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; }