Sniff (Telemetry)
Our MDB devices have a sniffing method which allows to have a detailed overview of what is happening in the MDB bus.
To start the sniffer instance just issue the following command:
X,1
Answer:
- x,ACK
The device is now in sniffing mode.
Every line logged by the sniffer has the following structure:
x,aa,tttttttttt,yy,data
Where:
- x - message was sent from sniffer instance
- aa - the block status (two character hex), where the first hex dight (0x80 or 0x00) identifies if message was sent by master (0x00) or slave (0x80), and lower bits have error information (if any, should be 0 normally, but for further reference, please check the error codes section below).
- tttttttttt - 10-digit timestamp in 0.1ms resolution for when the block was received
- yy - command code of the device to which the message is sent (if sent from master)
- data - the data bytes or just ACK
If you place an MDB-USB sniffing a bus where a VMC and a standard cashless peripheral are connected to, the sniffer will log something which looks like the following:
We removed some polls to make the output below a bit shorter and therefore, the timestamps may not be the exact ones that were logged.
What follows after the "#" is a comment is only a comment to help you understand the example. It will not appear in the captures.
X,1
x,ACK
x,00,0006493742,10, # Master (VMC) is turned ON and starts polling
x,00,0006494836,10,
x,00,0006495930,10,
x,00,0006497026,10,
x,00,0006526578,10,
x,00,0006527672,10,
x,80,0006527730,ACK # Cashless Slave (peripheral) is turned ON and starts answering polls
x,00,0006528766,12,
x,80,0006528824,00
x,00,0006528848,ACK
x,00,0006529862,11,0003000000
x,80,0006529978,ACK
x,00,0006530956,12,
x,80,0006531012,0103175601021e00
x,00,0006531118,ACK
x,00,0006532052,11,01ffff0000
x,80,0006532168,ACK
x,00,0006533146,17,005142584d444220496e7465726663653030303030303030303030303130
x,80,0006533554,ACK
x,00,0006534238,12,
x,80,0006534296,09514258333533343336353430363433514942495858204d44423032340300000021
x,00,0006534706,ACK
x,00,0006535336,17,0400000020
x,80,0006535450,ACK
x,00,0006536428,12,
x,80,0006536486,ACK
x,00,0006569264,12,
x,80,0006569322,ACK
x,00,0006570358,12,
x,80,0006570416,ACK
x,00,0006571454,14,01 # VMC enables the cashless slave (peripheral)
x,80,0006571524,ACK
x,00,0006572548,12,
x,80,0006572604,ACK
x,00,0006573642,12,
x,80,0006573700,ACK
x,00,0006574736,12,
x,80,0006574794,ACK
x,00,0006575830,12,
x,80,0006575888,ACK
x,00,0006617422,12,
x,80,0006617480,ACK
x,00,0006618520,13,0000640002 # VMC makes a vending request
x,80,0006618634,ACK
x,00,0006619612,12,
x,80,0006619670,ACK
x,00,0006620706,12,
x,80,0006620764,ACK
x,00,0006621800,12,
x,00,0006663392,12,
x,80,0006663450,050064 # Cashless Slave accepts Vending request, providing credit
x,00,0006663498,ACK
x,00,0006664488,12,
x,80,0006664544,ACK
x,00,0006665582,12,
x,80,0006665640,ACK
x,00,0006666676,12,
x,80,0006666734,ACK
x,00,0006667772,12,
x,00,0006692946,12,
x,80,0006693002,ACK
x,00,0006694042,13,020001 # Master (VMC) finishes the vending cycle successfully
x,80,0006694134,ACK
x,00,0006695136,13,04 # Master enables the cashless slave --> ready for a new cycle
x,80,0006695206,ACK
x,00,0006696228,12,
x,80,0006696286,07
x,80,0006702854,ACK
X,0
The messages on the ports are independently received, and when they are 'ready' (complete) they are put into their respective processes for handling. The timestamp is taken when the message starts, so it is the correct reference for the message, when it gets into the usb transmit queue is not guaranteed. The messages won't coming 50ms later of course but few ms can happen - sorting by timestamp guarantees the messages are in the right sequence.
Bus error detection
Sometimes, MDB Equipments, either the Peripherals, or the VMCs do not follow the MDB Specification entirely, either by being slightly off the timing constraints, or by setting wrong bits on the checksum bytes. Sometimes this leads to equipments which are incompatible with other equipments from different vendors. When that happens, if we put up an MDB Device (Pi Hat or MDB USB) adn look at the sniffing, we will be able to observe some messages as shown below:
Errors detected on the Peripheral Direction
X,02,<timestamp>,<data>,<checksum>
Y,S,<error_info>
What each field means:
- timestamp: 10-digit timestamp in 0.1ms resolution for when the block was received
- data: The bytes received in that packet.
- checksum: The checksum of the packet just received.
- error_info: From the received bytes, which sort of error was found in each one.
x,02,0009446584,12,12
Y,S,100
In the example above, the error indicates that the first 12 was received as data, the second 12 received as checksum, and there was an error on the 9th bit (not visible in the sniffer data) which invalidated the checksum correct reception. This 9th bit is called a mode bit.
Errors detected in the Master direction
X,82,<timestamp>,<data>,<checksum>
Y,M,<error_info>
What each field means:
- timestamp: 10-digit timestamp in 0.1ms resolution for when the block was received
- data: The bytes received in that packet.
- checksum: The checksum of the packet just received.
- error_info: From the received bytes, which sort of error was found in each one.
x,82,0836889476,0001083800000100
Y,M,222222221
In the example above, this error means that on the 8 bytes received, there was a checksum error on all the bytes, and also a mode bit error on this data "packet".
x,82,0001919148,
Y,M,7
In the example above, there was a timeout, checksum and bit mor error. 7 it's bits added: 1 + 2 + 4
Error Types shown on sniffer
Error | Code | Description |
---|---|---|
1 | Bit Mode Error | On MDB, each data byte is composed by a start bit, 8 data bits, followed by a mode bit, and a stop bit. The mode bit, when sent from VMC to peripherals, to differentiate between address and data bytes. When this bit is set to 1 , the packet is an address byte, when it is set to 0, the packet is a data byte. |
2 | Checksum error | According to MDB specification, any communication data block (excluding ACK and NACK), must be followed by a checksum byte. This byte consists of the addition (sum) of all the bytes within the data block, with the carry out bit ignored. If this value is incorrect, then this error code will be shown in the sniffer console. |
4 | Timeout error | This error code will be shown any time the MDB timing constraints are not respected. For further information, please refer to sectiomn 3.2 of the MDB Specification version 4.3. |
8 | Framing error | This error occurs when the MDB framing of the received byte is not according to the definition in the MDB Specification (each data byte must have 1 start bit, 8 data bits, 1 mode bit and 1 stop bit). |