stephane / libmodbus

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

modbus_strerror is not clear. Can you give a clear error return value to help locate the problem? #636

Closed yanzhang920817 closed 1 year ago

yanzhang920817 commented 2 years ago

I have the following code. If the return value fails, it just returns "write failed: unknown error 112345678". Can you list several return values so that I can know why the write failed?

`    int ret;
    ret = modbus_write_register(m_ctx, addr, value);
    if (ret == -1) {
        printf("write failed: %s\n", modbus_strerror(errno));
    }
    usleep(100);
    return ret;`
stephane commented 1 year ago

Your error code is not know so I can't help you...