Skip to content

Commit aab9281

Browse files
committed
src/modbus.c: _modbus_receive_msg(): if ctx->backend->select() failed on WIN32, and we follow MODBUS_ERROR_RECOVERY_LINK, do modbus_flush(ctx)
At least this allows unit-tests to pass... Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 376d016 commit aab9281

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/modbus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type)
427427
wsa_err = WSAGetLastError();
428428

429429
// no equivalent to ETIMEDOUT when select fails on Windows
430+
// but we still need it to forget the invalid answer
431+
modbus_flush(ctx);
430432
if (wsa_err == WSAENETDOWN || wsa_err == WSAENOTSOCK) {
431433
modbus_close(ctx);
432434
modbus_connect(ctx);

0 commit comments

Comments
 (0)