Can a perl script be a plug-in?
Moderator: Mattk
-
- Platinum Boarder
- Posts: 873
- Joined: Fri Jan 25, 2008 6:27 pm
- Location: Isle of Skye, Scotland
Can a perl script be a plug-in?
Hi,
I've little Linux experience and I'm hoping this is a really simple question for someone who knows the answer. :laugh:
I've just got a "Cost Control CC128" electricity consumption monitor. I also got a serial to USB lead (uses the Prolific chip), and by adapting a simple script, installing a CPAN module and activating the prolific driver module I now have an executable perl script. So at the shell command line I can type:
./ccpi.pl
and I get plug-in style output, e.g.
data0 60500
data1 3433
data0 60500
data1 3411
However if I set up a plug-in weather station with a plug-in path of:
/srv/www/myweb/ccpi.pl
no sensors are seen by Meteohub.
Am I missing something obvious?
I've little Linux experience and I'm hoping this is a really simple question for someone who knows the answer. :laugh:
I've just got a "Cost Control CC128" electricity consumption monitor. I also got a serial to USB lead (uses the Prolific chip), and by adapting a simple script, installing a CPAN module and activating the prolific driver module I now have an executable perl script. So at the shell command line I can type:
./ccpi.pl
and I get plug-in style output, e.g.
data0 60500
data1 3433
data0 60500
data1 3411
However if I set up a plug-in weather station with a plug-in path of:
/srv/www/myweb/ccpi.pl
no sensors are seen by Meteohub.
Am I missing something obvious?
Re:Can a perl script be a plug-in?
Hi,
I don't know the answer, but I have a similar problem.
I wrote a perl script to get data from my heating system to meteohub. I also installed the CPAN module and the script was running well!
I get as an output for the temperatures:
t1 35
t2 340
t3 355
t4 470
.....
As the script is running in a {while}loop and print out the data every minute,
I setup the plug-in without filling in the plug-in path. Following an other thread in this forum.
But no sensors are seen in meteohub too.
error message: meteohub log
logger (05.02.2010 22:40:34): connect station 1 (Plug-in via Plug-in).
logger (05.02.2010 22:40:34): unexpected 0 bytes delivered from weather station 1 (Plug-in)
What is going wrong?
I don't know the answer, but I have a similar problem.
I wrote a perl script to get data from my heating system to meteohub. I also installed the CPAN module and the script was running well!
I get as an output for the temperatures:
t1 35
t2 340
t3 355
t4 470
.....
As the script is running in a {while}loop and print out the data every minute,
I setup the plug-in without filling in the plug-in path. Following an other thread in this forum.
But no sensors are seen in meteohub too.
error message: meteohub log
logger (05.02.2010 22:40:34): connect station 1 (Plug-in via Plug-in).
logger (05.02.2010 22:40:34): unexpected 0 bytes delivered from weather station 1 (Plug-in)
What is going wrong?
-
- Platinum Boarder
- Posts: 873
- Joined: Fri Jan 25, 2008 6:27 pm
- Location: Isle of Skye, Scotland
Re:Can a perl script be a plug-in?
I'm not at all certain but I think that something is perhaps not "letting go" of the connection cleanly?Billy wrote:What is going wrong?
I have managed to get Meteohub to see plug-in output on a couple of occasions by pulling out then re-inserting the connector, but even when that 'works' (and that's not every time - possibly because of the connector picking up ttyUSB1 instead of ttyUSB0 sometimes?) Meteohub only sees one cycle of the reading loop. When Meteohub tries to restart the plug-in after 150 seconds of silence, there is still nothing.
Very strange.
Are you also using the Prolific driver?
I believe it used to be possible to get an old fashioned serial cable for the device I'm using (Current Cost CC128). I may see if I can get hold of one of those - that would at least take serial-to-USB considerations out of the equation!
Re:Can a perl script be a plug-in?
When Perl script runs but no data delivered to Meteohub, flushing might be a solution. When acting on pipes you don't have control when data is written from buffers to the listening device. So it might be that the Perl script writes data, but these just fill-up buffers. Of course buffers will be flushed after some amount of data (and when writing process terminates), but that can take time as you feed very little data in. From Meteohub's point of view no data is coming through, so it tries a restart and things start again...
Only solution to that is to manually flush buffers after having written your data to the pipe. Please change your Perl script accordingly give it a try.
Link to flushing in Perl: http://www.rocketaware.com/perl/perlfaq ... fileha.htm
Only solution to that is to manually flush buffers after having written your data to the pipe. Please change your Perl script accordingly give it a try.
Link to flushing in Perl: http://www.rocketaware.com/perl/perlfaq ... fileha.htm
-
- Platinum Boarder
- Posts: 873
- Joined: Fri Jan 25, 2008 6:27 pm
- Location: Isle of Skye, Scotland
Re:Can a perl script be a plug-in?
Thank you.admin wrote:Only solution to that is to manually flush buffers after having written your data to the pipe. Please change your Perl script accordingly give it a try.
Adding the line
STDOUT->autoflush( 1 );
did the trick. :cheer:
However I may have found a slight deviation from the plug-in documentation, which states:
In practice I seem to find that anything above data19 is seen but is listed as Type unknown.Data data# 0-39 system data [1/100 value]
I don't have more that 20 sensors (yet) but 30 are possible. The CC128 can read from up to 10 sensors (numbered 0 to 9), and each can have up to 3 'channels' *numbered 1 to 3). Those numbers are in the xml that I'm parsing and I'd hoped to use a regex so that each available value resulted in a line to stdout on the basis of:
data<channelNumber><sensorNumber> <valueX100>
e.g. Channel 1 on sensor 0 is data10, channel 2 on sensor 3 is data23, and so on up to, channel 3 on sensor 9 is data39.
Should that be possible?
Re:Can a perl script be a plug-in?
Thanks a lot for these hints. I'll check it for my situation after one week on vacation.
:)
:)
Re:Can a perl script be a plug-in?
As promised herewith my feedback.
Perl script is now running well after optimizing some "while loops".
STDOUT->autoflush( 1 ); was not necessary as I used $| = 1;for flushing.
BTW: Does anybody know if one can use Meteohub to log and display digital data 0/1 like:
eg. power off/on or pump off/on ?
Thanks for help.
Billy
Perl script is now running well after optimizing some "while loops".
STDOUT->autoflush( 1 ); was not necessary as I used $| = 1;for flushing.
BTW: Does anybody know if one can use Meteohub to log and display digital data 0/1 like:
eg. power off/on or pump off/on ?
Thanks for help.
Billy
-
- Platinum Boarder
- Posts: 873
- Joined: Fri Jan 25, 2008 6:27 pm
- Location: Isle of Skye, Scotland
Re:Can a perl script be a plug-in?
The generic "data" type always stores data with 2 decimal places, but the data itself could easily be integer in nature. How a web page or graph is then used to display and interpret the data is up to it.Billy wrote:BTW: Does anybody know if one can use Meteohub to log and display digital data 0/1 like:
eg. power off/on or pump off/on ?
e.g. php or javascript could easily use an if statement with a condition that branches on whether or not the value is equal to zero, or you could use Meteohub to graph the value (or it's "rise" &/or "fall" properties).
Re: Can a perl script be a plug-in?
Boris fixed this right after my post, several versions ago. I'm currently running v4.5i, and wind reporting from the RainWise MkIII is fine. What version is your Meteohub?
______________________________________________________
Mobile Phones Lenovo LePad S2005A Lenovo LePhone P700
______________________________________________________
Mobile Phones Lenovo LePad S2005A Lenovo LePhone P700
Re: Re:Can a perl script be a plug-in?
Wow, that helped me today too. Changed Bash/nc script to some quite serious Perl socket. Tested for weeks in SDTOUT, but never as plugin itself. Old posts are still useful..skyewright wrote:
Adding the line
STDOUT->autoflush( 1 );
did the trick. :cheer:
