Need help - Getting lost in all the information - want to get things working...
Dear all,
I'm working on the following setup:
3x emonTxV3.4 connected to a Raspi V1b via serial cable (2x with USB UART).
This Raspi (called emonhub-pi) forwards the packets via Ethernat cable to a central Raspi V2 (emonCMS-pi), running on SSD with a local emonHub / emonCMS installation.
The emonCMS-pi already does the job with wireless packets from emonTH devices.
As I found the time now to setup the emonhub-pi as a forwarder (first installation did the job well - but SD crashed) I updated to the newest preconfigured SD image "emonSD-17Jun2015.img" from emon website.
Here I did some basic setting (static IP, root Passwd, ...).
I successfully ping-ed the emonCMS-pi and connected via ssh - network connection seems to fit.
I looked at the serial console to see what the emonTxV3 NR1 is posting (USB serials not yet connected)
"10 513,25 510,44 -509,99 509,74 230,83" each 2s (Serial direct sketch)
My emonHub config file lists the following (that worked within the image before
[hub] loglevel = WARNING [reporters] [[emonCMS]] Type = EmonHubEmoncmsReporter [[[init_settings]]] [[[runtimesettings]]] url = http://192.168.1.28/emoncms apikey = ############################### [interfacers] [[SerialDirect]] Type = EmonHubSerialInterfacer [[[init_settings]]] com_port = /dev/ttyAMA0 com_baud = 9600 [[[runtimesettings]]] group = 210 frequency = 433 baseid = 15 [nodes]
Now the emonhub.log constantly gives me this warning:
2016-04-16 19:05:08,867 WARNING MainThread SerialDirect thread is dead
Rebooting the the pi does not help
I'm running out of ideas. As I don't have a emonPi (only a Pi with emonhub running) I guess I could use an other image. But which to use ?
The central emonCMS is version 9.4
Thanks for any help in advance.
Re: Need help - Getting lost in all the information - want to get things working...
I'm not an expert - hopefully one will be along soon...
But I think you might need to install using the raspberry pi installation guide rather than using the SD image. Certainly worth a try.
https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/readme.md
Simon
Re: Need help - Getting lost in all the information - want to get things working...
Was the direct serial connection working before you re-imaged? Its been a while since I last did a build using a direct serial connection between the emontx and emonpi - things have moved on quite a bit since then in terms of emoncms and emonhub version. Can you catch the point in the logs where the SerialDirect thread dies? There may be some more clues there.
Can I rename your thread to reflect the topic perhaps: "Need help, emonhub with emontx to pi direct serial connection"?
Re: Need help - Getting lost in all the information - want to get things working...
1st step would be to set emonhub's "loglevel = DEBUG" in emonhub.conf rather than WARNING which will give you more info.
The "WARNING MainThread SerialDirect thread is dead" error message can only be found in the emon-pi variant of emonhub and yet the emonhub.conf you have is for the original version of emonhub. There are no reporters in the emon-pi variant, the "EmonHubEmoncmsReporter" was replaced with a "EmonHubEmoncmsHTTPInterfacer".
There is also an absence of the routing settings (the to and from) required for the interfacers in that variant.
While you are in the conf you can get rid of the group, frequency and baseid settings as they are not used for serial direct, only needed for RFM networks, this won't be effecting the issues you have though.
Your example packet "10 513,25 510,44 -509,99 509,74 230,83" shows some comma's, is this a typo or a regional thing? emonhub will expect (depending on version) a frame in one of 2 forms, a nodeid followed by space separated decimal values eg "10 513.25 510.44 -509.99 509.74 230.83" or (less likely) a node id followed by space seperated "byte values" ie values between 0 and 255 to be reconstructed into full values using datacodes, either way the comma's could cause the packets to be discarded unless there is a "regional" adjustment made at the recieving end (emonhub) too.
The emonhub log should show you exactly whats happening there if you change the loglevel.
Also be aware that emoncms.org will probally block your address/device if you are posting at 2s intervals, the recommended rate is 10s, but you should be ok with a local install.
Paul
Re: Need help - Getting lost in all the information - want to get things working...
I am also having trouble with the "SerialDirect thread is dead" message when trying to connect via serial to the emon-pi emonHub variant 1.1.
The Arduino I am using works when connected via serial to my older emonHub, running the emonSD-13-03-15.img image that provided me with "emonHub Pre-Release Development Version (rc1.2)".
With the identical hardware setup, but running the emonSD-29Mar16 release candidate 2 image, I get the errors below.
First, my interfacer config:
And here is the result:
Re: Need help - Getting lost in all the information - want to get things working...
Can you provide more info on the sketch and/or serial data ?
The "SerialDirect thread is dead" is a simple check written into the main core of emonhub to avoid a situation where an interfacer thread crashes out without any notice and it's then unknown if the interfacer is "dead" or just quiet.
Basically the thread is crashing and there is no clues as to why since the error handling and logging is "a little thin" in this version.
As in the example above it could well be the incoming data just isn't perfect and it's not being handled the same way it would be in the original version.
Paul
Re: Need help - Getting lost in all the information - want to get things working...
Here is the serial data:
The sketch is my modification of Felix Rusu's Moteino sketch:
Re: Need help - Getting lost in all the information - want to get things working...
My best guess is the text from the setup() isn't being caught and removed so when the interfacer tries to extract the node id it fails as there is no int present. The original emonhub's serial interfacer had basic input sanitation where as the raw data is passed without any checks in this variant.
Any attempts to edit the emonhub code could cause issues with the emonpi update script so your best course of action is a quick edit to the sketch to remove any printing of non-numeric data. Primarily in the setup() but since the loop() "if (Serial.available() > 0)" code block is not useful without proper integration within emonhub, perhaps a custom Monteino interfacer. I would probably cut that away too, replacing it with some hardcoded "options" if required.
if you want to implement something a little grander I will help with some pointers but if you plan to keep updating via the emonpi update script this is the easiest option unless the changes are made upstream.
Paul
Re: Need help - Getting lost in all the information - want to get things working...
Thanks, Paul! That was it. I hadn't bothered to clean up the mess I had made of that sketch because it was working on my old emonHub. I cleaned it up and removed all the extraneous serial printing. Now it works perfectly.
I did notice that emonhub is adding an RSSI value to that input, which I am not sending it. It sets it to zero and displays it in the inputs view. Is there some assumption in this version of emonhub that there is always an RSSI value?
Regarding implementing something a little grander, here is what I am envisioning: using my emonHub+Moteino as an internet-of-things base station. I.e uing the OpenHAB app to set a switch, which triggers an MQTT message, which Node-RED catches. Node-RED then sends a command over serial (USB) to the Moteino base station, which radios a remote Moteino to do something. I'd be interested in any pointers you might have. Like, is that even a good way to approach it? And, does Node-RED have an easy way to write serial data to the USB port of the Pi?
Thanks again!
Brandon
Re: Need help - Getting lost in all the information - want to get things working...
The other thing that appears to cause the "MainThread SerialDirect thread is dead" warning is simply connecting or disconnecting the device plugged into the USB port. And once that warning starts up, it repeats at least once every second. It would be nice, if I could suggest it, if the input sanitation from the older emonHub was brought forward to this one.
I found that simply restarting emonHub with "sudo service emonhub restart" was not enough to resolve "thread is dead" warning. I had to reboot the Pi on which it is running.
I would second the earlier motion to rename this thread: "WARNING MainThread SerialDirect thread is dead" and in my opinion we could add [SOLVED]. For now, the trick is to be very careful that you reboot your Pi running emonHub when you plug in a USB serial input, and you must make sure there is nothing printing to that serial port other than nice, clean input messages in the expected format.
Re: Need help - Getting lost in all the information - want to get things working...
Hi Brandon
emonhub should be robust enough not to fail due to incorrect serial data, ideally the sketch should identify itself so that down the line you know what sketch and version you are running. The removal of all the serial prints is not an acceptable fix IMO it is a quick and dirty workaround but if it gets you up and running that's good to know.
Yes the emon-pi variant assumes everything has an rssi, the original emonhub only passes the rssi if a valid rssi is attached to an incoming RFM packet, but this variant is very different in many ways.
If restarting emonhub doesn't resolve the "WARNING MainThread SerialDirect thread is dead" issue then there is something else in the mix causing an issue.
Any serial port (gpio or usb) can only have 2 devices using those lines, for that reason you should not have node-red connecting to the same port/device as emonhub. This maybe the reason you need to reboot the Pi if there is anything else accessing the same serial port, restarting emonhub will not free the serial port fo emonhubs exclusive use.
Ideally you should be able to configure emonhub to listen for the openhab mqtt and act "directly" with the monteino. I am not saying you cannot use node-red, many do but, you cannot have multiple softwares connected to the one device and therefore openhab should connect directly with emonhub or of you go to node-red then node-red should go to emonhub which may be pointless.
I am not opposed to the thread name being changed at all, perhaps "WARNING MainThread SerialDirect thread is dead" would be more appropriate but since the issue is far from solved I would be opposed to the [solved] tag especially as there are many, many reasons that could cause that catch all error, it is not the sort of error that will ever be solved for everyone.
Paul
Re: Need help - Getting lost in all the information - want to get things working...
Hi all,
thanks for all the good tips.
I will give them a try now - didn't found the time to go on with it until now.
First of all I will change the setting for log level and check the arduino script for the period/commata issue. It might be have been me, who copied the period things to Notepad++ and change all periods for commas (excel import required in germany)
In the end, it seems I have to update my emonCMS / emonHub Setup on the central Pi to support the new method.
I really don't like to make a "from the scratch" setup, since everything for ssd and settings is working fine.
I'll get back with more info soon.
If you'd like to rename the thread - feel free. Serial direct / serial thread dead / emonHub update issue might be good chunks for a header.
Cheers
Christian