Xpressnet™ - Command Extensions for BiDi

    Besides the standard xpressnet commands OpenDCC supports some command extensions. One of theses extensions is a command tunnel for handheld controllers from the xpressnet side to the PC side.
    An other extension is the transfer of BiDi messages over Xpressnet.

    BiDi could theoretically occur after every DCC message (every 6-12ms), thus it is necessary that BiDi dectectors obey the available bandwidth on Xpressnet and avoid redundant messages. Messages which are bundled with occupancy detecting should be debounced inside the detector and should have a state change not more othen than every 2s.

    Detectors are typically either global or local (assigned to a certain track). This assignment is mapped to the SID (=sender ID). Local assigned detectors typically do the occupancy detection as well, but needn't. One Xpressnet device normally represents more than on detector, also the use of 'hubs', which open a new xpressnet universe and bundles this local xpressnet to one upstream device is intended.
    The global detector should have the SID 0.
    All BiDi messages recide in the 0x7* range, the second byte is used as Sub-ID.
    Commandlist for BiDi Xpressnet Message (Extension)
    Commands from the Client to the Host
      OP-Code Ver. Operation
    0x73 0xF0 SID_H SID_L [XOR]   BiDi (or occupancy) detector with the logical addr SID (=sender ID) is idle. This message shall be issued once if the detector changes from occupied to idle. The occupancy detector should not issue occupancy messages more often than 3s.
    0x73 0xF1 SID_H SID_L [XOR]   BiDi (or occupancy) detector with the logical addr SID (=sender ID) is occupied. This message shall be issued once if the detector changes from idle to occupied. This message shall also be issued once if the detector changes from 'addr detected' to occupied only. The occupancy detector should not issue occupancy messages more often than 2s.
    0x75 0xF2 SID_H SID_L D+AddrH AddrL [XOR]   BiDi detector with the logical addr SID (=sender ID) has detected a locomotive with the address Addr. D is the MSB of the AddrH byte and denotes the direction. D=0 indicates that the locomotive has it's right side is connected to the detector, D=1 denotes the left side is connected to the detector. This message can replace the normal occupancy message.
    0x7x 0xFE SID_H SID_L DAT0 [DAT1] [DAT2] ... [DAT7] [XOR]   Occupancy summary: starting from logical addr SID (=sender ID) there may be up to 64 occupancy bits in this message. LSB of DAT0 is occupancy at SID, MSB of DAT0 is occupancy at SID+7. (1 means occupied, 0 means idle). The SID in this command must be a multiple of 8.
    0x75 0xFF SID1_H SID1_L SID2_H SID2_L [XOR]   Request a scan message of the command station in the given range. The command station will issue a broadcast (see below) with this range. This message shall be issued after 3s, if a client powered up and has not yet goten a 'clear changes' message. This could happen, if a client is plugged into an running xpressnet.
    0x74 0xE0 AddrH AddrL SPEED [XOR]   Locomotive with the address Addr anounces its real speed. Speedbyte is coded according to the BiDi-Standard. A detector shall issue this package only if a speed change is detected.
    0x76 0xE1 AddrH AddrL CV_H CV_L DAT [XOR]   A BiDi detector has detected a BiDi PoM command.
    The locomotive or accessory decodcer with the address Addr responds to a configuration variable CV access with the content DAT. CV is annotated with a range of 0 .. 1023 (!). Addr (consisting of AddrH and AddrL) is coded as follows:
    Bit 15,14 Bits 13...0
    00 Mobile Decoder, driving forward
    10 Mobile Decoder, driving revers
    01 Accessory-Adress
    11 Extended Accessory
    0x78 0xD0+BiDi-ID AddrH AddrL Data[1], ... Data[n] [XOR]   This is a raw message mirroring the BiDi message on the track 1:1 (reserved for debugging / future use)
     
    Messages from the Host to Client
    0x75 0xFF SID1_H SID1_L SID2_H SID2_L [XOR]   This is a broadcast: BiDi detectors with a SID between SID1 and SID2 should report their actual state. This broadcast is typically issued after power up to collect all states of the BiDi detectors. Detectors should clear any 'already reported' flag and repeat the report. 'CLEAR CHANGES'
    0x78 0xE1 SID_H SID_L AddrH AddrL CV_H CV_L DAT [XOR]   BiDi detector with the logical addr SID (=sender ID) has detected a BiDi PoM command.
    The locomotive or accessory decodcer with the address Addr responds to a configuration variable CV access with the content DAT. CV is annotated with a range of 0 .. 1023. Addr (consisting of AddrH and AddrL) is coded as follows: Accessory-Adresse Extended Accessory
    Bit 15,14 Bits 13...0
    00 Lokadresse, Fahrtrichtung vorwärts
    10 Lokadresse, Fahrtrichtung rückwärts
    01
    11
    This is sent as broadcast to all.
    There are still some commands to define:
      - query of actual speed and lok report in a sid
      - request rescan

PC-Interface

    Questions: should a pc interface push all BiDi messages to the PC (like a broadcast?); we need a message from a client, which rescans the BiDi detectors