Optional mode for RTU over TCP - #55
Open
domob1812 wants to merge 2 commits into
Open
Conversation
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.
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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements an optional mode (configured via
mode: rtuovertcpin a device'modbusconfig 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/falseconfiguration, 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.