I'm trying to find a way to record the status of a 14v hardware
discrete. The discrete signal will either be 14V or 0V. I've got a
USB to serial adapter, and I'm hoping to find a way to use that to
get the signal into my computer so perl can log the status of the
discrete.

Looking at various RS-232 specs on the web, it looks like there are
three lines that could legitimately be at either 14V of 0V, such as
Ring Indicator, Clear to Send or Data Set Ready.

Serial Port info: http://www.anotherurl.com/library/rs232.htm

I've set up a test where I can put 12V into a serial port line, but I
can't make perl see it. I've been trying to use the
Device::SerialPort module, as it seemed to have the capability I
needed. Is there another module that is better suited, or some basic
perl function, or system call I should be using instead?

My test script looks like:

#!/usr/bin/perl
#
# Test to see if Device::SerialPort can be used to monitor an event marker

use strict;
use warnings;

use Device::SerialPort qw( :STAT );
use Time::HiRes qw( time sleep );

my $duration = "10"; # run duration, in seconds
my $now_time = "0";

my $PortName = "/dev/tty.USA49W1b1P4.4";
my $EventMarker = new Device::SerialPort ( $PortName )
|| die "Can't open $PortName: $!n";

my $start_time = time;
while (time < ($start_time + $duration)) {
$now_time = time;
my $ModemStatus = $EventMarker->modemlines;
if ($ModemStatus & $EventMarker->MS_RING_ON) {
print "$now_timetevent marker detected *************n";
} else {
print "$now_timetnadan";
}
sleep 0.1;
}

exit;

=============
Note: I also tried it after having set the various serial port
parametres (baud, data bits, stop bits, etc), but that made no
difference to the result.

Test setup: 12V power supply, with the ground hooked to pin 5 of the
serial port's 9 pin connector, and 12V hooked to pin 9, via a
momentary switch. A voltmeter verifies 12V between pins 9 and 5 when
the switch is depressed. The same test was also done looking for
DCD, using pin 1, and having perl look for $EventMarker->MS_RLSD_ON.

Thanks in advance for any advice,

Kevin Horton