#!/usr/bin/perl -w use POSIX; $fd = POSIX::open('/dev/ttyS1', O_RDWR | O_NOCTTY) or die "$! in open"; $termios = POSIX::Termios->new; $termios->getattr($fd) or die "$! in getattr"; print $termios->getispeed, " ", $termios->getospeed, " ", POSIX::B9600, " ", POSIX::B38400, "\n"; $termios->setispeed(POSIX::B38400); $termios->setospeed(POSIX::B38400); $termios->setattr($fd,&POSIX::TCSANOW); for (;;) { for ($i = 0; $i < 256; $i++) { $buff = chr($i); POSIX::write($fd, $buff, 1) or die "$! in write"; select undef, undef, undef, 0.1; }; for ($i = 255; $i >= 0; $i--) { $buff = chr($i); POSIX::write($fd, $buff, 1) or die "$! in write"; select undef, undef, undef, 0.01 }; }; POSIX::close($fd);