I've just reinstalled my system from scratch on a Pi v2, but following system restarts, emonhub sometimes does not run.and I get this error.
It occurred twice last night, but by restarting again, everything ran OK
pi@raspberrypi ~ $ sudo service emonhub restart [ ok ] Restarting OpenEnergyMonitor emonHub: emonhub has been restarted ok. pi@raspberrypi ~ $ Traceback (most recent call last): File "/usr/share/emonhub/emonhub.py", line 338, in <module> hub.run() File "/usr/share/emonhub/emonhub.py", line 90, in run values = I.read() File "/home/pi/emonhub/src/emonhub_interfacer.py", line 509, in read return self._process_frame(f, t) File "/home/pi/emonhub/src/emonhub_interfacer.py", line 101, in _process_frame validated = self._validate_frame(ref, frame) File "/home/pi/emonhub/src/emonhub_interfacer.py", line 531, in _validate_frame self.rssi = int(received[-1][1:-1]) ValueError: invalid literal for int() with base 10: '9C'
Any thoughts...
Re: Emonhub error? (Solved)
Which RFM2Pi and firmware versions are you running ?
Line 531 just (strips parenthesis and) the casts the rssi value to an int. To get to that line there are several hoops and hurdles to sift out invalid packets, not least the "if the last value in this frame is enclosed in parenthesis " check immediately before it. Plus the "ValueError: invalid literal for int() with base 10: '9C'" could suggest that value is hex.
Can you see a emonhub.log entry for this ? emonHub may have added a "NEW FRAME" log entry (if in debug mode) and that line would probably end in " (9C) ".
I'm guessing you are using emonhub rc1.2(development branch) ?
I can look at adding an additional check to emonhub to make it more robust against being tripped up by this error as it could be a little more graceful and carry on after logging the issue.
Paul
Re: Emonhub error? (Solved)
Thanks Paul, this is what showed up in the emonhub log;
...and further investigation (thanks to the emonhub log) revealed a problem with a 'Retained MQTT Message' which contained a 13 digit number as it's payload, and was sent as soon as emoncms subscribed to that node, and almost certainly caused the issue above.
Background to this was I was testing emoncms by sending MQTT messages via node-red using qos 1 and with the retained flag set. Unfortunately I had forgot to format the payload, and the default payload is a 13 digit Unix Timestamp, so it was then immediately deleted.
However, I suspect that emoncms phpmqtt is not returning a MQTT Puback message, acknowledging receipt, and the 'timestamp' message was stored by the client as a Retained Message. So, despite a reboot, whenever emoncms subscribed to RX/# at startup, it was sent the 13 digit message which exceeds datacode h spec.
I've now cleared the Retained message cache, and have rebooted several times with no issues.
Paul
Re: Emonhub error? (Solved)
Glad you got it sorted although I'm a little unsure how the value found it's way in via the serial port and so far into the code, if it was coming from the mqtt broker, do you have some mqtt handling in emonhub or is it stock?
Paul
Re: Emonhub error? (Solved)
It's stock, and I did think the same, but the only explanation that my limited knowledge could comprehend!
Paul