This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
sdk:scripts:modbus-tcp-rtu-gateway [2022/07/07 12:14] – klueppel | sdk:scripts:modbus-tcp-rtu-gateway [2022/09/05 12:07] – schmitt | ||
---|---|---|---|
Line 7: | Line 7: | ||
DEV = sprintf(" | DEV = sprintf(" | ||
TCP_PORT | TCP_PORT | ||
- | DEBUG = 0; | ||
- | |||
- | |||
/* check serial port config */ | /* check serial port config */ | ||
Line 19: | Line 16: | ||
/* set attributes */ | /* set attributes */ | ||
- | ret = nb_serial_setattr(DEV, | + | ret = nb_serial_setattr(DEV, |
if (ret != 0) { | if (ret != 0) { | ||
nb_syslog(" | nb_syslog(" | ||
Line 61: | Line 58: | ||
exit(1); | exit(1); | ||
} | } | ||
- | if (DEBUG == 1) { | + | |
- | nb_modbus_set_debug(serial_fd, | + | |
- | } | + | |
printf(" | printf(" | ||
- | |||
tcp_client = -1; | tcp_client = -1; | ||
registered = 0; | registered = 0; | ||
- | |||
while (1) { | while (1) { | ||
Line 78: | Line 71: | ||
sleep(1); | sleep(1); | ||
continue; | continue; | ||
- | | + | } |
- | if (DEBUG == 1) { | + | |
- | nb_modbus_set_debug(tcp_client, | + | |
- | | + | |
} | } | ||
Line 110: | Line 100: | ||
nb_syslog(" | nb_syslog(" | ||
} else { | } else { | ||
- | /* Modbus TCP - RTU must set the slave id */ | ||
- | | ||
- | if (ret > 0) { | ||
- | nb_syslog(" | ||
- | break; | ||
- | } | ||
- | |||
response = nb_modbus_send_raw(serial_fd, | response = nb_modbus_send_raw(serial_fd, | ||
if (is_void(response)) { | if (is_void(response)) { |