4 use Device::SerialPort;
5 use Data::Dump qw(dump);
6 use Time::HiRes qw(time);
10 my $path = shift @ARGV || '/dev/serial/by-path/platform-20980000.usb-usb-0:1.3.1:1.0-port0';
14 my $s = new Device::SerialPort( $path ) || die $!;
19 $s->handshake('none');
20 $s->read_char_time(2);
21 $s->read_const_time(3);
31 my $cmd = "mosquitto_pub -h rpi2 -t 'stat/rpi/$t' -m '$m'";
32 #warn "# _mqtt_pub [$t] = [$m]\n";
38 my ($len, $string) = $s->read($read_len);
42 my $hex = unpack('H*',$string);
45 my $temp = `curl localhost:3000/temp.txt`;
48 #printf "%s %2d %s\n", time(), $len, $hex;
49 printf "%8.4f %6.2f %2d %s | %s\n", $ts, $ts - $t, $len, $hex, $temp;
52 if ( $hex =~ m/^.+aa fc 39 aa (.+)/ ) {
53 my @l = split(/\s+/,$1);
59 hex( $l[14] ), # * 300,
60 hex( $l[15] ), # * 400,
64 _mqtt_pub "stat/boiler/" . chr(ord('a') + $_) => $d[$_] foreach 0 .. $#d;