As much as I like the advantages of a monogamous world, maybe I can offer some advice here. In another Python project I did I found the best way to allow multiple threading-based hardware-interfacing processes to use the same hardware is to make use of the threading.Lock() functionality. I think EmonHub could greatly benefit from it, especially as the number of interfacers grows. In my simplistic world it would actually be rather straightforward to implement.
- the treadLock would be added to the init() constructor of the Emonhub class:
threadLock = threading.Lock()
- Then the lock just needs to be activated and released in the run() method of the EmonHubInterfacer class, just before and after self.read(), like this:
rxc = self.read()
In this way all interfacers children could do their hardware interaction without any risk of collision with other hardware processes because only one interfacer can acquire the lock at any one time. My excuses if I am overlooking something obvious here and for possibly overstepping any boundaries.
I like this approach and think this is where it should be heading. I dont even need a counter; as long as I only set the interfacer interval hourly it should be just perfect. And yes, I need another NodeID for that, but I could not find anywhere in the config file where the NodeID is linked to an interfacer. Does it have to be hardcoded or how does this work?