0

TL;DR: Can one application programmatically monitor COM port status of an already opened COM port, and how?

I have a data communication from host HOST via ttyS0 (COM1) to another device CLIENT, so the port is definitely in use. CLIENT does not only send data on the port to HOST, but also sets a pin ("RI pin 9") from low to high, when CLIENT's batteries are low, so to notice HOST of that condition. HOST can then initiate a graceful shutdown.

How can any process like genpower (UPS monitoring tool) check the status of PINs, when serial ports can only be opened once and then are locked?

To provide additional info:

There is a powermonitoring daemon "genpowerd" that can shut down a machine when it sees a specified pin of a specified serial port go to high. As of Ubuntu 10 it seemed to be doing that, even though that serial port was also used as a data connection between two arbitrary end points (meaning the serial port is definitely in use). Googling a bit for serial ports it seems that older Unix versions had an additional file

/dev/cua0

in addition to /dev/ttyS0. My vendor claims because genpower is no longer part of Ubuntu, I cannot use UPS sensing anymore. I am wondering if that is because /dev/cau* went away? Could that have been used to accomplish what I want? I am quite positive that strace was not involved. The genpowerd utility simply opens the serial port with a simple

fd = open(port, O_RDWR | O_NDELAY))

and then goes on performing ioctl(...) calls on it.

  • Maybe this is a hint. – user86969 May 28 '15 at 12:29
  • I wonder if that is the only way. That would mean that a generic daemon would need to attach itself to any program that opens a serial port. – Tom May 28 '15 at 13:47
  • There are certainly many ways to achieve that but then I cannot see one at the moment. Hard to tell without the program. – user86969 May 28 '15 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.