Skip to content

Using modbus_receive with an external event loop (infinite timeout) #215

@karlp

Description

@karlp

Related to: #95
I've got a modbus tcp/rtu relay, similar to #111 but even with that pull, the same problem exists.

The only method for receiving from a tcp socket is modbus_receive, which, for indications, will block indefinitely. Once a single byte has been received on the socket, it will correctly timeout if a full frame isn't received. I'm using libevent2, and I can set a watermark so that I only get the event when backend->header_length bytes have been received, so I'd like to be able to have some method of getting into the "middle" of modbus_receive. The problem with accept and modbus_receive is that there's no way out once you've called it. While the existing system works fine for real clients, a single user telneting to the listening port and not sending any data simply blocks the server.

I can't (yet) see any way around this without modifying libmodbus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions