misc code updates.
This commit is contained in:
parent
3f86d316d8
commit
307044eda9
@ -30,10 +30,10 @@ local $| = 1;
|
||||
my $dbname = "powermeter";
|
||||
my $dbhost = "localhost";
|
||||
my $dbusername = "powermeter";
|
||||
my $dbpassword = "password";
|
||||
my $dbpassword = "<your password>";
|
||||
my $dbtable = "powermeter";
|
||||
|
||||
my $subclient = "/usr/bin/mosquitto_sub -t sensors/cc128";
|
||||
my $subclient = "mosquitto_sub -t sensors/cc128";
|
||||
open(SUB, "$subclient|");
|
||||
SUB->autoflush(1);
|
||||
|
||||
|
@ -9,9 +9,9 @@ use FileHandle;
|
||||
|
||||
local $| = 1;
|
||||
|
||||
my $subclient = "/usr/bin/mosquitto_sub -t sensors/cc128/raw -q 2";
|
||||
my $pubclient = "/usr/bin/mosquitto_pub -t sensors/cc128 -q 2 -l";
|
||||
my $pubclient_ch1 = "/usr/bin/mosquitto_pub -t sensors/cc128/ch1 -q 2 -l";
|
||||
my $subclient = "mosquitto_sub -t sensors/cc128/raw -q 1";
|
||||
my $pubclient = "mosquitto_pub -t sensors/cc128 -q 1 -l";
|
||||
my $pubclient_ch1 = "mosquitto_pub -t sensors/cc128/ch1 -q 1 -l";
|
||||
|
||||
open(SUB, "$subclient|");
|
||||
open(PUB, "|$pubclient");
|
||||
@ -23,7 +23,7 @@ PUB_CH1->autoflush(1);
|
||||
|
||||
while (my $line = <SUB>) {
|
||||
#<msg><src>CC128-v0.12</src><dsb>00002</dsb><time>00:02:12</time><tmpr>15.7</tmpr><sensor>0</sensor><id>03112</id><type>1</type><ch1><watts>00108</watts></ch1></msg>
|
||||
if ($line =~ m#<time>(.*)</time><tmpr> *([\-\d.]+)</tmpr><sensor>0</sensor><id>[0-9]*</id><type>1</type><ch1><watts>0*(\d+)</watts></ch1></msg#){
|
||||
if ($line =~ m#<time>(.*)</time><tmpr> *([\-\d.]+)</tmpr><sensor>0</sensor><id>[0-9]*</id><type>1</type><ch1><watts>0*(\d+)</watts></ch1></msg.*#){
|
||||
my $reading_time = $1;
|
||||
my $temp = $2;
|
||||
my $watts = $3;
|
||||
|
@ -6,7 +6,7 @@
|
||||
use strict;
|
||||
use Device::SerialPort qw( :PARAM :STAT 0.07 );
|
||||
|
||||
my $pubclient = "mosquitto_pub -t sensors/cc128/raw -q 2 -l";
|
||||
my $pubclient = "mosquitto_pub -t sensors/cc128/raw -q 1 -l";
|
||||
my $PORT = "/dev/ttyUSB0";
|
||||
local $| = 1;
|
||||
|
||||
|
@ -13,7 +13,7 @@ running = True
|
||||
try:
|
||||
while running:
|
||||
line = usb.readline()
|
||||
mosq.publish("cc128/raw", line)
|
||||
mosq.publish("sensors/cc128/raw", line)
|
||||
except usb.SerialException, e:
|
||||
running = False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user