|
|
Subscribe / Log in / New account

IR decoding with BPF

IR decoding with BPF

Posted Jul 10, 2018 8:58 UTC (Tue) by chris.sykes (subscriber, #54374)
In reply to: IR decoding with BPF by dgm
Parent article: IR decoding with BPF

> But I thought that libmodbus (http://libmodbus.org/) had this already implemented. Is it not the case?

Nope, libmodbus tries to parse the RTU frames as bytes are received in order to figure out how many are still outstanding; the trouble is, it has to do this before it can check the CRC...


to post comments

IR decoding with BPF

Posted Jul 10, 2018 14:00 UTC (Tue) by dgm (subscriber, #49227) [Link] (3 responses)

Any idea of why it does this instead of reading byte for byte and timing out?

IR decoding with BPF

Posted Jul 10, 2018 15:39 UTC (Tue) by chris.sykes (subscriber, #54374) [Link] (2 responses)

I suspect support for Modbus TCP, which uses length prefixed framing, was added first, with RTU coming later, and they kept the "how many bytes am I still waiting for" code in the common layer.

It's difficult to do RTU frame timing properly from user-space, without RT scheduling; and you really want control over the RX FIFO interrupt thresholds in the UART as well.

I've often thought making Modbus RTU serial line discipline, that exposed a socket API (like socketCAN), would make an interesting project, but so far, haven't found the time...

IR decoding with BPF

Posted Jul 11, 2018 7:22 UTC (Wed) by shiftee (subscriber, #110711) [Link] (1 responses)

So do you think BPF could be modified (in theory at least) to read Modbus RTU packets and somehow provide them to user space as length prefixed frames?

IR decoding with BPF

Posted Jul 11, 2018 9:44 UTC (Wed) by Darkmere (subscriber, #53695) [Link]

Probably. One of the interesting use cases for that is a system where you have multiple speeds on the same physical network.

With rs485 you then want to decode traffic in multiple speeds at once to find out which traffic is modbus RTU and which is some other traffic.
(It’s common enough to have Mbus at 2400 bps and modbus at 9600 and 19200. And no. It ain’t pretty)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds