use strict;
use Device::SerialPort;
use Data::Dump qw(dump);
+use Time::HiRes qw(time);
+
+my $read_len = 255;
+
+my $path = shift @ARGV || '/dev/serial/by-path/platform-20980000.usb-usb-0:1.3.1:1.0-port0';
$|=1;
-my $s = new Device::SerialPort( '/dev/ttyUSB0' ) || die $!;
+my $s = new Device::SerialPort( $path ) || die $!;
$s->baudrate(2400);
-$s->databits(8);
+$s->databits(8); # 7
$s->parity('none');
$s->stopbits(1);
$s->handshake('none');
#$s->write('o');
+my $t = time();
+
+my $sym;
+my $chr = 'A';
+
while (1) {
- my ($len, $string) = $s->read(255);
+ my ($len, $string) = $s->read($read_len);
+ my $ts = time();
if ( $len > 0 ) {
my $hex = unpack('H*',$string);
$hex =~ s/(..)/$1 /g;
- printf "%s %2d %s\n", time(), $len, $hex;
+=for later
+ my $ascii;
+ foreach ( split(/ /, $hex) ) {
+ if ( ! exists $sym->{$_} ) {
+ $chr++;
+ $ascii
+=cut
+
+ my $temp = `curl localhost:3000/temp.txt`;
+ $temp =~ s/\s+/ /gs;
+
+ #printf "%s %2d %s\n", time(), $len, $hex;
+ printf "%8.4f %6.2f %2d %s | %s\n", $ts, $ts - $t, $len, $hex, $temp;
+ $t = time();
}
}