Chaps,
Apols for the delay, been busy. Anyhow, here's the code I use at home for the Galaxy reading.
I'm not much of a coder TBH, and in anycase there is quite a lot of other stuff going on in here, as I call some web services and other stuff, hopefully though it's of use. To be honest, if you can't follow what's going on here, then frankly you've got no chance of getting this to work!! Lols...!
Good luck, feel free to use the code however you like. It works a treat, in fact this code has been running on a RasPi for over 3 years, without so much as a reboot!
Basics are that the data is encoded (not encrypted) the first section of code pulls that apart, from then its just RIO ids and zone numbers accompanied by the zone resistance in HEX.
Cheers
Dan
[email protected] ~ $ cat galaxy.perl
#!/usr/bin/perl
# Note this adaptor is for Galaxy GD-96
# Client Program
use Device::SerialPort 0.12 ;
#Set up serial port
$ob = Device::SerialPort->new ("/dev/ttyAMA0") || die "Can't Open $PORT: $!";
$ob->baudrate(9600) || die "failed setting baudrate";
$ob->parity("none") || die "failed setting parity";
$ob->databits(8) || die "failed setting databits";
$ob->stopbits(1) || die "failed setting stopbits";
$count=100 ;
system( "logger 'HAL - galaxy.perl rebooted' ");
while (1) {
$dan=$ob->read(1);
select(undef, undef, undef, 0.001); #sleep 250 mS
$req = unpack ("H*" , $dan );
$req =~ s/[^\w]//g ;
$req =~ s/' '//g ;
chomp($req);
if ( $req ne "") {
if ($req eq "11") {
$match = 1 ;
$val1 = $req ;
}
if (( $match == 1 ) && ( $req eq "fe" )) {
$match = 2 ;
$val2 = $req ;
}
if (( $match == 2 ) && ( $req eq "ba" )) {
$match = 3 ;
$val3 = $req ;
}
if (($req != "11") && ($req != "fe") && ($req != "ba")) {
$match = "0" ;
}
if ( $match == 3 ) {
$count = 0 ;
$match = 0 ;
@dan=() ;
push (
@Dan , $val1 ) ;
push (
@Dan , $val2 ) ;
}
if ( $count < 25 ) {
push (
@Dan, $req ) ;
}
if ( $count == 25 ) {
$epoch = time();
# print "
@Dan \n";
if (($dan[3] eq "02") && ($dan[7] eq "f1")) {
# print " $dan[3] ==
@Dan \n";
$out_21 = $dan[8] . $dan[9] ;
$out_22 = $dan[10] . $dan[11] ;
$out_23 = $dan[12] . $dan[13] ;
$out_24 = $dan[14] . $dan[15] ;
$out_25 = $dan[16] . $dan[17] ;
$out_26 = $dan[18] . $dan[19] ;
$out_27 = $dan[20] . $dan[21] ;
$out_28 = $dan[22] . $dan[23] ;
if (( $out_21 =~ /^07/ ) && ( $out_21_stat ne "O" )) {
open($fh, '>', 'out_21.txt'); print $fh "O $epoch \n" ; close $fh;
$out_21_stat = "O" ;
`curl -d "varname=out_21&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 21 activated - PlantRmPIR' ");
}
if (( $out_21 !~ /^07/ ) && ( $out_21_stat ne "C" )) {
open($fh, '>', 'out_21.txt'); print $fh "C $epoch \n" ; close $fh;
$out_21_stat = "C" ;
`curl -d "varname=out_21&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_22 =~ /^07/ ) && ( $out_22_stat ne "O" )) {
open($fh, '>', 'out_22.txt'); print $fh "O $epoch \n" ; close $fh;
$out_22_stat = "O" ;
`curl -d "varname=out_22&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 22 activated - PlantRmSmoke' ");
}
if (( $out_22 !~ /^07/ ) && ( $out_22_stat ne "C" )) {
open($fh, '>', 'out_22.txt'); print $fh "C $epoch \n" ; close $fh;
$out_22_stat = "C" ;
`curl -d "varname=out_22&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_23 =~ /^07/ ) && ( $out_23_stat ne "O" )) {
open($fh, '>', 'out_23.txt'); print $fh "O $epoch \n" ; close $fh;
$out_23_stat = "O" ;
`curl -d "varname=out_23&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 23 activated - CellarRearDoor' ");
}
if (( $out_23 !~ /^07/ ) && ( $out_23_stat ne "C" )) {
open($fh, '>', 'out_23.txt'); print $fh "C $epoch \n" ; close $fh;
$out_23_stat = "C" ;
`curl -d "varname=out_23&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_24 =~ /^07/ ) && ( $out_24_stat ne "O" )) {
open($fh, '>', 'out_24.txt'); print $fh "O $epoch \n" ; close $fh;
$out_24_stat = "O" ;
`curl -d "varname=out_24&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 24 activated - CellarPassagePIR' ");
}
if (( $out_24 !~ /^07/ ) && ( $out_24_stat ne "C" )) {
open($fh, '>', 'out_24.txt'); print $fh "C $epoch \n" ; close $fh;
$out_24_stat = "C" ;
`curl -d "varname=out_24&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_25 =~ /^07/ ) && ( $out_25_stat ne "O" )) {
open($fh, '>', 'out_25.txt'); print $fh "O $epoch \n" ; close $fh;
$out_25_stat = "O" ;
`curl -d "varname=out_25&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 25 activated - BackLoungeSmoke' ");
}
if (( $out_25 !~ /^07/ ) && ( $out_25_stat ne "C" )) {
open($fh, '>', 'out_25.txt'); print $fh "C $epoch \n" ; close $fh;
$out_25_stat = "C" ;
`curl -d "varname=out_25&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_26 =~ /^07/ ) && ( $out_26_stat ne "O" )) {
open($fh, '>', 'out_26.txt'); print $fh "O $epoch \n" ; close $fh;
$out_26_stat = "O" ;
`curl -d "varname=out_26&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 26 activated - FrontDoor' ");
}
if (( $out_26 !~ /^07/ ) && ( $out_26_stat ne "C" )) {
open($fh, '>', 'out_26.txt'); print $fh "C $epoch \n" ; close $fh;
$out_26_stat = "C" ;
`curl -d "varname=out_26&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_27 =~ /^07/ ) && ( $out_27_stat ne "O" )) {
open($fh, '>', 'out_27.txt'); print $fh "O $epoch \n" ; close $fh;
$out_27_stat = "O" ;
`curl -d "varname=out_27&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 27 activated - FrontLoungePIR' ");
}
if (( $out_27 !~ /^07/ ) && ( $out_27_stat ne "C" )) {
open($fh, '>', 'out_27.txt'); print $fh "C $epoch \n" ; close $fh;
$out_27_stat = "C" ;
`curl -d "varname=out_27&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
if (( $out_28 =~ /^07/ ) && ( $out_28_stat ne "O" )) {
open($fh, '>', 'out_28.txt'); print $fh "O $epoch \n" ; close $fh;
$out_28_stat = "O" ;
`curl -d "varname=out_28&value=O|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
system( "logger 'HAL - Galaxy Zone 28 activated - Spare' ");
}
if (( $out_28 !~ /^07/ ) && ( $out_28_stat ne "C" )) {
open($fh, '>', 'out_28.txt'); print $fh "C $epoch \n" ; close $fh;
$out_28_stat = "C" ;
`curl -d "varname=out_28&value=C|$epoch&action=Send"
http://192.168.100.100/varstore.php` ;
}
}
@dan=() ;
}
$count = $count + 1 ;
}
}