Skip to main content

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

Just checked in code to issue Legacy/TMCC2 Lighting Effects commands, as documented on page 18 of the Lionel Partner Program documentation. These are part of the 3-word commands, and use 9 bytes to express a command. The Lighting control effects include support for:

  • Dog house lights (on/off)
  • Hazard lights (on/off/auto)
  • Ditch lights (on/on pulse off with horn/off pulse on with horn/off)
  • Loco/engine marker lights (on/off)
  • Tender marker lights (on/off)
  • Ground lights (on/off/auto)
  • Strobe lights (on/double flash/off
  • Mars lights (on/off)
  • Cab lights (on/off/auto)
  • Rule 17 (on/off/auto)
  • Car cabin lights (on/off/auto)

Support includes the cli script lighting.py, and a command class.

I also built a cli that reads requests from the command line and, using the parsers developed for each of the cli commands, parses the input and sends the appropriate command to the LCS SER2. The program continues to process your input until you enter "q" or hit <ctrl-c>.

Here is an example:

(legacyEnv) davids@Sprucewood-iMac PyLegacy (master) % src/cli/control.py 
PyLegacy train controller, Ver 0.1
>> eng 88 speed 50 # sets the absolute speed of engine 88 to 50
>> li 88 ditch -on # turns ditch lights on
>> eng 88 -b -re 4 -de 0.5 # blow horn 4 times w/delay of 0.5 seconds between


You can also get help on command options like so:

>> eng 1 sp -h
usage: control.py Engine/Train speed [-h] [-a | -r]
Engine/Train speed: 0 - 199 (Legacy) or 0 - 31 (TMCC) or roll, restricted,
slow, medium, limited, normal, or highball

positional arguments:
Engine/Train speed: 0 - 199 (Legacy) or 0 - 31 (TMCC) or roll, restricted,
slow, medium, limited, normal, or highball

options:
-h, --help show this help message and exit
-a, --absolute Set absolute speed
-r, --relative Set relative speed speed (-5 to 5)
>>


The Effects controls are next up (smoke on/off, stock car options, pantograph control, etc).

Enjoy!

  -- Dave

Last edited by cdswindell
×
×
×
×
×