MDB Communication Protocal: Difference between revisions

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
== Introduction ==
== Introduction ==
This manual describes the serial communication protocol between Q3v and MDB Interface Board, which will be short as "MIB" in follow content.
This doc defines a serial communication protocol between the application running on Q3v and MDB Vending machine.
The basic baud rate of serial port is set as 115200.
Overall,the q3v low level hardware will forwarding the mdb request from the vendg machine,and forward to the Android application as serial data,
As the Q3 Pos could be receive command from MIB as a slave, and also could send command to MIB as a master (e.g., send “begin session” command to inform the MDB VMC it’s ready for pay), a mode byte was added in serial frame to show if a command is slave response or a master request.
When the app tackle all the request serial data, the q3v pos could be regarded as a MDB cashless slave device.
The request command always anticipates a response command except the checksum is wrong, or the incorrect serial format, in another word, the slave will use silence as a NAK.
And also,the application could request some config command, e.g. "get firmware version",Therefore the protocol is 2-way-direction,
and there is a mode byte indicates the direction.


 
== Serial Protocol Packet Definition ==
== Protocol Packet Definition ==
=== Serial Port parameters ===
=== Serial Port parameters ===
* Baud rate 115200
* Baud rate 115200
Line 18: Line 18:
* '''Length''' size: 1byte, the number bytes of mode, data, and checksum.
* '''Length''' size: 1byte, the number bytes of mode, data, and checksum.
* '''Mode''' size: 1, 0x00 means a master request packet, 0x01 means a slave response packet, other value is prohibited.
* '''Mode''' size: 1, 0x00 means a master request packet, 0x01 means a slave response packet, other value is prohibited.
* '''Data '''size: n bytes. The data could be raw MDB commands, such as SETUP, VEND(please refer the Multi-Drop Bus Protocol V4.3 for detials).<br>
* '''Data '''size: n bytes. The data could be raw MDB commands, such as SETUP, VEND(please refer the <Multi-Drop Bus Protocol V4.3>for detials).<br>
Or the MIB control commands, such as GET VERSION, SET PARAMETER.
Or the MIB control commands, such as GET VERSION, SET PARAMETER.
* '''Checksum''' size: 1byte, using LRC algorithm, input data were "mode, data"
* '''Checksum''' size: 1byte, using LRC algorithm, input data were "mode, data"
Line 24: Line 24:


== MDB Forwarding mechanism ==
== MDB Forwarding mechanism ==
MIB will forward all the MDB cashless device commands (MDB spec section 7), except VMC request Poll.<br>
The q3v will forward all the MDB cashless device commands,except the the POLL command,the request and response procedure can be described in following steps:
 
# VMC Send MDB request to q3v
When the MIB receive the VMC request, it removes the MDB mode bit, fill into serial packet data area, and transmit to serial port. In the opposite direction, the MIB receive the response, it unwraps the packet, and adding mode bit to the tail bytes, sending to the VMC, wait for the acknowledge.<br>
# q3v receive the step 1 data,get rid the 9th mdb mode bit,fill into serial packet '''data''' part,sending the serial packet to application.
# The application will listen to to the serial port all the time,after receiving step 2 serial data,unwrap it to mdb request data,handle it, and wrap its mdb response into serial packet, sending to q3v
# q3v get the step 3 data, unwrap to mdb response data, add mdb mode bit,forwarding to mdb master.
# mdb master handle the mdb slave response


Taking the RESET for example, the transfer steps can be described as below.
Taking the '''RESET''' for example
# ''VMC -> MIB: 0x110 0x10''
# ''VMC -> q3v: 0x110 0x10''
# ''MIB -> Q3V: 0x09 0x04 0x00 0x10 0x10 0xE0 0x0D''
# ''q3v -> app: 0x09 0x04 0x00 0x10 0x10 0xE0 0x0D''
# ''app -> q3v: 0x09 0x04 0x01 0x00 0x00 0xFF 0x0D''
# ''VMC -> MIB: 0x00 0x100''
# ''VMC -> MIB: 0x00 0x100''
# ''VMC -> MIB: 0x00''
# ''VMC -> MIB: 0x00''


== A typical MDB transacrion flow ==
== A typical MDB transacrion flow ==
[[File:Mdb flow chart.png|thumb]]
[[File:Mdb flow chart.png|frame|center|MDB transacrion flow]]
 
== Protocol command definition ==

Revision as of 10:24, 22 July 2022

Introduction

This doc defines a serial communication protocol between the application running on Q3v and MDB Vending machine. Overall,the q3v low level hardware will forwarding the mdb request from the vendg machine,and forward to the Android application as serial data, When the app tackle all the request serial data, the q3v pos could be regarded as a MDB cashless slave device. And also,the application could request some config command, e.g. "get firmware version",Therefore the protocol is 2-way-direction, and there is a mode byte indicates the direction.

Serial Protocol Packet Definition

Serial Port parameters

  • Baud rate 115200
  • 8bit, 1 stop bit, and no parity

Packet format

Start code Length mode Data Checksum End code
  • Start code size 1 byte, always be 0x09
  • Length size: 1byte, the number bytes of mode, data, and checksum.
  • Mode size: 1, 0x00 means a master request packet, 0x01 means a slave response packet, other value is prohibited.
  • Data size: n bytes. The data could be raw MDB commands, such as SETUP, VEND(please refer the <Multi-Drop Bus Protocol V4.3>for detials).

Or the MIB control commands, such as GET VERSION, SET PARAMETER.

  • Checksum size: 1byte, using LRC algorithm, input data were "mode, data"


MDB Forwarding mechanism

The q3v will forward all the MDB cashless device commands,except the the POLL command,the request and response procedure can be described in following steps:

  1. VMC Send MDB request to q3v
  2. q3v receive the step 1 data,get rid the 9th mdb mode bit,fill into serial packet data part,sending the serial packet to application.
  3. The application will listen to to the serial port all the time,after receiving step 2 serial data,unwrap it to mdb request data,handle it, and wrap its mdb response into serial packet, sending to q3v
  4. q3v get the step 3 data, unwrap to mdb response data, add mdb mode bit,forwarding to mdb master.
  5. mdb master handle the mdb slave response

Taking the RESET for example

  1. VMC -> q3v: 0x110 0x10
  2. q3v -> app: 0x09 0x04 0x00 0x10 0x10 0xE0 0x0D
  3. app -> q3v: 0x09 0x04 0x01 0x00 0x00 0xFF 0x0D
  4. VMC -> MIB: 0x00 0x100
  5. VMC -> MIB: 0x00


A typical MDB transacrion flow

MDB transacrion flow

Protocol command definition