5

Is there a utility software (or an easy method to do it from shell script) to display a serial port's status — i. e. blinking “RXD”, “TXD”, “DCD”, “DTR”, “DSR”, “RTS”, “CTS”? Particularly, I need to monitor whether “DCD” line is set most of the time and momentarily cleared on some interval. The port doesn't need to be sniffed, it's okay to open it exclusively.

In DOS and Windows world, it's usual for terminal emulator and other modem-related software to display pin status, either in GUI or in console applications. However, I couldn't find an alternative even for Linux (although some say it may be possible to examine /proc/tty/driver/serial by hand, if it exists), not to mention FreeBSD, which is my actual target. Common tools like cu and minicom only display port settings at most, not the status.

  • Not an answer, but e.g.,cat /proc/tty/driver/ttyAMA (exists, but unused) outputs serinfo:1.0 driver revision: 0: uart:PL011 rev3 mmio:0x20201000 irq:83 tx:65 rx:0 RTS|CTS|DTR. – goldilocks Dec 7 '14 at 14:33
  • 1
    @goldilocks FreeBSD, unlike Linux, only uses /proc to represent actual process information, and it's not even mounted by default. Likewise, FreeBSD doesn't provide /sys (this path is used for system sources instead). It's because sysctl should be used to access corresponding data, but I couldn't find any direct counterpart in it to that would exist in Linux in regard to my question. – Anton Samsonov Dec 7 '14 at 15:29
0

AFAIK you can read the DCD pin using ports. According to https://www.freebsd.org/doc/en/articles/serial-uart/, DCD lives in bit 7 of the Modem Status Register (port 0x06+PORT_ADDR). For your application, Bit 3, DDCD probably is better though. It's also possible to hook interrupts, take a look at the Modem Status Change interrupt.

| improve this answer | |
  • The question was about already existing software or shell snippet, well-written and tested. There is no doubt that the status may be programmatically read by a custom, manually written software. Currently, I am using Python with py-serial for this task, but still hope there is a better alternative (not to the Python, but to my very own self-invented wheel). – Anton Samsonov Jan 4 '15 at 15:50
  • @AntonSamsonov AFAIK there is no well-tested utility available, and a cursory find on the ports tree was inconclusive. In your question you also specified that you would also be looking for "an easy method to do it from shell script". While "easy" may be debatable, this is a viable method from a shell script. IO ports can be read via shell builtins from /dev/io. This could be implemented in several lines of pure shell. – plonk Jan 5 '15 at 18:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.