Emonhub MainThread dying with direct serial connections

Connections via RFM are quite stable. As I moved the rPi right next to the EmonTX Shield transmitters I want to connect them directly without radios now. It seems that the noRF example found in the wiki is outdated as it does not transmit the nodeID first. After fixing that I got valid data coming in. After a while no new data is displayed in emoncms. Restarting emonhub (service emonhub restart) makes it work. I found out that debug messages that are output during boot up of the micro controller seem to put the input processor into an invalid state (“thread is dead”). I guess this is due to missing input sanitation on the emonhub side?

I have two EmonTX Shield connected to Pro Minis running on 16Mhz, 3.3V sourced from the rPi B+. One EmonTX connected to the GPIO header of the rPi, one to a PL2303 USB-serial adapter. Only TX and GND are connected from the EmonTXs.

emonhub config:

[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyAMA0 #native serial port
com_baud = 9600
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
subchannels = ToRFM12,
calibration = 230V #(UK/EU: 230V, US: 110V)
baseid = 5 #(emonPi default:5)
quiet = false #(default:true)

[[SerialDirectUSB]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyUSB0 #USB adapter
com_baud = 9600
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
subchannels = ToRFM12,
calibration = 230V #(UK/EU: 230V, US: 110V)
baseid = 5 #(emonPi default:5)
quiet = false #(default:true)

Typical output of the log after some time:

2016-05-15 15:03:49,778 WARNING MainThread SerialDirectUSB thread is dead
2016-05-15 15:03:50,095 WARNING MainThread SerialDirectUSB thread is dead
2016-05-15 15:03:50,225 DEBUG emoncmsorg acknowledged receipt with ‘ok’ from http://emoncms.org
2016-05-15 15:03:50,234 INFO emoncmsorg sending: http://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2016-05-15 15:03:50,496 WARNING MainThread SerialDirectUSB thread is dead

It most probably will be the lack of sanitation and error handling, see this thread on the old forum for a similar issue.

When writing your firmware you will need to be 110% sure there is no chance of non-numerical data or any other deviation from the expected payload format and value scope. The serial interfacer in the “emonpi” variant of emonhub wasn’t developed any further than the “experimental” proof of concept.