stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.29k stars 1.71k forks source link

ERROR Unknown error: select select function return -1 and no err #689

Open ezreal1129 opened 1 year ago

ezreal1129 commented 1 year ago

use version 3.1.10 on windows, When the client sets the timeout time to 2s and reply time to 3s using modbus slave software, why is ERROR Unknown error: select displayed on the client? When viewing the source code, it is found that select returns -1, but normally 0 should be returned.

the client output: Waiting for a confirmation... ERROR Unknown error: select Error modbus_write_registers: -1

The connection settings are as follows: ret = modbus_set_response_timeout(ctx, 2, 0); printf("sec:%d,usec:%d\n", ctx->response_timeout.tv_sec,ctx->response_timeout.tv_usec);

//write registers int ret = modbus_write_registers(ctx,address,nums,sendBuf); if (ret != nums) { printf("Error modbus_write_registers: %d\n", ret); return -1; } free(sendBuf); modbus_disconnect(ctx); return 0;

the modbus slave software setting: image