Skip to content

Commit 5aac8bf

Browse files
committed
RTU and TCP select fixes
1 parent 1043512 commit 5aac8bf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libmodbus/modbus-rtu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ static int _modbus_rtu_select(modbus_t *ctx, fd_set *rset,
12631263
do {
12641264
s_rc = RS485.available();
12651265

1266-
if (s_rc == length_to_read) {
1266+
if (s_rc >= length_to_read) {
12671267
break;
12681268
}
12691269
} while ((millis() - start) < wait_time_millis);

src/libmodbus/modbus-tcp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,10 @@ static int _modbus_tcp_select(modbus_t *ctx, fd_set *rset, struct timeval *tv, i
833833
do {
834834
s_rc = ctx_tcp->client->available();
835835

836-
if (s_rc == length_to_read) {
836+
if (s_rc >= length_to_read) {
837837
break;
838838
}
839-
} while ((millis() - start) < wait_time_millis);
839+
} while ((millis() - start) < wait_time_millis && ctx_tcp->client->connected());
840840
#else
841841
while ((s_rc = select(ctx->s+1, rset, NULL, NULL, tv)) == -1) {
842842
if (errno == EINTR) {

0 commit comments

Comments
 (0)