use Device::SerialPort; my $port = new Device::SerialPort("/dev/ttyACM0"); $port->user_msg('ON'); $port->baudrate(9600); $port->parity("none"); $port->databits(8); $port->stopbits(1); $port->handshake("xoff"); $port->write_settings; $port->lookclear; my $is_writting = 0; my $i = 0; while (1) { my ($count, $saw) = $port->read(1); $i++; if ($count < 1) { if ($is_writting) { print "\n"; $is_writting = 0; $i = 0; } next; } print $saw; $is_writting = 1; }