diff --git a/examples/linux/platform.h b/examples/linux/platform.h index f315bfe..517cb3c 100644 --- a/examples/linux/platform.h +++ b/examples/linux/platform.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -164,10 +165,13 @@ void disconnect(void* conn) { } -// Read/write/sleep platform functions +// Read/write platform functions int32_t read_fd_linux(uint8_t* buf, uint16_t count, int32_t timeout_ms, void* arg) { - if(!arg) return -1; + if (!arg) { + return -1; + } + int fd = *(int*) arg; uint16_t total = 0; diff --git a/examples/linux/server-tcp.c b/examples/linux/server-tcp.c index 3361af2..50dd13b 100644 --- a/examples/linux/server-tcp.c +++ b/examples/linux/server-tcp.c @@ -220,14 +220,12 @@ int main(int argc, char* argv[]) { if (conn) { // Set the next connection handler used by the read/write platform functions nmbs_set_platform_arg(&nmbs, conn); - }else{ - continue; - } - err = nmbs_server_poll(&nmbs); - if (err != NMBS_ERROR_NONE) { - printf("Error on modbus connection - %s\n", nmbs_strerror(err)); - // In a more complete example, we would handle this error by checking its nmbs_error value + err = nmbs_server_poll(&nmbs); + if (err != NMBS_ERROR_NONE) { + printf("Error on modbus connection - %s\n", nmbs_strerror(err)); + // In a more complete example, we would handle this error by checking its nmbs_error value + } } }