-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRC calculation error for WriteSingleCoil response #338
Comments
Found the issue: This line creates
It is then sent to the WriteSingleCoilResponseBody constructor
Which is unable to correctly process boolean and instead tries to compare it agains
|
yangit
added a commit
to yangit/node-modbus
that referenced
this issue
Apr 20, 2024
…omation#338 The WriteSingleCoilResponseBody constructor declares that it can handle `boolen` but it can not do that. So I have addled boolean handling into the function.
yangit
added a commit
to yangit/node-modbus
that referenced
this issue
Apr 20, 2024
…omation#338 The WriteSingleCoilResponseBody constructor declares that it can handle `boolen` but it can not do that. So I have addled boolean handling into the function.
yangit
added a commit
to yangit/node-modbus
that referenced
this issue
Apr 20, 2024
Fix write-single-coil.ts incorrect processing of true value Cloud-Automation#338
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the problem
client.writeSingleCoil(6, true)
response is CRC-ed incorrectly if the values is set to trueclient.writeSingleCoil(6, false)
response is CRC-ed correctlyThe problem above is true for any register but I show it for register No6 so that it is easier to see where which bytes are.
Expected outcome
Both commands should CRC response correctly
Setup
I'm on Ubuntu 22.04.4 LTS Node v20.12.1 using FTDI UART TTL USB adapter
If I use serial port and send this command to my device:
and I get back this reply
The above is confirmed using
SerialPort
package REPL, and also by using 1 extra FTDI adapter evaesdropping on tx line from my device. So I'm 100% sure the response bytes what they are.If I use JS Modbus library like so
client.writeSingleCoil(6, true)
I get an error below (output is with
DEBUG=rtu*
)Error logs
One line stands out to me
Why it says 01 05 00 06 00 00? There should be ff 00
At the same time you can see that line below does indeed show correct data received.
The error is persistent and happens 100% of the time.
The error says
CRC error
.Feels like data got mangled somewhere deep in the library.
The text was updated successfully, but these errors were encountered: