Skip to main content

Reply to "Python code to issue TMCC, Legacy, and PDI Commands"

@G3750 posted:

That's pretty cool!  Are you keeping some sort of state table for everything?  If so, I'm guessing it is dynamic in nature (record creation and destruction) so as to minimize memory usage.

George

Yes, I'm keeping a state table for the devices discovered by sniffing the TMCC command flow fro the LCS Ser2. The info is fairly minimal, to reduce the memory footprint. For example, for switches, just the thru/diverged info. For Accessories, a triplet for Aux on/off, Aux 1 on/off, and Aux2 on/off. For engines and trains, for now, I'm only listening for speed, direction, and if the engine has been "started" or "shutdown". I could maintain more info, such as momentum, brake level, smoke, etc, but I'm not sure I'll need that for what I'm doing (but it could be added).

I never really delete any state records, as on a typical layout, you are not removing switches or accessories. I could time out engine/train state records, but they really don't take too much memory.  On my Pi Zero W 2, which I think only has about 512MB of ram, the program only uses about 20mb.

  -- Dave

×
×
×
×
×