You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Invalid in TCP or RTU mode...modbus_t*invalid_ctx=modbus_new_tcp("1.2.3.4", 1502);
modbus_set_response_timeout(ctx, 0, 1); // <-- BUG: should be invalid_ctx, right?rc=modbus_connect(invalid_ctx);
printf("8/8 Connection timeout: ");
ASSERT_TRUE(rc==-1&&errno==ETIMEDOUT, "");
modbus_free(invalid_ctx);
When adjusting the response timeout in ctx rather the intendet invalid_ctx the connection fails with errno 111 (connection refused).
I'm not quite clear why this happens, as we try to use invalid_ctx in the connect statement and not ctx. The errno is set to ETIMEDOUT in modbus-tcp.c:310 correctly, when using the timeout on invalid_ctx. However, when we do not set the timeout, then the errno is set to ECONNREFUSED in modbus-tcp.c:319.
By changing ctx to invalid_ctx in the test code (see snipped above) the test suite runs correctly again. -> pull request
ghorwin
added a commit
to ghorwin/libmodbus
that referenced
this issue
Jan 20, 2025
Running
unit_tests.sh
gives an assert in theunit-test-client.log
:This causes the test suite to fail.
The text was updated successfully, but these errors were encountered: