I'm trying to change the inbound and outbound port speeds of a serial port
using POSIX. I'm trying to write a small perl script to drive an LCD
display. The reason I open it as DisplayIO is because I need to print to
standard IO. At the moment all I'm trying to do is change the port speed but
I don't seem to be having much luck with this.
Below is the code I'm using. Can someone give me some suggestions:
#########################################################################
#! /usr/bin/perl -w
use strict;
use POSIX;
my $termios;
my $inspeed;
my $outspeed;
my $SerialFileName = '/dev/ttyS1' ; # com1 or ttyS0 (com2)
unless (open (DisplayIO, "+> $SerialFileName")) {
die "Sorry, I was unable to open the display\n";
}
$termios = POSIX::Termios->new;
$termios->getattr(1);
$outspeed = $termios->getoflag;
$inspeed = $termios->getiflag;
print "The current outbound port speed is $outspeed\n";
print "The current inbound port speed is $inspeed\n";
$termios->setospeed(&POSIX::B19200);
$termios->setispeed(&POSIX::B19200);
$termios->setattr(1, TCSANOW);
$outspeed = $termios->getoflag;
$inspeed = $termios->getiflag;
print "The new outbound port speed is $outspeed\n";
print "The new inbound port speed is $inspeed\n";
sleep 1;
while(){
# keep an infinite loop running until I control C out of it.
}
close (DisplayIO) ;
exit 0 ;
#######################################
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]