Serial line I/O, Elcomat, POSIX::Termios

 
#!/usr/bin/perl -w
use strict;
use POSIX qw(:termios_h);
my ($typ, $status, $messwert_x, $messwert_y);
my $str= " " x 100;
my $buffer= " " x 100;

my $fd = POSIX::open( "/dev/cua0", &POSIX::O_RDWR) || die "open returns error";
my $term = POSIX::Termios->new; 
$term->getattr( $fd);
$term->setospeed( &POSIX::B19200); 
$term->setispeed( &POSIX::B19200); 
$term->setattr( $fd, &POSIX::TCSANOW);

foreach my $i ( 1 .. 10)
{
    POSIX::write( $fd, "a\015", 2);
    $str = "";
    while( $str !~ /.+\015$/)
    {
	POSIX::read( $fd, $buffer, 100);
	$str = $str . $buffer; 
    }
    chomp $str;
    ($typ, $status, $messwert_x, $messwert_y) = split ' ', $str;
    print "$messwert_x, $messwert_y \n";
}
POSIX::close( $fd);