TransWikia.com

Viewing (monitoring) line status of a serial port

Unix & Linux Asked by Anton Samsonov on February 4, 2021

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.

One Answer

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.

Answered by plonk on February 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP