Device API
LoDi-Shift-Commander API
Introduction
The device type is always 0x09 on the LoDi-Shift-Commander.
Basic commands
GetVersion
This command returns the device identifier and the FW version of the device.
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x0F | 0x00 .. 0xFF |
| Packet type | Command | Packet number | Device type | Major | Minor | Patch |
|---|---|---|---|---|---|---|
| 0x21 | 0x0F | 0x00 .. 0xFF | 0x09 |
The firmware version is made up of the three parts major, minor and patch. It is shown in the format "v<major>.<minor>.<patch>". Example: "v01.01.01"
This command reads the settings of the LoDi-Shift-Commander.
The major version only changes when completely new hardware with different characteristics and a different feature set is released.
The minor version changes when the API is extended. Individual commands may also become incompatible.
The patch version changes for general bug fixes that do not touch the API.
DeviceConfigGet
Bus config
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x64 | 0x00 .. 0xFF |
| Packet type | Command | Packet number | MaxAktivWeichen | WeichenStart | The bus config field holds the configuration of the bus. It is split into several bits. |
|---|---|---|---|---|---|
| 0x21 | 0x64 | 0x00 .. 0xFF | 0 .. 1 | 0 .. 10 | 0 .. 2 |
Bit 0: bus 1 active
- 0: bus 1 inactive
- 1: bus 1 active
- 0: bus 2 inactive
- 1: bus 2 active
- 0: light bus (96 outputs)
- 1: switching bus (384 outputs)
- The MaxAktivWeichen field defines how many turnouts may be thrown at the same time. This avoids overloading the power supply when solenoid accessories are used.
0: no limit
- >0: the number of turnouts set can be active at once. Otherwise execution waits until the other turnouts have finished throwing.
- The WeichenStart entry sets how the turnouts are initialised at switch-on.
0: the turnouts are not initialised
- 1: the turnouts are set to their last state.
- 2: every turnout state is cycled through once. After that the last state known before switch-off is set.
- OperatorNameGet
Reads the name of a LoDi-Operator.
BusNr
| Packet type | Command | Packet number | OperatorPos | Character n |
|---|---|---|---|---|
| 0x20 | 0x73 | 0x00 .. 0xFF | 1..2 | 0..47 |
| Packet type | Command | Packet number | Length | Character 1 | .. | BusNr names the bus to use. Within that bus, OperatorPos determines whose operator name is read. Each LoDi-Operator counts as one device. |
|---|---|---|---|---|---|---|
| 0x21 | 0x73 | 0x00 .. 0xFF | 0 .. 16 |
The length determines the number of characters that follow.
Switching commands
CommandListGet
Reads the list of every command the LoDi-Shift-Commander supports.
KommandoNr
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x61 | 0x00 .. 0xFF |
| Packet type | Command | Packet number | Count | States | Outputs | Category | The count field carries the number of possible commands. It determines how many command descriptions follow. |
|---|---|---|---|---|---|---|---|
| 0x21 | 0x61 | 0x00 .. 0xFF | 0 .. 255 | 1 .. 16 | 1 .. 10 | 0 .. 3 |
The KommandoNr field is the identifier of the command.
The states entry says how many states, counted from 0, the command can take. A simple turnout typically has 2 states; signals may well have 10 or more.
Outputs describes how many hardware outputs the command occupies. A simple turnout occupies two, signals quite possibly 6 and more.
The category field returns the classification of the command. The following values are possible:
0: turnouts – turnouts are initialised at start-up if the device is set to do so
- 1: signals – every track signal, light or semaphore
- 2: effects – every lighting effect
- 3: special – every special decoder command, such as those for the LoDi-Light-Operator
- CommandNameGet
Reads the name of a command together with additional information.
The KommandoNr field holds the identifier of the command to be read.
| Packet type | Command | Packet number | States |
|---|---|---|---|
| 0x20 | 0x62 | 0x00 .. 0xFF | 0 .. 255 |
Character 0
| Packet type | Command | Packet number | Length | The length field determines the number of characters that follow in character 0 to character n. The resulting string is to be read as follows: | .. | BusNr names the bus to use. Within that bus, OperatorPos determines whose operator name is read. Each LoDi-Operator counts as one device. |
|---|---|---|---|---|---|---|
| 0x21 | 0x62 | 0x00 .. 0xFF |
<command name>|<colour of output 1>|..|<colour of output n>
The colours are defined as follows:
ws: white
- rt: red
- gn: green
- ge: yellow
- bl: blue
- The colours are assigned to the respective outputs. They mainly serve the display.
For some commands only the command name is returned, without additional colour information.
Example:
"DB BS|rt|gn" -> Deutsche Bahn block signal with the colours red and green
NodeConfigGet
Reads the configuration of every node from the LoDi-Shift-Commander.
GlobDelay
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x66 | 0x00 .. 0xFF |
| Packet type | Command | Packet number | AusgangHi | Count | AusgangLo | Delay | States | GlobDelay gives the duration of a command when delay is set to 0. The duration is read in steps of 20 ms, so a value of 10 means 200 ms. What it does exactly depends on the command. |
|---|---|---|---|---|---|---|---|---|
| 0x21 | 0x66 | 0x00 .. 0xFF | 0 .. 250 | 0 .. 255 | 0 .. 255 |
The count field gives the number of node records that follow. Each record is four bytes long. The index of the record determines the address of the node. Counting starts at 0 (the display adds 1).
AusgangHi and AusgangLo together give the first output the node addresses. The output number is calculated as follows:
Output = AusgangHi*256 + AusgangLo
The KommandoNr entry determines the command to be carried out. If the command is 0, there is no function at this address.
NodeNameGet
Reads the name of one or more nodes.
Nodes
| Packet type | Command | Packet number | Count | The count field says how many nodes are read. The nodes (addresses) may be given in any order. |
|---|---|---|---|---|
| 0x20 | 0x71 | 0x00 .. 0xFF | 0 .. 255 | 0 .. 255 |
| Packet type | Command | Packet number | Count | Length | Character 1 | .. | BusNr names the bus to use. Within that bus, OperatorPos determines whose operator name is read. Each LoDi-Operator counts as one device. |
|---|---|---|---|---|---|---|---|
| 0x21 | 0x71 | 0x00 .. 0xFF | 0 .. 255 | 0..16 |
The reply carries as many names as the count says, in the order of the request, each preceded by its length and followed by that many characters.
NodeStatusGet
Reads the current (permanently stored) state of every node from the LoDi-Shift-Commander.
The count field gives the number of status fields that follow. Only as many status fields are sent as the highest occupied address needs. Each status field corresponds to one address; counting starts at address 0.
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x6A | 0x00 .. 0xFF |
| Packet type | Command | Packet number | Count | Status |
|---|---|---|---|---|
| 0x21 | 0x6A | 0x00 .. 0xFF | 0 .. 255 | 0..15 |
NodeStatusSend
Sets the state of one or more nodes (addresses) — that is, throws turnouts, sets signals and so on.
State
| Packet type | Command | Packet number | Count | The count field says how many nodes are read. The nodes (addresses) may be given in any order. | The count field gives the number of node/state pairs that follow. |
|---|---|---|---|---|---|
| 0x20 | 0x6C | 0x00 .. 0xFF | 0 .. 255 | 0 .. 255 | 0 .. 15 |
| Packet type | Command | Packet number |
|---|---|---|
| 0x21 | 0x6C | 0x00 .. 0xFF |
Every node (every address) can take a state from 0 to 15.
Example for address 5: 0x20 0x6C 0xXX 0x01 0x05 0x01
The Shift-Commander then sends a confirmation: 0x21 0x6C 0xXX
Example for sending several addresses (1,2,3,4): 0x20 0x6C 0xXX 0x04 0x01 0x01 0x02 0x01 0x03 0x01 0x04 0x01
Notes:
Example for sending several addresses (1,2,3,4): 0x20 0x6C 0xXX 0x04 0x01 0x01 0x02 0x01 0x03 0x01 0x04 0x01
There is no need to delay sending turnout commands. The LoDi-Shift-Commander makes sure that not too many turnouts throw at once.
- The state that was set is stored permanently and is therefore known to the LoDi-Shift-Commander after the next switch-on.
- OutputsGet
Reads the status of every output.
AnzahlHigh
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x60 | 0x00 .. 0xFF |
| Packet type | Command | Packet number | AnzahlLow | The fields AnzahlHigh and AnzahlLow together give the number of output states that follow. | The count field gives the number of node/state pairs that follow. |
|---|---|---|---|---|---|
| 0x21 | 0x60 | 0x00 .. 0xFF | 0 .. 255 |
Count = AnzahlHigh*256 + AnzahlLow
How many outputs follow depends on the setting of bus 2. If both buses are set to light bus, 192 output states are transmitted. If bus 2 is set to switching bus, 480 outputs are transmitted.
Bus 1 starts at the first byte and ends at the 96th. Bus 2 starts at the 100th byte.
The state field holds the internal output state. It is to be read as follows:
Value <= 100: output is on.
- Value between 100 and 164: output is dimmed.
- Value >= 164: output is off.
- Room lighting control
The room lighting control is in principle just another LoDi-Operator, only with a few extra functions. The LoDi-Operator 4-C-LED can be switched with NodeStatusSend in exactly the same way.
The states are assigned as follows:
0: lighting off
- 1: light curve 1
- 2: light curve 2
- 3: light curve 3
- 8: flash
- 9: double flash
- 10: random flashing
- 11: passing clouds
- The LoDi-Shift-Commander simulates a 24-hour day. The simulated time is transmitted to every LoDi-Operator 4-C-LED at regular intervals. The operators are also able to keep counting the time themselves without that synchronisation.
TimeSpeedSet
Sets the speed at which time passes, as a multiple of normal time.
Factor
| Packet type | Command | Packet number | The factor field gives the time acceleration as a multiple of normal time. A value of 0 stops time. |
|---|---|---|---|
| 0x20 | 0x76 | 0x00 .. 0xFF | 0 .. 250 |
| Packet type | Command | Packet number |
|---|---|---|
| 0x21 | 0x76 | 0x00 .. 0xFF |
At a value of 120, an hour is only 30 seconds long.
TimeGet
Reads the current simulated time.
ZeitHigh
| Packet type | Command | Packet number |
|---|---|---|
| 0x20 | 0x78 | 0x00 .. 0xFF |
| Packet type | Command | Packet number | ZeitLow | The current time is counted in steps of 2 seconds. It is calculated as follows: |
|---|---|---|---|---|
| 0x21 | 0x78 | 0x00 .. 0xFF |
Time = ZeitHigh256 + ZeitLow*
An hour is 1800 time units long. The highest value for the time is 43199.
A time of 36000 therefore corresponds to 20:00.
TimeSet
Sets the current simulated time.
LoDi-Shift-Commander API Service
| Packet type | Command | Packet number | ZeitLow | The current time is counted in steps of 2 seconds. It is calculated as follows: |
|---|---|---|---|---|
| 0x20 | 0x77 | 0x00 .. 0xFF |
| Packet type | Command | Packet number |
|---|---|---|
| 0x21 | 0x77 | 0x00 .. 0xFF |
Time = ZeitHigh256 + ZeitLow*
An hour is 1800 time units long. The highest value for the time is 43199.
