Try a different poll; same suspect register, length=1 or something.
I stand by “RS485 does weird stuff” so it is worth a try to see if thesame bit pattern gets through in a different packet structure. It’s really unlikely a genuine wire problem would be this consistent though.
Modbus-RTU has strict rules about maximum gaps between characters. Any implementation may be sloppy about implementing those, for send or receive.
Again, detailed analysis at the line level is necessary to finger point about that sort of thing.
It’s not unreasonable to ask for openHAB to be more forgiving, but we still don’t know what needs forgiving yet.
Darn serial, we always seem to go very low-level with this one Line level understanding would be probably the best insight into the topic. Is that what you meant with “old laptop as serial monitor”?
Based on javacomm serial library documentation (which is actually not used by OH but I guess the API is similar enough), we have “Note, however, that framing errors may cause the Timeout and Threshold values to complete prematurely without raising an exception.” – This is happening when we get “awaited 4 bytes, but received 2” log message. Does this give more hints?
I guess the socat suggestion might reveal something but then again it might hide the issues as socat would sit “between” the real serial port and openHAB.
I could try to make a special version of binding which tries to read bytes again if we timeout and not get all bytes at first time. It seems unlikely this would fix the issue though…
I don’t have a good enough understanding of what goes on between serial device and binding.
Something (the USB adaptor that I assume is in use) gets a byte at a time, something decides the bytes have stopped coming so “here’s a packet” and in our case it’s short.
A framing error pretty much means the stop bit was missed at the expected time, very low level error.
Poor bit timing by the transmitter or receiver can cause framing errors, and that could be sensitive to last data bit sent. That’d be the most significant bit, used as sign bit in signed integers…
I would expect bytes to be discarded at low level, but maybe not. That would leave the library to decide to pass along garbage or not, if it bothers checking for the framing error flag.
Can we tell if there really is a framing error at the hardware or do intervening libraries hide that?
Maybe @pete3 is able to try some read polls that include a larger proportion of bytes over hex80 value?
Hmm … can you make “programatically” inject the bytes from serialport, to see if openhab “alone” has similar behavior? That would also help isolating the problem.
One can then utilise diagslave (virtual modbus slave) and modpoll (modbus maste) to fill up the registers with the data you want to have. Pointing the openHAB to the other end of the null modem emulator allows you to read data from this local diagslave modbus serial slave
Many things are probably different to real slave and real serial communications… not sure how well it gives insights to the issues
EDIT: I tested this myself. Openhab can read the -10004=0xD8EC just fine over this “null modem emulator”, diagslave acting as modbus rtu slave. The issue can be something platform specific (I have 64bit linux x86_64) or related to something more lower level
It will not fix your issue but instead of DEBUG level log message ("awaited 4 bytes, but received 2") & issueing CRC errors, error more loudly logged about the missing bytes.
gnu.io refers to the serial support of openHAB. You can install it e.g. by feature:install openhab-transport-serial. I would expect then the modbus transport installation to work
Hi, just upgrade from 2.5.9 to 3 and now on snapshot to fix the locking problem (Thanks @ssalonen ) and am wondering if my CRC error issue is related to this subject. (On 2.5.9 had occasionally 1 of 3 try failed but never 2nd or 3rd).
Using a PI4, serial USB interface (Cheap Chinese), CAT5 cable with co-located 3xEastron SDM630, 2x SDM120 and about 10m away a WP8028ADAM. The SDM’s poll at 60,000ms and the WP8028 at 500ms. All ModBUS timings are OpenHAB default. The SDM630 & WP8028ADAM have zero errors. Both SDM120 however both have equal amount of excessive CRC resulting in approx. 100 OFFLINE (Est. 5% of the poll’s) events per 24hours with error as follows: