#!/usr/bin/perl
use warnings;
use strict;
use Device::SerialPort;
use Data::Dump qw(dump);

$|=1;

my $s = new Device::SerialPort( '/dev/ttyUSB0' ) || die $!;
$s->baudrate(2400);
$s->databits(8);
$s->parity('none');
$s->stopbits(1);
$s->handshake('none');
$s->read_char_time(2);
$s->read_const_time(3);

#$s->write('o');

while (1) {
	my ($len, $string) = $s->read(255);

	if ( $len > 0 ) {
		my $hex = unpack('H*',$string);
		$hex =~ s/(..)/$1 /g;
		print time(), " $len $hex\n";
	}
}

$s->close;
