RFM2Pi thread dead: Caused by 3phase decoder settings

I’ve just spent a few hours playing with my new emonTx v3.4 in preparation for monitoring my 3 phase power. As required for this, I downloaded the 3phase firmware and started editing my way to a calibrated setup.

I noticed the following sections already existed in the default emonhub.conf file that came with the emonSD image:

[[11]]
  nodename = 3phase
  [[[rx]]]
    names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
    datacode = h
    scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
    units =W,W,W,W,V,C,C,C,C,C,C,p
 
[[12]]
  nodename = 3phase2
  [[[rx]]]
    names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
    datacode = h,h,h,h,h,h,h,h,h,h,h,L
    scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
    units =W,W,W,W,V,C,C,C,C,C,C,p

So I fired it all up and was getting data - happy days!
Then I noticed in my Inputs that I had two unnamed values against 3phase (numbered 12 and 13). Looking at the 3phase firmware I see that it is set to node 11, so that’s where I went looking in the emonhub.conf.

Ok, I thought “I just need to copy the decoder section from the script comments”, so I copied and pasted those in over node 11 in my emonhub.conf and rebooted.
I headed downstairs to continue my calibration efforts where I had access to measure current, expecting to come back upstairs to see correct data in my inputs when I came back.

What I came back to was a log file full of “MainThread RFM2Pi thread is dead”.

After a few hours of searching through the forums and numerous reboots, I went back through all of the changes I’d made since it had worked, and the fix was to put the old (default) copy of my emonhub.conf back.

Another half hour of searching through logs and playing with different options, the problem turned out to be a missing “s”.

The default emonhub.conf has this for node 11:

    datacode = h

The 3phase script comments have this:

    datacode = h,h,h,h,h,h,h,h,h,h,h,L

The correct line should be:

    datacodes = h,h,h,h,h,h,h,h,h,h,h,L

I’ve logged an Issue in GitHub against the 3phase firmware, but I’m not sure that a syntax error in the emonhub.conf should cause a thread to die either, so I think that’s another bug somewhere else.

Looking at the other 3phase nodes in the default emonhub.conf file, I see that node 12, 13 and 14 are also all incorrect.

Not in my master version - that is correct with “datacodes = …”
It has clearly been edited / incorrectly copied for the 1st Feb 2017 version. I don’t use Github and I don’t check edits made by others.

All of the documentation that I could find points to “get the code for 3phase firmware from GitHub”.
If it’s not the right place, where is the right place? Where is the “master version” and how do I get it?

Regardless of who edited what and when, there is still the problem that the default emonhub.conf that came with the emonSD image I downloaded from http://files.openenergymonitor.org/emonSD-07Nov16.zip includes the “datacode” syntax error for nodes 12, 13 and 14. If this is the wrong place to report that, where is the right place?

Hopefully my post will still save someone else a lot of time if they followed the same instructions I did when attempting 3phase power…

I’ve submitted a PR for your correction to the 3phase sketch

@Robert is correct, the issue was introduced in with several other changes on the 1st Feb

Regarding the existing emonHub configurations, there has already been a correction applied

which also mentions the resulting “thread is dead” logs. You are absolutely right in saying this shouldn’t happen and if you search the forums for “Thread is dead” you will find numerous reports of this error, for many different reasons. That message is a last resort message that should never be seen, it signifies the interfacer thread has died because of unhandled errors, the message was only ever there to avoid any chance of the threads crashing silently. The issue is specific to the “emon-pi” variant and can only ever get better with stricter coding and better testing. At least we now know how to cause this particular trigger, so we can take a closer look at why.

All I was saying is the version that I created was correct. Edits by others have made it incorrect, and the responsibility for those errors lies with the editor.

It grieves me too that people (like you and Paul) have to waste time and effort over errors like this one.

Thanks Paul, I saw the PR and so closed the issue in GitHub.

I did sift through dozens of “thread is dead” posts in the forums here and none of them that I read indicated the syntax error could be a cause :slight_smile:
It seems I should have gone searching in GitHub as well. You live and learn.

PR has now been merged. Thanks a lot @pb66