User avatar
esa1966
Posts: 11
Joined: Mon Apr 15, 2013 5:31 pm
Location: Belgium
Contact: Website

Serial Sniffer & Send XON

Tue Jul 08, 2014 7:38 pm

Hi,

I have a issue on a device and this will be my first step in LINUX world (and with the Raspberry Pi).

The situation :
I have two devices connected through RS232.
One device regularly stop to communicate (No more data on TX).
After analysis, a XON is the solution to relaunch the communication.
So we suppose that an XOFF has been send and I must prove it.

I need to do two thinks :
1) Use a SNIFFER on the SERIAL port (RX & TX) and create a LOG FILE.
2) Listen on the TX and if there is no more transmission then I send a XON and I restart the Sniffer that will create a new file.

1) Sniffer solution :
For the Sniffer, I see http://jpnevulator.snarl.nl/.
It has the possibility to log BIN and ASCII.

2) Listening & Transmit XON :
I think about a little program with PYTHON that Listen to TX.
How to do such listening easily?
This program listen on the TX and if there is no more data, it will do :
1) STOP the SNIFFER : I suppose it not complicated to do.
2) Commute a Relay (to disconnect the RX pin from te other device and connect to the RPi)
3) Rpi will SEND the XON
4) Restart the Sniffer.

I suppose, that I absolutely need to use two SERIAL ports :
- one to Spy the RX+TX for the Sniffer : http://www.lammertbies.nl/comm/cable/RS ... nitor.html
- and another to Listen the TX on the second serial port.

Is it the good way or is it a better solution?
Who can give some advices and guide me in the Python listener?

Thank

User avatar
joan
Posts: 14378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Serial Sniffer & Send XON

Tue Jul 08, 2014 8:20 pm

Serial data transfer stops between two devices maybe because an XOFF has been sent.

Is one of the devices a Rapberry Pi?

What serial data format and baud rate is being used?

User avatar
esa1966
Posts: 11
Joined: Mon Apr 15, 2013 5:31 pm
Location: Belgium
Contact: Website

Re: Serial Sniffer & Send XON

Thu Jul 10, 2014 6:20 am

Actually, I have two devices. One is a fire panel that doesn't answer as I suppose he received a XOFF.
The other is a terminal server.
So, in place of sniffing the COM between the two devices, I can plan to replace the actual server with a Rpi running "ser2net".
The log can be made with this tool.
Now, to detect a lack of communication, i suppose I can checvk the log file.
If it doesn't change, I can take the action :
- stop ser2net
- send an xon
- listen the fire panel
- if ok : restart ser2net

Any advice and how to detect the stop of communication from fire panel?
Thanks

User avatar
joan
Posts: 14378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Serial Sniffer & Send XON

Thu Jul 10, 2014 8:13 am

esa1966 wrote:Actually, I have two devices. One is a fire panel that doesn't answer as I suppose he received a XOFF.
The other is a terminal server.
So, in place of sniffing the COM between the two devices, I can plan to replace the actual server with a Rpi running "ser2net".
The log can be made with this tool.
Now, to detect a lack of communication, i suppose I can checvk the log file.
If it doesn't change, I can take the action :
- stop ser2net
- send an xon
- listen the fire panel
- if ok : restart ser2net

Any advice and how to detect the stop of communication from fire panel?
Thanks
So you plan to abandon the server and replace it permanently with a Pi?

In that case why would the two ends stop communicating?

The only way to tell if communication has failed is to time-out an expected response.

The original sniffer idea to try to identify the root problem seems better.

Note, if you use the Pi's UART gpios they are 3.3V.

User avatar
esa1966
Posts: 11
Joined: Mon Apr 15, 2013 5:31 pm
Location: Belgium
Contact: Website

Re: Serial Sniffer & Send XON

Thu Jul 10, 2014 4:40 pm

In fact, the actual terminal server (tcp<->rs232) is transparent.
The scada (master) speaks with the fire panel throught this TS.
So if I replace the actual TS by the Rpi+ser2net, I'm sure that the problem will continue to happen.
And as ser2net can also do a log (with separated rx &tx), it easier that using two usb rs232.
Now, it's when we speak together that new solution can be improved.
As I never used ser2net, I'm not sure of that solution.
I'm a biginner in python programming. If s/o can advice me how to create the little script, I'll apreciate.
Thank.

User avatar
joan
Posts: 14378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Serial Sniffer & Send XON

Thu Jul 10, 2014 5:29 pm

Sorry, I don't see that I can be any help. I'm not familiar with scada, fire-panels, the way they communicate, or ser2net.

User avatar
tedhale
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
Contact: Website

Re: Serial Sniffer & Send XON

Thu Jul 10, 2014 6:57 pm

If the terminal server is sending an XOFF, it is because the fire panel is sending data faster than the terminal can receive it and it is about to overflow it's buffer. The Pi solution may be able to receive data faster and not have this problem. If it does have the same problem, then you could turn off soft flow control but that risks losing data.
Or, it could be that the terminal is sending binary data. In that case, you will occasionally get an XOFF character. It is better if you can use hardware handshaking, but be aware that the simple serial port on the Pi does not include any handshaking lines.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com

Return to “General programming discussion”