How to detect failure in Modbus communication


peyro

Recommended Posts

Hello, I am using Modbus RTU driver to communicate with a PLC, however sometimes the cable fails and would like to display an alarm on screen. What function can be used for this purpose?? does this function should be polled periodically to test the link or can it be an event??

Thanks in advance for any help...

peyro

Link to comment
Share on other sites

If the cable falls out, you are likely going to get a timeout error from DAQFactory because the device will never respond. If you are using channels, you can use the OnAlert event to capture this. If you are using script to poll, you can simply use try/catch

Link to comment
Share on other sites

  • 2 years later...

Azeotech,

I am trying to acheive the same thing as this (IE having a 'COMMS FAILED' indicator on my screen) - however my serial device does not stream. I need to send a serial command and expect a response by return.

If I unplug my serial cable and then send my command - I simply don't get a response... not an error.

Is there a way of either monitoring that an Rx has not been recieve within xx-seconds of a Tx command? or alternatively monitoring that an Rx has not been received for xx number of seconds?

I am not sure that try/catch will work because as mentioned - I do not receive an error...

Link to comment
Share on other sites

The original poster's device didn't stream either. Modbus is a poll / response protocol. If you are polling from channels, then you'll need to use OnAlert. If you are polling directly from script, you will get an error when you do your read() or readuntil() call and there is no data available (it times out). A try/catch will handle this.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.