misc code updates.
This commit is contained in:
parent
3f86d316d8
commit
307044eda9
@ -30,10 +30,10 @@ local $| = 1;
|
|||||||
my $dbname = "powermeter";
|
my $dbname = "powermeter";
|
||||||
my $dbhost = "localhost";
|
my $dbhost = "localhost";
|
||||||
my $dbusername = "powermeter";
|
my $dbusername = "powermeter";
|
||||||
my $dbpassword = "password";
|
my $dbpassword = "<your password>";
|
||||||
my $dbtable = "powermeter";
|
my $dbtable = "powermeter";
|
||||||
|
|
||||||
my $subclient = "/usr/bin/mosquitto_sub -t sensors/cc128";
|
my $subclient = "mosquitto_sub -t sensors/cc128";
|
||||||
open(SUB, "$subclient|");
|
open(SUB, "$subclient|");
|
||||||
SUB->autoflush(1);
|
SUB->autoflush(1);
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ use FileHandle;
|
|||||||
|
|
||||||
local $| = 1;
|
local $| = 1;
|
||||||
|
|
||||||
my $subclient = "/usr/bin/mosquitto_sub -t sensors/cc128/raw -q 2";
|
my $subclient = "mosquitto_sub -t sensors/cc128/raw -q 1";
|
||||||
my $pubclient = "/usr/bin/mosquitto_pub -t sensors/cc128 -q 2 -l";
|
my $pubclient = "mosquitto_pub -t sensors/cc128 -q 1 -l";
|
||||||
my $pubclient_ch1 = "/usr/bin/mosquitto_pub -t sensors/cc128/ch1 -q 2 -l";
|
my $pubclient_ch1 = "mosquitto_pub -t sensors/cc128/ch1 -q 1 -l";
|
||||||
|
|
||||||
open(SUB, "$subclient|");
|
open(SUB, "$subclient|");
|
||||||
open(PUB, "|$pubclient");
|
open(PUB, "|$pubclient");
|
||||||
@ -23,7 +23,7 @@ PUB_CH1->autoflush(1);
|
|||||||
|
|
||||||
while (my $line = <SUB>) {
|
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>
|
#<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 $reading_time = $1;
|
||||||
my $temp = $2;
|
my $temp = $2;
|
||||||
my $watts = $3;
|
my $watts = $3;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use Device::SerialPort qw( :PARAM :STAT 0.07 );
|
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";
|
my $PORT = "/dev/ttyUSB0";
|
||||||
local $| = 1;
|
local $| = 1;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ running = True
|
|||||||
try:
|
try:
|
||||||
while running:
|
while running:
|
||||||
line = usb.readline()
|
line = usb.readline()
|
||||||
mosq.publish("cc128/raw", line)
|
mosq.publish("sensors/cc128/raw", line)
|
||||||
except usb.SerialException, e:
|
except usb.SerialException, e:
|
||||||
running = False
|
running = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user