node-modbus-serial icon indicating copy to clipboard operation
node-modbus-serial copied to clipboard

Modbus RTU sniffer

Open tenisak opened this issue 4 years ago • 4 comments

I would need to use node.js to listen for Modbus RTU communication between two other devices. Is this possible? I don't know if the modbus-serial library can be used for this. My idea is to open the serial port and route the data from rx line directly to the parser. I will not send requests, I will only get responses. How to do it? :-)

tenisak avatar Feb 16 '21 08:02 tenisak

Hi, thanks for the question

You should use some serial port sniffing tool, that expose a virtual port that sniffs the port/s you are using for communication this is a random link I found searching for serial sniffer: https://www.cyberciti.biz/faq/howto-monitor-data-on-a-serial-port-in-linux/

yaacov avatar Feb 16 '21 09:02 yaacov

Thanks a lot for the quick response! Opening a serial port and getting raw data is easy... Rather, I'm looking for a way to use the parser you have inside modbus-serial. Is it possible to use _onReceive function somehow? Insert any of my functions into transaction.next and continue by CRC check, etc.? :-)

tenisak avatar Feb 16 '21 10:02 tenisak

No, but you can create one :-) you can create a port that does that, for the client side look at how works https://github.com/yaacov/node-modbus-serial/blob/master/ports/rtubufferedport.js it's not exactly what you are looking for but it may be a starting point.

yaacov avatar Feb 16 '21 11:02 yaacov

Thanks so much for the starting point. I will try to deal with it :-)

tenisak avatar Feb 16 '21 13:02 tenisak