summaryrefslogtreecommitdiffstats
path: root/heating-cgi/boiler_rx
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2021-01-12 16:58:31 +0000
committerfishsoupisgood <github@madingley.org>2021-01-12 16:58:31 +0000
commit7c6887eaaf812b63bab6c5e134f80a2ef36aeb31 (patch)
tree4b4b0d371107ae1b8540ca1618cb9aa796b72616 /heating-cgi/boiler_rx
parentf4b573fe337a436d5e2b20be4be031d77376d609 (diff)
downloadheating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.gz
heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.bz2
heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.zip
works
Diffstat (limited to 'heating-cgi/boiler_rx')
-rwxr-xr-xheating-cgi/boiler_rx65
1 files changed, 65 insertions, 0 deletions
diff --git a/heating-cgi/boiler_rx b/heating-cgi/boiler_rx
new file mode 100755
index 0000000..777b3ee
--- /dev/null
+++ b/heating-cgi/boiler_rx
@@ -0,0 +1,65 @@
+#!/usr/bin/env perl
+
+use Net::Telnet;
+use IO::File;
+
+sub dump_file($$) {
+ my ( $name, $guts ) = @_;
+
+ my $fh = new IO::File ">" . $name;
+ return unless defined $fh;
+ $fh->print($guts);
+ $fh->close;
+ undef $fh;
+}
+
+my $timeout = 60;
+
+my $host = $ARGV[0];
+
+my $path = "/var/run/boiler_" . $host;
+
+mkdir( $path, 0755 );
+
+while (1) {
+ my $telnet = new Net::Telnet(
+ Timeout => 10,
+ Telnetmode => 0,
+ Binmode => 1,
+ Host => $host,
+ Port => 2001
+ );
+
+ #$telnet->open($bits[1]);
+
+ my $nodata = 0;
+
+ while ( ( not $telnet->eof ) and ( $nodata < $timeout ) ) {
+ my $line = $telnet->getline( Timeout => 1, Errmode => 'return' );
+
+ if ( not defined $line or ( length($line) == 0 ) ) {
+ $nodata++;
+ }
+ else {
+ $nodata = 0;
+ }
+
+ chomp $line;
+ chomp $line;
+
+ $line = uc($line);
+
+ next unless $line =~ /^([TB])(.)(.)(..)(....)/;
+
+ my $fn = $1 . $2 . "x" . $4;
+ my $c = $1 . $2 . $3 . $4 . $5;
+
+ dump_file( $path . "/" . $fn, $c );
+
+ }
+
+ $telnet->close;
+
+}
+
+exit(0);