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
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.