HiredGunTech has asked for the wisdom of the Perl Monks concerning the following question:
10:33:46.213965 decode.go:45: CenterFreq: 912600155 10:33:46.215377 decode.go:46: SampleRate: 2359296 10:33:46.215528 decode.go:47: DataRate: 32768 10:33:46.215651 decode.go:48: ChipLength: 72 10:33:46.215780 decode.go:49: PreambleSymbols: 16 10:33:46.215903 decode.go:50: PreambleLength: 2304 10:33:46.216021 decode.go:51: PacketSymbols: 128 10:33:46.216137 decode.go:52: PacketLength: 18432 10:33:46.216263 decode.go:59: Protocols: scm+ 10:33:46.216404 decode.go:60: Preambles: 0001011010100011 10:33:46.216529 main.go:126: GainCount: 29 {"Time":"2022-02-26T10:35:55.66825429-05:00","Offset":0,"Length":0,"Ty +pe":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType" +:188,"EndpointID":101419821,"Consumption":305782,"Tamper":2056,"Packe +tCRC":26848}} {"Time":"2022-02-26T10:36:10.667844535-05:00","Offset":0,"Length":0,"T +ype":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType +":188,"EndpointID":101419821,"Consumption":305782,"Tamper":2056,"Pack +etCRC":26848}} ...
<br><br> #!/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::PatternLa +yout 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=1 +01419821,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=j +son -filterid=101419821,101419999 -unique=false")); $Radio_string = $_; Print $Radio_string; @array = json($Radio_string); Dump(@array);
print "spawned:\n"; chdir ("/home/jj/go/bin/") ; if ( -e "rtlamr" ) {print "Found rtlamr.\n";} $pid = open($handle, "rtlamr -msgtype=scm+ --format=json -filterid=101 +419821,101419999 -unique=false" ) or die "Couldn't open file rtlamr, +$!";
spawned:<br> Found rtlamr. Couldn't open file rtlamr, No such file or directory at /home/jj/eclip +se-workspace/ReadGas/ReadFromRadio.pl line 49.
open ( $handle, ">", "rtlamr -msgtype=scm+ --format=json -filterid=101 +419821,101419999 -unique=false") or die "Can't open > output.txt: $!" + ;
spawned: Found rtlamr. loop#:0 Can't exec "rtlamr": No such file or directory at /home/jj/eclipse-wor +kspace/ReadGas/ReadFromRadio.pl line 50. print() on closed filehandle $handle at /usr/lib/x86_64-linux-gnu/perl +/5.30/IO/Handle.pm line 431. loop#:1 ......
Found rtlamr. Can't exec "rtlamr": No such file or directory at /home/jj/eclipse-wor +kspace/ReadGas/ReadFromRadio.pl line 50. Couldn't open file rtlamr, No such file or directory at /home/jj/eclip +se-workspace/ReadGas/ReadFromRadio.pl line 50.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing from another program (stream)
by LanX (Saint) on Feb 27, 2022 at 19:14 UTC | |
by HiredGunTech (Initiate) on Feb 27, 2022 at 21:34 UTC | |
by LanX (Saint) on Feb 27, 2022 at 21:43 UTC | |
|
Re: Parsing from another program (stream)
by etj (Priest) on Feb 27, 2022 at 20:11 UTC | |
by HiredGunTech (Initiate) on Feb 27, 2022 at 21:38 UTC | |
by etj (Priest) on Feb 27, 2022 at 23:13 UTC | |
|
Re: Parsing from another program (stream)
by Marshall (Canon) on Feb 28, 2022 at 23:46 UTC |