[mdlug] Serial port monitoring
Drew
drew4096 at gmail.com
Fri Feb 1 15:59:56 EST 2008
At 10:24 PM 1/31/08, Robert Meier wrote:
>The underlying hardware, if access is supported,
>should be available via ioctl(2).
>Start by looking at tty_ioctl(4), including TIOCM_CD.
>It is probable you will have to load some additional
>CONFIG_SERIAL_8250 kernel modules.
>It is possible you will have to recompile your kernel,
>as IIRC tty_ioctl support is no longer standard.
>
>To interpret much of the above man pages you will need to download and
>understand the spec sheet for the 8251 Universal Asynchronous Receiver
>Transmitter that is the canonical hardware implementation of RS-232.
I'm looking at the man page for tty_ioctl(4), from which it
looks like I need
to write a C program or something which can #include and call the function,
executing "ioctl(fd, TIOCMGET, &modeminfo);" then "modeminfo &= TIOCM_CAR;"
Most of the info that I need (eg, values for TIOCMGET and TIOCM_CAR)
should be in the header files, and I could theoretically write the
program without
ever knowing what these constants are.
Finding a value for fd (the serial port handle) is a bit more
problematic: For
all TRUE returns, it is anticipated (in fact part of the definition
of a valid TRUE
return) that the serial port will be in use, grabbed by VMware. I found that
PalmOS allows multiple programs to open the (same) serial port; but
I'm not sure
about whether Linux does.
> >> * If there is no actual modem, but just a straight serial connection
> >> using pins 2, 3, and ground, can reading Carrier Detect in that
> >> manner be relied upon to return an OFF status?
>
>No.
Then I need to find some other way to determine whether the serial
port is connected *and* refrain from using it from VMs for any serial work
(eg, Palm apps)...
>If your goal is security,
>then you might consider wiring the carrier detect line to a parallel
>port pin to monitor it.
I might look into the parallel pin method a bit more anyway, but my goal
doesn't have anything to do with security.
What I'm after is something that will automatically keep count of how many
minutes I've been connected to Netzero dialup during the month, without my
having to remember to do anything special before starting it up. I only get 10
hours a month, and they don't seem willing to provide a way to determine how
much time is left.
I always do this from a Windows 98 virtual machine, as this makes it easy
to reset the system to a known good state every few uses; and I have minicom
on the host for direct dialing. So I figured that actual modem
traffic (as opposed
to serial I/O without a modem) && the serial port in use by a virtual machine
would be a good indicator of whether to increment the minutes-in-the-month
counter (to be kept in/written to a file somewhere).
A second serial port would get around some of the problems; I could then
dedicate /dev/ttyS0 to the modem and use the other port(s) for Palm and other
serial work, instead of unplugging and replugging cables all the time. However,
the only serial boards I have (or even heard of) are ISA, and I only have PCI
slots (and only three of those). There is provision for a second serial port on
the motherboard, but as a Winmodem, and I think there is physical interference
with use of one of the PCI slots.
Any suggestions or ideas?
----
- Drew.
More information about the mdlug
mailing list