#!/usr/bin/perl -w
# Routines to pull data from the Gas meter.
# 2/15 jj v0.0.1
#
use strict;
use warnings;
use JSON;
use Data::Dumper;
use Log::Log4perl qw(:easy);
# Initialize Logger
my $log_conf = q(
log4perl.rootLogger = DEBUG, LOG1
log4perl.appender.LOG1 = Log::Log4perl::Appender::File
log4perl.appender.LOG1.filename = /home/jj/Documents/log/Meterlog.log
log4perl.appender.LOG1.mode = append
log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.LOG1.layout.ConversionPattern = %d %p %m %n
);
Log::Log4perl::init(\$log_conf);
my $logger = Log::Log4perl->get_logger();
# sample logging statement
$logger->info("this is an info log message");
my @array;
my $i=0;
my $Radio_string ="";
# Need to launch RTLAMR and read the strings coming out.
# Can pre-filter to just MY meter on the commandline with:
# cd ~/go/bin
# ./rtlamr -msgtype=scm+ --format=json -filterid=101419821, 101419999 -unique=false
# Launch the radio
system("/home/jj/go/bin/rtlamr -msgtype=scm+ --format=json -filterid=101419821,101419999 -unique=false");
# slurp the headers
do {
$Radio_string = $_;
Print $i;
Print $Radio_string;
$i++;
} until $i == 10;
Print("\n-------End of headers.--------\n\n");
# now wait for and process usage reports
#@array = json(system("/home/jj/go/bin/rtlamr -msgtype=scm+ --format=json -filterid=101419821,101419999 -unique=false"));
$Radio_string = $_;
Print $Radio_string;
@array = json($Radio_string);
Dump(@array);