Leser: 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
sub SerRead { $ser_dev = "/dev/ttyS3"; $AckOk = "\x06"; $AckErr = "\x15"; sysopen ( SerialRead, "$ser_dev", O_RD | O_NONBLOCK ) || die "cannot sysopen"; $len=""; while (length($len) == 0){ $len = sysread(SerialRead, $buf, 1 ); } if ($buf == $AckOk) { print "ACK_OK\n"; } if ($buf == $AckErr) { print "ACK_ERR\n"; } close SerialRead; }
1 2 3 4 5 6 7 8 9
$mo = POSIX::Termios->new; $mo->setiflag(0 | IXON | IXOFF); $mo->setoflag(0); $mo->setlflag(0); $mo->setcc(VMIN, 3); # N3; = 3 Zeichen $mo->setcc(VTIME, 0); $mo->setcflag(CREAD | CS8 | B9600); $mo->setattr(fileno(Serial), TCSANOW);