Perl and serial ports.
Simon McCartney
simon at asidua.com
Mon Jan 19 09:22:38 CST 2004
On Mon, Jan 19, 2004 at 03:05:18PM +0000, Stray Toaster wrote:
> Yo.
>
> Has anyone messed about with reading/writing to serial ports using perl?
>
> I haven't looked on CPAN yet, as I thought I would ask on the list.
> Makes a difference from Viagra mails, as useful as that might me.
The following isn't pretty or portable, but works fine for me:
(It's on linux, rh62 is think...2.2.19)
# setup the serial port, 1200 8N1
system("stty --file=/dev/ttyS0 ispeed 1200 ospeed 1200 cs8 -cstopb parenb -parodd");
# open up a fd to the serial port
open(SX2000, "/dev/ttyS0") || die "Can't open /dev/ttyS0\n";
while ($line = <SX2000>)
{
# a whole bunch of stuff for parsing phone logs..
}
close(SX2000);
-simonm (E: simon at asidua.com W: +44 28 9072 5060 M: +44 7710 836915)
One By One The Penguins Steal My Sanity
More information about the Belfast-pm
mailing list