하드웨어/PLC (LSE)2022. 5. 11. 10:47

이런 드러운 그지 깽깽이들 -_-

전달 받은 프로그램은 XPE 라서 XPD를 열수 있는 XP-Builder와는 호환되지 않는다.

 

'하드웨어 > PLC (LSE)' 카테고리의 다른 글

lse plc 작화(drawing) cpu internal 변수  (0) 2022.05.12
lse plc fenet  (0) 2022.05.11
LSE PLC XGL-CH2B  (0) 2022.04.28
PLC not  (0) 2022.04.28
plc toggle  (0) 2022.04.28
Posted by 구차니

pi 라는 함수들이 있어서 찾아보니 코드로는 모르겠고

도움말에서 검색.. Protocol Independent. 무슨 의미이려나?

아무튼 메모리 1Kb 더 먹고 hostname resolve를 제공한다는 것 같은데(resolution은 또 머야..)

그 기능만 차이가 있다면 굳이 pi를 쓸 이유는 없을 듯

 

TCP (IPv4) Context

The TCP backend implements a Modbus variant used for communications over TCP/IPv4 networks. It does not require a checksum calculation as lower layer takes care of the same.
Create a Modbus TCP contextmodbus_new_tcp(3)

TCP PI (IPv4 and IPv6) Context

The TCP PI (Protocol Indepedent) backend implements a Modbus variant used for communications over TCP IPv4 and IPv6 networks. It does not require a checksum calculation as lower layer takes care of the same.
Contrary to the TCP IPv4 only backend, the TCP PI backend offers hostname resolution but it consumes about 1Kb of additional memory.
Create a Modbus TCP contextmodbus_new_tcp_pi(3)

[링크 : https://libmodbus.org/docs/v3.0.8/]

'프로그램 사용 > libmodbus' 카테고리의 다른 글

libmodbus modbus_mapping_new()  (0) 2022.05.10
libmodbus poll 적용  (0) 2022.05.04
modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
Posted by 구차니

미국 대통령에 의한 우크라이나 민주주의 방어를 위한 lend-lease 법이 통과되었다고.

우크라이나를 앞세운 미국의 대리전, 그리고

그 상대국은 일차적으로는 러시아지만.. 중국이 어떻게 움직일지 모르는 상황이고,

중-러 둘다 내부상황이 좋지 않기에, 불만을 외부로 돌리기 위해 어떻게 튈지 전혀 예측이 안되는 상황.

 

[링크 : https://www.whitehouse.gov/briefing-room/speeches-remarks/2022/05/09/remarks-by-president-biden-at-signing-of-s-3522-the-ukraine-democracy-defense-lend-lease-act-of-2022/]

Posted by 구차니

함수는 간단한데.. 예제가 이상하게 만들어 놔서 헷갈렸네..

아무튼 modbus_mapping_new() 함수의 인자들은 

coil / discrete input / holding register / input register 에 대한 변수를 몇개까지 유지하냐에 대한 값을 받는다.

 

modbus_mapping_t modbus_mapping_new(int nb_bits, int nb_input_bits, int nb_registers, int nb_input_registers);

[링크 : https://libmodbus.org/docs/v3.0.8/modbus_mapping_new.html]

 

libmodbus의 test 에 생성된 unit-test.h 소스에서 추출하고

 29 const uint16_t UT_BITS_ADDRESS = 0x130;
 30 const uint16_t UT_BITS_NB = 0x25;
 31 const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B };
 32
 33 const uint16_t UT_INPUT_BITS_ADDRESS = 0x1C4;
 34 const uint16_t UT_INPUT_BITS_NB = 0x16;
 35 const uint8_t UT_INPUT_BITS_TAB[] = { 0xAC, 0xDB, 0x35 };
 36
 37 const uint16_t UT_REGISTERS_ADDRESS = 0x160;
 38 const uint16_t UT_REGISTERS_NB = 0x3;
 39 const uint16_t UT_REGISTERS_NB_MAX = 0x20;
 40 const uint16_t UT_REGISTERS_TAB[] = { 0x022B, 0x0001, 0x0064 };

 56 const uint16_t UT_INPUT_REGISTERS_ADDRESS = 0x108;
 57 const uint16_t UT_INPUT_REGISTERS_NB = 0x1;
 58 const uint16_t UT_INPUT_REGISTERS_TAB[] = { 0x000A };

 

최신 문서에서 보는데 오히려 더 헷갈린다.

/* The first value of each array is accessible from the 0 address. */
mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB,
                                INPUT_BITS_ADDRESS + INPUT_BITS_NB,
                                REGISTERS_ADDRESS + REGISTERS_NB,
                                INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB);

[링크 : https://libmodbus.org/docs/v3.1.6/modbus_mapping_new.html]

 

아래처럼 수정하고

        mb_mapping = modbus_mapping_new(10,10,10,10);

 

modbus poll 프로그램에서 아래와 같이 실제 설정된 크기보다 크게 읽도록 하니

 

illegal data address 라고 에러가 발생한다.

 

아무튼.. 메모리 시작 번지는 의미가 없고 그냥 0번지 부터 해당 크기 만큼 응답하게 되는 듯?

 

+

[링크 : https://www.codetd.com/ko/article/12030369]

[링크 : https://m.blog.naver.com/ssundong0_0/221385568015]

[링크 : https://intrepidgeeks.../libmodbus-source-code-analysis-1-basic-framework-key-data-structure-and-interface]

'프로그램 사용 > libmodbus' 카테고리의 다른 글

libmodbus pi 함수들  (0) 2022.05.10
libmodbus poll 적용  (0) 2022.05.04
modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
Posted by 구차니

써멀이 쓸데없이 귀엽게 발라졌네

 

소중한 딸래미의 개인정보 유출 방지를 위해 eMMC를 아작내버리고 쓰레기통으로 슝~

'개소리 왈왈 > 모바일 생활' 카테고리의 다른 글

요금제 변경 시도  (0) 2022.06.02
어라 요금제 폭탄?  (0) 2022.05.17
오늘의 지름  (0) 2022.04.06
v50s 액정 사설 수리 비용  (0) 2022.03.04
액정깨짐  (0) 2021.10.23
Posted by 구차니

그냥 그냥저냥 지나감

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

포켓몬 빵 사겠다고  (2) 2022.05.15
요즘은 금쪽이 보고 사는 중  (0) 2022.05.13
생일, 결혼기념일  (0) 2022.05.07
노트5 파괴!  (0) 2022.05.06
어린이날  (0) 2022.05.05
Posted by 구차니

5월 가정 경제 파탄의 달 마지막(?) 행사가 되길 ㅠㅠ

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

요즘은 금쪽이 보고 사는 중  (0) 2022.05.13
어버이날  (0) 2022.05.08
노트5 파괴!  (0) 2022.05.06
어린이날  (0) 2022.05.05
메인보드 구매, 교체  (0) 2022.04.30
Posted by 구차니

강화에 실패.

 

이전 핸폰이 액정 나가고 배터리도 나가고..

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

어버이날  (0) 2022.05.08
생일, 결혼기념일  (0) 2022.05.07
어린이날  (0) 2022.05.05
메인보드 구매, 교체  (0) 2022.04.30
장모님댁  (0) 2022.04.29
Posted by 구차니

어른이날은 왜 없냐고

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

생일, 결혼기념일  (0) 2022.05.07
노트5 파괴!  (0) 2022.05.06
메인보드 구매, 교체  (0) 2022.04.30
장모님댁  (0) 2022.04.29
신속항원 검사  (0) 2022.04.17
Posted by 구차니

기본 소스를 사용해보면. modbus_receive() 에서 블록킹 된 상태라서 다른걸 할 수가 없다.

 

검색을 해보니 libmodbus issue 쪽에서 발견한 내용으로

poll 에서 확인이 되면 소켓을 modbus_set_socket() 함수를 이용하여 context에 연결하고 receive 하도록 구성되어 있다.

    modbus_t *ctx = modbus_new_tcp("0.0.0.0", port_);
    int server_socket = modbus_tcp_listen(ctx, 2);
    if (server_socket < 0) {
      // error handling
      modbus_free(ctx);
      return;
    }

          if (p->revents & POLLIN) {
            modbus_set_socket(ctx, p->fd); // set the socket to libmodbus answers to the right client

            uint8_t query[MODBUS_RTU_MAX_ADU_LENGTH];
            int rc = modbus_receive(ctx, query);
            if (rc <= 0) { // connection has been closed actually by the client
              ::close(p->fd);
              p = sockets.erase(p); // remove it from the poll-array
              continue;
            }

            /* rc is the query size */
            rc = modbus_reply_callback(ctx, query, rc); // handle the reply (via the callbacks)
            if (rc < 0) {
              // error handling - invalid request
              ::close(p->fd); // close client
              p = sockets.erase(p);
              continue;
            }
          }

[링크 : https://github.com/stephane/libmodbus/issues/173]

 

[링크 : https://libmodbus.org/docs/v3.0.8/modbus_set_socket.html]

'프로그램 사용 > libmodbus' 카테고리의 다른 글

libmodbus pi 함수들  (0) 2022.05.10
libmodbus modbus_mapping_new()  (0) 2022.05.10
modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
Posted by 구차니