$hsh{'Barometric_Trend'} = unpack("C", substr $blk,3,1);
$hsh{'Barometric_Trend_txt'} = $bar_trend{$hsh{'Barometric_Trend'}};
$hsh{'Barometric_Trend'} = unpack("C", substr $blk,3,1);
$hsh{'Barometric_Trend_txt'} = $bar_trend{$hsh{'Barometric_Trend'}};
- $t = unpack("s", substr $blk,7,2) / 1000;
- # $hsh{'Barometric_Press_hg'} = $t;
- $hsh{'Barometric_Press_mb'} = sprintf("%.2f",$t*33.8637526);
-
+ $t = unpack("s", substr $blk,7,2) / 1000;
+# $hsh{'Barometric_Press_hg'} = $t;
+ $hsh{'Barometric_Press_mb'} = sprintf("%.2f",$t*33.8637526);
+
- my $tf = unpack("s", substr $blk,12,2) / 10;
- # $hsh{'Air_Temp_Outside_f'} = $tf;
+ my $tf = unpack("s", substr $blk,12,2) / 10;
+# $hsh{'Air_Temp_Outside_f'} = $tf;
-
- $hsh{'Wind_Speed_mph'} = unpack("C", substr $blk,14,1);
- # $hsh{'Wind_Speed_mps'} = sprintf("%.1f",$hsh{'Wind_Speed_mph'}*0.44704);
+
+ $hsh{'Wind_Speed_mph'} = unpack("C", substr $blk,14,1);
+# $hsh{'Wind_Speed_mps'} = sprintf("%.1f",$hsh{'Wind_Speed_mph'}*0.44704);
$hsh{'Humidity_Outside'} = unpack("C", substr $blk,33,1);
$hsh{'Humidity_Inside'} = unpack("C", substr $blk,11,1);
$hsh{'Dew_Point'} = dew_point($tf, $hsh{'Humidity_Outside'});
$hsh{'Humidity_Outside'} = unpack("C", substr $blk,33,1);
$hsh{'Humidity_Inside'} = unpack("C", substr $blk,11,1);
$hsh{'Dew_Point'} = dew_point($tf, $hsh{'Humidity_Outside'});
-
- # $hsh{'UV'} = unpack("C", substr $blk,43,1);
- # $hsh{'Solar'} = unpack("s", substr $blk,44,2); # watt/m**2
-
+
+# $hsh{'UV'} = unpack("C", substr $blk,43,1);
+# $hsh{'Solar'} = unpack("s", substr $blk,44,2); # watt/m**2
+
$hsh{'Rain_Rate'} = (unpack("s", substr $blk,41,2) / 100) * 25.4; # Inches per hr converted to mm
$hsh{'Rain_Storm'} = (unpack("s", substr $blk,46,2) / 100) * 25.4; # Inches per storm
#$hsh{'Storm_Date'} = unpack("s", substr $blk,48,2); # Need to parse data (not sure what this is)
$hsh{'Rain_Rate'} = (unpack("s", substr $blk,41,2) / 100) * 25.4; # Inches per hr converted to mm
$hsh{'Rain_Storm'} = (unpack("s", substr $blk,46,2) / 100) * 25.4; # Inches per storm
#$hsh{'Storm_Date'} = unpack("s", substr $blk,48,2); # Need to parse data (not sure what this is)
- $hsh{'Rain_Day'} = (unpack("s", substr $blk,50,2)/100) * 25.4;
- $hsh{'Rain_Month'} = (unpack("s", substr $blk,52,2)/100) * 25.4;
- $hsh{'Rain_Year'} = (unpack("s", substr $blk,54,2)/100) * 25.4;
-
- $hsh{'ET_Day'} = unpack("s", substr $blk,56,2)/1000;
- $hsh{'ET_Month'} = unpack("s", substr $blk,58,2)/100;
- $hsh{'ET_Year'} = unpack("s", substr $blk,60,2)/100;
-
- #$hsh{'Alarms_Inside'} = unpack("b8", substr $blk,70,1);
- #$hsh{'Alarms_Rain'} = unpack("b8", substr $blk,70,1);
- #$hsh{'Alarms_Outside'} = unpack("b8", substr $blk,70,1);
-
+ $hsh{'Rain_Day'} = (unpack("s", substr $blk,50,2)/100) * 25.4;
+ $hsh{'Rain_Month'} = (unpack("s", substr $blk,52,2)/100) * 25.4;
+ $hsh{'Rain_Year'} = (unpack("s", substr $blk,54,2)/100) * 25.4;
+
+ $hsh{'ET_Day'} = unpack("s", substr $blk,56,2)/1000;
+ $hsh{'ET_Month'} = unpack("s", substr $blk,58,2)/100;
+ $hsh{'ET_Year'} = unpack("s", substr $blk,60,2)/100;
+
+ #$hsh{'Alarms_Inside'} = unpack("b8", substr $blk,70,1);
+ #$hsh{'Alarms_Rain'} = unpack("b8", substr $blk,70,1);
+ #$hsh{'Alarms_Outside'} = unpack("b8", substr $blk,70,1);
+
- $hsh{'Batt_Console'} = unpack("s", substr $blk,87,2) * 0.005859375;
-
- $hsh{'Forecast_Icon'} = unpack("C", substr $blk,89,1);
- $hsh{'Forecast_Rule'} = unpack("C", substr $blk,90,1);
-
- $hsh{'Sunrise'} = sprintf( "%04d", unpack("S", substr $blk,91,2) );
- $hsh{'Sunrise'} =~ s/(\d{2})(\d{2})/$1:$2/;
- $hsh{'Sunset'} = sprintf( "%04d", unpack("S", substr $blk,93,2) );
+ $hsh{'Batt_Console'} = unpack("s", substr $blk,87,2) * 0.005859375;
+
+ $hsh{'Forecast_Icon'} = unpack("C", substr $blk,89,1);
+ $hsh{'Forecast_Rule'} = unpack("C", substr $blk,90,1);
+
+ $hsh{'Sunrise'} = sprintf( "%04d", unpack("S", substr $blk,91,2) );
+ $hsh{'Sunrise'} =~ s/(\d{2})(\d{2})/$1:$2/;
+ $hsh{'Sunset'} = sprintf( "%04d", unpack("S", substr $blk,93,2) );
- #my $nl = ord substr $blk,95,1;
- #my $cr = ord substr $blk,96,1;
-
- my $crc = unpack "%n", substr($blk,97,2);
- my $crc_calc = CRC_CCITT($blk);
-
+ my $crc = unpack "%n", substr($blk,97,2);
+ my $crc_calc = CRC_CCITT($blk);
+
#delete($hsh{crc})||die"cant delete crc";
#delete($hsh{crc_calc})||die"cant delete crc_calc";
#delete($hsh{next_rec})||die"cant delete next_rec";
#delete($hsh{crc})||die"cant delete crc";
#delete($hsh{crc_calc})||die"cant delete crc_calc";
#delete($hsh{next_rec})||die"cant delete next_rec";
my $crc_prev = $crc;
my $index = $crc >> 8 ^ $data;
my $lhs = $crc_table[$index];
#print "lhs=$lhs, crc=$crc\n";
my $rhs = ($crc << 8) & 0xFFFF;
$crc = $lhs ^ $rhs;
my $crc_prev = $crc;
my $index = $crc >> 8 ^ $data;
my $lhs = $crc_table[$index];
#print "lhs=$lhs, crc=$crc\n";
my $rhs = ($crc << 8) & 0xFFFF;
$crc = $lhs ^ $rhs;
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0xed1, 0x1ef0
);
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0xed1, 0x1ef0
);
$bar_trend{236} = "Falling Slowly";
$bar_trend{0} = "Steady";
$bar_trend{20} = "Rising Slowly";
$bar_trend{236} = "Falling Slowly";
$bar_trend{0} = "Steady";
$bar_trend{20} = "Rising Slowly";
my $ck = CRC_CCITT(substr($str,1,9));
if ( $ck ) {
warn "checksum error"; return 0;
}
my @rsp_lst = split //, $str;
my $ck = CRC_CCITT(substr($str,1,9));
if ( $ck ) {
warn "checksum error"; return 0;
}
my @rsp_lst = split //, $str;
if ( $ack != 6 ) {
warn "SETTIME not set ack $ack !"; return 0;
}
my ($sec, $min, $hour, $day, $mon, $yr) = @{$s_time};
if ( $ack != 6 ) {
warn "SETTIME not set ack $ack !"; return 0;
}
my ($sec, $min, $hour, $day, $mon, $yr) = @{$s_time};
- $str = join "", map chr, ($sec, $min, $hour, $day, $mon, $yr);
+ $str = join "", map chr, ($sec, $min, $hour, $day, $mon, $yr);
- }
-
- #my $port_obj = $self->{'port_obj'};
-
- my $datetime = pack("ss",$vDateStamp, $vTimeStamp);
-
+ }
+
+ #my $port_obj = $self->{'port_obj'};
+
+ my $datetime = pack("ss",$vDateStamp, $vTimeStamp);
+
- #-----------------------
- #my $str = unpack("H*", $cmd);
- #$str =~ s/(\w{2})/$1 /g;
+ #-----------------------
+ #my $str = unpack("H*", $cmd);
+ #$str =~ s/(\w{2})/$1 /g;
- ($cnt_in, $str) = $ob->read(7);
-
- $ack = ord substr($str,0,1);
-
- my $ls = unpack("H20",substr($str,1,4) );
- $ls =~ s/(\w{2})/$1 /g;
-
- my $pages = unpack("s",substr($str,1,2) );
- my $rec_start = unpack("s",substr($str,3,2) );
-
+ ($cnt_in, $str) = $ob->read(7);
+
+ $ack = ord substr($str,0,1);
+
+ my $ls = unpack("H20",substr($str,1,4) );
+ $ls =~ s/(\w{2})/$1 /g;
+
+ my $pages = unpack("s",substr($str,1,2) );
+ my $rec_start = unpack("s",substr($str,3,2) );
+
$ob->read_interval(0);
my ($cnt_in, $str) = $ob->read($page_sz); #,3
printf("len=%s\n",length($str));
if ($cnt_in!=$page_sz) {
dienice("hmm, dmpaft only got $cnt_in bytes. was expecting $page_sz");
}
$ob->read_interval(0);
my ($cnt_in, $str) = $ob->read($page_sz); #,3
printf("len=%s\n",length($str));
if ($cnt_in!=$page_sz) {
dienice("hmm, dmpaft only got $cnt_in bytes. was expecting $page_sz");
}
my $crc = unpack "%n", substr($str,265,2);
print "page crc=$crc, calc_crc=$calc_crc\n";
my $rec_sz = 52;
my $crc = unpack "%n", substr($str,265,2);
print "page crc=$crc, calc_crc=$calc_crc\n";
my $rec_sz = 52;
-
- #print "$start_ptr \t > " . unpack( "h*", $rec_str) . "\n";
-
- my $date = substr($rec_str,0,2);
+
+ #print "$start_ptr \t > " . unpack( "h*", $rec_str) . "\n";
+
+ my $date = substr($rec_str,0,2);
- }
- $date_prev = $date_curr;
-
- $hsh{'date_stamp'} = $date_curr;
- $hsh{'time_stamp'} = unpack "s", substr($rec_str,2,2);
-
- $hsh{'day'} = unpack( "c", $date & pack("c",0x1F) );
- $hsh{'month'} = ( $hsh{'date_stamp'} >> 5) & 0xF;
- $hsh{'year'} = ( $hsh{'date_stamp'} >> 9) + 2000;
-
- $hsh{'hour'} = sprintf("%02d", int ( $hsh{'time_stamp'} / 100 ));
-
- $hsh{'min'} = $hsh{'time_stamp'} - ($hsh{'hour'} * 100);
- $hsh{'min'} = sprintf("%02d", $hsh{'min'});
-
- $hsh{'time_stamp_fmt'} = "$hsh{'hour'}:$hsh{'min'}:00";
- $hsh{'date_stamp_fmt'} = "$hsh{'year'}_$hsh{'month'}_$hsh{'day'}";
+ }
+ $date_prev = $date_curr;
+
+ $hsh{'date_stamp'} = $date_curr;
+ $hsh{'time_stamp'} = unpack "s", substr($rec_str,2,2);
+
+ $hsh{'day'} = unpack( "c", $date & pack("c",0x1F) );
+ $hsh{'month'} = ( $hsh{'date_stamp'} >> 5) & 0xF;
+ $hsh{'year'} = ( $hsh{'date_stamp'} >> 9) + 2000;
+
+ $hsh{'hour'} = sprintf("%02d", int ( $hsh{'time_stamp'} / 100 ));
+
+ $hsh{'min'} = $hsh{'time_stamp'} - ($hsh{'hour'} * 100);
+ $hsh{'min'} = sprintf("%02d", $hsh{'min'});
+
+ $hsh{'time_stamp_fmt'} = "$hsh{'hour'}:$hsh{'min'}:00";
+ $hsh{'date_stamp_fmt'} = "$hsh{'year'}_$hsh{'month'}_$hsh{'day'}";
#$hsh{'unixtime'} = timelocal(0,$hsh{min}, $hsh{hour}, $hsh{day}, $hsh{month}-1, $hsh{year}-1900);
#$hsh{'unixtime'} = timelocal(0,$hsh{min}, $hsh{hour}, $hsh{day}, $hsh{month}-1, $hsh{year}-1900);
-
- $hsh{'Air_Temp'} = unpack("s", substr($rec_str,4,2)) / 10;
- $hsh{'Air_Temp_Hi'} = unpack("s", substr($rec_str,6,2)) / 10;
+
+ $hsh{'Air_Temp'} = unpack("s", substr($rec_str,4,2)) / 10;
+ $hsh{'Air_Temp_Hi'} = unpack("s", substr($rec_str,6,2)) / 10;
$hsh{'Air_Temp_Lo'} = unpack("s", substr($rec_str,8,2)) / 10;
$hsh{'Rain_Clicks'} = unpack("s", substr($rec_str,10,2));
$hsh{'Rain_Rate'} = unpack("s", substr($rec_str,12,2)) / 100; # Inches per hour
$hsh{'Air_Temp_Lo'} = unpack("s", substr($rec_str,8,2)) / 10;
$hsh{'Rain_Clicks'} = unpack("s", substr($rec_str,10,2));
$hsh{'Rain_Rate'} = unpack("s", substr($rec_str,12,2)) / 100; # Inches per hour
- $hsh{'Wind_Samples'} = unpack("s", substr $rec_str,18,2);
- $hsh{'Air_Temp_Inside'} = unpack("s", substr $rec_str,20,2) / 10;
+ $hsh{'Wind_Samples'} = unpack("s", substr $rec_str,18,2);
+ $hsh{'Air_Temp_Inside'} = unpack("s", substr $rec_str,20,2) / 10;
$hsh{'Relative_Humidity_Inside'} = unpack("C", substr $rec_str,22,1);
$hsh{'Relative_Humidity'} = unpack("C", substr $rec_str,23,1);
$hsh{'Relative_Humidity_Inside'} = unpack("C", substr $rec_str,22,1);
$hsh{'Relative_Humidity'} = unpack("C", substr $rec_str,23,1);
$hsh{'Wind_Gust_Max'} = unpack("C", substr($rec_str,25,1));
$hsh{'Wind_Dir_Max'} = unpack("C", substr($rec_str,26,1));
$hsh{'Wind_Dir'} = unpack("C", substr($rec_str,27,1));
$hsh{'Wind_Gust_Max'} = unpack("C", substr($rec_str,25,1));
$hsh{'Wind_Dir_Max'} = unpack("C", substr($rec_str,26,1));
$hsh{'Wind_Dir'} = unpack("C", substr($rec_str,27,1));
$hsh{'UV'} = unpack("C", substr($rec_str,28,1)) / 10;
$hsh{'ET'} = unpack("C", substr($rec_str,29,1)) / 1000;
$hsh{'UV'} = unpack("C", substr($rec_str,28,1)) / 10;
$hsh{'ET'} = unpack("C", substr($rec_str,29,1)) / 1000;
-
- print "date> $hsh{'Air_Temp'} $hsh{'time_stamp'} $hsh{'time_stamp_fmt'} $hsh{'date_stamp'} $hsh{'date_stamp_fmt'}\n";
- #print Dumper \%hsh;
-
- push @arc_rec_lst, {%hsh};
- }
-
+
+ print "date> $hsh{'Air_Temp'} $hsh{'time_stamp'} $hsh{'time_stamp_fmt'} $hsh{'date_stamp'} $hsh{'date_stamp_fmt'}\n";
+ #print Dumper \%hsh;
+
+ push @arc_rec_lst, {%hsh};
+ }
+
#$in = <STDIN>; # Testing step through facility
#if ($in =~ /q/i ) { $port_obj->write( pack("h", 0x1B) ); last; }
#else { $port_obj->write( pack("h", 0x06) ); }
print "ACK receipt of page\n";
$ob->write( pack("h", 0x06) );
#$in = <STDIN>; # Testing step through facility
#if ($in =~ /q/i ) { $port_obj->write( pack("h", 0x1B) ); last; }
#else { $port_obj->write( pack("h", 0x06) ); }
print "ACK receipt of page\n";
$ob->write( pack("h", 0x06) );