Skip to content

Optional mode for RTU over TCP - #55

Open
domob1812 wants to merge 2 commits into
tiagocoutinho:masterfrom
domob1812:rcu-echo
Open

Optional mode for RTU over TCP#55
domob1812 wants to merge 2 commits into
tiagocoutinho:masterfrom
domob1812:rcu-echo

Conversation

@domob1812

Copy link
Copy Markdown

This implements an optional mode (configured via mode: rtuovertcp in a device' modbus config section) where on the device side, we expect raw RTU frames instead of modbus TCP. For instance, from a RS485-to-TCP adapter that is transparently passing over the RTU data instead of converting correctly to modbus TCP.

It also adds a strip_rtu_echo: true/false configuration, which can in addition strip an echo for adapters that use a full-duplex wiring with separate R and T lines, but are connected to a half-duplex device.

This implements #48. I have tested the change with a Waveshares adapter in fully transparent mode connected to a Huawei Sun2000 inverter, which requires both changes to be applied for correct communication.

This adds logic to support device-side communication in raw RTU frames
rather than modbus TCP, e.g. for RS485-to-TCP adapters that transparently
forward the underlying RTU frames instead of properly converting them.

To enable the mode, use "mode: rtuovertcp" in a device' "modbus"
configuration section.
For RTU mode, add an optional mode ("strip_rtu_echo: true") where the
device side is assumed to echo back the request before the actual
reply, such as when a full-duplex adapter (with separate R and T
lines) is wired to a half-duplex device.
@domob1812

Copy link
Copy Markdown
Author

I've modified the PR to use a different logic for reading RTU frames: Instead of "knowing" how long a frame should be for certain function codes, we read bytes until the CRC checksum matches. This is agnostic of the actual function code used, more elegant, and it supports custom modbus extensions as well (which my inverter uses for some functionality).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant