How do I know if a serial port is actually transmitting data, without opening the device?

Peter Kovac

I have a high-availability cluster (Heartbeat) connected via serial line and two ethernet NICs. I'd like to set up a monitoring script capable of recognizing disconnected serial line (basically the same question was answered at SO, however I am not satisfied with such a general answer).

I cannot simply open the serial device and read the data myself, since the serial line is opened by Heartbeat.

So I started to look for some indirect clues. The only difference I have found so far is in the contents of /proc/tty/driver/serial. This is how it looks like when it's connected:

# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:2722759 rx:2718165 brk:1 RTS|CTS|DTR|DSR|CD

And when disconnected:

# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:2725233 rx:2720703 brk:1 RTS|DTR

I'm not confident enough to decide that the signals listed at the end of the line have the very meaning of connected/disconnected cable as I have not found any documentation on the contents of the /proc/tty/driver/serial. I can only assume that the presence of the signal means the given signal is on "right now" (or was in recent past? or?). The Serial HOWTO says that additional signals present when the cable is connected (CTS flow control signal, DSR "I'm ready to communicate", CD "Modem connected to another") are all in the "input" direction. So there has to be somebody alive at the other end.

Assuming that meaning of signals is as described in the Serial HOWTO, I can base my decision on the presence of, say CD signal. However I am not really sure.

So the question is: is my method "right", or do I have any better options I am not aware of?

EDIT: I did some additional observations and had a talk with my colleague. Turns out the presence or absence of signals at the end of the line is quite good indicator of the serial port activity, on both ends. However, it's not an indicator of physical presence of a cable. Whenever there was a program writing to serial port outgoing signals were present (RTS|DTR). When the other side was writing incoming signals were present (CTS|DSR|CD). When none of the sides communicates there are no signals at all (that does not necessarily mean there is no cable present). Don't forget that the exact signals depend on the wiring of the cable (I have "null modem with partial handshaking").

SF.

RS232 has no "cable presence" indicator of any kind. You're just getting transmission or metadata (control) signals through, or you don't - that's all you know. If you receive an incoming signal (CTS|DSR|CD) you know the cable is connected. If you don't receive any incoming signal, the state of the cable is indeterminate and there is no way to determine if it's plugged in without additional hardware solutions - or performing some kind of exchange with the remote device.

The usual approach is performing some kind of "keep-alive" transmissions (even just metadata - e.g. momentarily set DTR and expect CTS) but if the discipline of protocol used by software at the two ends of the cable forbids such idle exchange, you're pretty much stuck with using a soldering iron to proceed.

What you might try, is some kind of additional "demon" that sets up a pipe, forwarding data between your software and the physical device (on both ends), encapsulating it - and performing "connection checks" if the pipe is idle.

Let me add one rather common solution: if your endpoint device doesn't use hardware control, you can short DTR with CTS inside the plug on the host side and use 'hardware control' on the host side. Generating DTR automatically drives CTS, enabling the transmission, if the cable is present, so transmission is unaffected. Meanwhile, with cable absent, the system will react to lack of CTS in a manner appropriate to this event, e.g. generating a timeout or suspending transmission until the cable is plugged in.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I know which /dev/ttyS* is my serial port?

From Dev

How do I access a USB serial port without an entry in /dev?

From Dev

Knowing when a write() on a serial port has finished transmitting data

From Dev

Python : How to know serial port device events like keybord events

From Dev

How do I mark mail as read in Lotus Notes without actually opening the email?

From Dev

How can I know which serial port corresponds to a PCI card?

From Dev

How can I know the process name which is opening a tcp port?

From Dev

What does opening a serial port do?

From Dev

opening a usb-serial port using the device VID/PID

From Dev

opening a usb-serial port using the device VID/PID

From Dev

How do I get the data from a serial GPS connected to my android device?

From Dev

How to read Binary Data from Serial Port without any Encoding?

From Dev

How do I know when Mongoose addToSet actually adds something?

From Dev

How do I know that a drive that is not labelled 'recovery' is actually the recovery drive?

From Dev

How do I use a serial port on Linux like a pipe or netcat?

From Dev

How do I find out if something is using the serial port?

From Dev

How do I write a sequence of bytes to a serial port in java

From Dev

How should I go about monitoring the I/O of a serial port if I have a device which takes in two serial ports?

From Dev

How to detect whether Arduino's Serial is transmitting?

From Dev

Transmitting/Receiving data to/from a GRPS device

From Dev

How do I use jpnevulator to capture and log the serial traffic between an application and hardware serial port?

From Dev

How do I 'merge' a git branch without actually merging it

From Dev

How do I test an executable without actually running it?

From Dev

How do I know the device path to an USB-stick?

From Dev

How do I know if a NAT device is taking place on my network?

From Dev

How do i know my device ScreenLock settings in Android

From Dev

How do I know the device path to an USB-stick?

From Dev

Simulate a serial port that actually is an internet port

From Dev

Read data from serial port device in c#

Related Related

  1. 1

    How do I know which /dev/ttyS* is my serial port?

  2. 2

    How do I access a USB serial port without an entry in /dev?

  3. 3

    Knowing when a write() on a serial port has finished transmitting data

  4. 4

    Python : How to know serial port device events like keybord events

  5. 5

    How do I mark mail as read in Lotus Notes without actually opening the email?

  6. 6

    How can I know which serial port corresponds to a PCI card?

  7. 7

    How can I know the process name which is opening a tcp port?

  8. 8

    What does opening a serial port do?

  9. 9

    opening a usb-serial port using the device VID/PID

  10. 10

    opening a usb-serial port using the device VID/PID

  11. 11

    How do I get the data from a serial GPS connected to my android device?

  12. 12

    How to read Binary Data from Serial Port without any Encoding?

  13. 13

    How do I know when Mongoose addToSet actually adds something?

  14. 14

    How do I know that a drive that is not labelled 'recovery' is actually the recovery drive?

  15. 15

    How do I use a serial port on Linux like a pipe or netcat?

  16. 16

    How do I find out if something is using the serial port?

  17. 17

    How do I write a sequence of bytes to a serial port in java

  18. 18

    How should I go about monitoring the I/O of a serial port if I have a device which takes in two serial ports?

  19. 19

    How to detect whether Arduino's Serial is transmitting?

  20. 20

    Transmitting/Receiving data to/from a GRPS device

  21. 21

    How do I use jpnevulator to capture and log the serial traffic between an application and hardware serial port?

  22. 22

    How do I 'merge' a git branch without actually merging it

  23. 23

    How do I test an executable without actually running it?

  24. 24

    How do I know the device path to an USB-stick?

  25. 25

    How do I know if a NAT device is taking place on my network?

  26. 26

    How do i know my device ScreenLock settings in Android

  27. 27

    How do I know the device path to an USB-stick?

  28. 28

    Simulate a serial port that actually is an internet port

  29. 29

    Read data from serial port device in c#

HotTag

Archive