first chat with boiler
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 11 Dec 2014 18:45:25 +0000 (19:45 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 11 Dec 2014 18:45:25 +0000 (19:45 +0100)
dialog.pl [new file with mode: 0755]

diff --git a/dialog.pl b/dialog.pl
new file mode 100755 (executable)
index 0000000..8f50b5e
--- /dev/null
+++ b/dialog.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Data::Dump qw(dump);
+use Device::SerialPort qw(:STAT);
+
+my $port = Device::SerialPort->new('/dev/ttyUSB0');
+$port->baudrate(9600);
+$port->databits(8);
+$port->parity('none');
+$port->stopbits(1);
+$port->handshake('none');
+
+# disable timeouts
+$port->read_char_time(500);
+$port->read_const_time(1000);
+
+sub v {
+       my ($hex,$desc) = @_;
+       my $bytes;
+       $bytes .= pack('C', hex('0x' . $_)) foreach split(/\s+/,$hex);
+       warn "# $desc\n";
+       warn ">> $hex ",dump( $bytes );
+       $port->write( $bytes );
+
+       my $len = $port->read(1);
+       warn "<< len: ",ord($len);
+       my $data = $port->read(ord($len) - 1);
+       warn "<< ",dump($data);
+
+}
+
+v '07 02 00 00 00 04 C4', "hardware version";
+