Mattzobricks / MattzoControllers

MattzoController firmware
20 stars 10 forks source link

MTC4BT: Loco does not respond if multiple locos share the same Rocrail address #17

Open Mattzobricks opened 1 year ago

Mattzobricks commented 1 year ago

Loco does not respond if two locos share the same Rocrail address in the MTC4BT configuration.

Find my config file below. Please notice that locos EST1 and EST2 share the same Rocrail address.

{ "name": "MTC4BT", "espPins": [ { "pin": 2, "inverted": false, "attachedDevice": "light" } ], "fn": [ { "name": "status", "device": "espPin", "pin": 2 } ], "locos": [ { "address": 6051, "name": "ICE", "speedStep": 10, "brakeStep": 20, "bleHubs": [ { "type": "PU", "address": "90:84:2b:16:15:f8", "channels": [ { "channel": "A", "attachedDevice": "motor", "direction": "forward" }, { "channel": "B", "attachedDevice": "light", "direction": "forward" } ] }, { "type": "PU", "address": "90:84:2b:00:5d:bb", "channels": [ { "channel": "A", "attachedDevice": "motor", "direction": "forward" }, { "channel": "B", "attachedDevice": "light", "direction": "forward" } ] } ], "fn": [ { "name": "f1", "device": "bleHub", "address": "90:84:2b:16:15:f8", "channel": "B" }, { "name": "f2", "device": "bleHub", "address": "90:84:2b:00:5d:bb", "channel": "B" } ] }, { "address": 6197, "name": "EST1", "speedStep": 10, "brakeStep": 20, "bleHubs": [ { "type": "PU", "address": "90:84:2b:18:f2:52", "channels": [ { "channel": "A", "attachedDevice": "motor", "direction": "forward" } ] } ] }, { "address": 6197, "name": "EST2", "speedStep": 10, "brakeStep": 20, "bleHubs": [ { "type": "PU", "address": "90:84:2b:18:f7:75", "channels": [ { "channel": "A", "attachedDevice": "motor", "direction": "forward" } ] } ] }, { "address": 727, "name": "SBrickTrain", "speedStep": 10, "brakeStep": 20, "bleHubs": [ { "type": "SBrick", "address": "58:8e:81:58:b2:00", "channels": [ { "channel": "D", "attachedDevice": "motor", "direction": "forward" }, { "channel": "B", "attachedDevice": "light", "direction": "forward" } ] } ] } ] }

Mattzobricks commented 1 year ago

Attention: does not just extend to motor related commands, but also to function commands.

raymondbrink commented 1 year ago

This is by design so currently not supported. Multiple locos with the same address would be a new feature. There might be special situations to consider.

Hilbert70 commented 1 year ago

It is possible to add, by adding an iterator variable. And changing getLocomotive(locoAddress) into getFirstLocomotive(locoAddress) and loop using the new function getNextLocomotive(locoAddress).

getFirstLocomotive(locoAddress) sets the iterator to the beginning of the vector and then calls getNextLocomotive(locoAddress) to get the first matching address.

Or alternatively: setStartLocomotive(locoAddress) sets the iterator to the beginning of the vector. And then in a while loop: while (loco = getLocomotive(locoAddress) ) { // do loco stuff }

The functions: HandleTrigger and HandleLc should be changed accordingly.

Mattzobricks commented 1 year ago

Ray is not going to implement the feature as discussed with Hilbert and Mattze; just add a comment in the specification that no two locos with the same address are allowed in the configuration.