Communication Protocol of CDM6240 Cash Dispenser
Communication Protocol of CDM6240 Cash Dispenser
for CDM6240
No.:
Version: v1.0
Issued on:
Document History
Personnel
No. and name Version Date Revision description
involved
Communication Created and issued for the Prepared by:
V1.0 July 14, 2013
Protocol for CDM6240 first time Approved by:
2. Copyright Statement
All rights reserved by GRGBanking. Without its permission, any third party shall not copy or
publish this document. Without prior notification of the user, GRGBanking shall have the right to
modify and supplement this document at any time. Therefore, the information contained in this
document may not be the latest. If you want to get more precise information, please contact your
supplier.
3. Version number
Version number consists of:
When a new function is added or defects are fixed, version number shall be upgraded, and upgrade
of version number shall be compatible with previous versions.
3. Upgrade of Build number:
When small defects and errors are fixed, it is necessary to upgrade the Build number
1. Communication protocol
Communication mode: asynchronous communication
Baud rate: 9600 Baud/s
Data structure: 10 bits, one start bit + 8 data bits + 1 end bit, no odd-even check.
Maximum transmission bytes: 2048Byte
Handshake: Non-handshake mode
The hardware non-handshake mode is supported between the cash dispenser and a PC. DTR and DSR are
short-circuited, and RTS and CTS are short-circuited at each communication terminal, and only three signal lines
of the RS232 interface (i.e. TXD, RXD and GND) are used. The connection method is as follows:
PC PC端
end 机芯端end
Dispenser
1 DCD 1 DCD
2 RXD 2 RXD
3 TXD 3 TXD
4 DTR 4 DTR
5 SG 5 SG
6 DSR 6 DSR
7 RTS 7 RTS
8 CTS 8 CTS
9 NC 9 NC
不支持硬件握手形式
The hardware handshake mode is not supported.
Length range
Notes:
LENGTH: 2 bytes
Command frame: data length in DATA area, low bytes followed by high bytes, range [0 - 1000].
Response frame: data length in DATA area: -12 (excluding the first 12-byte data in DATA area),
high bytes followed by low bytes, range [0 - 1000].
DATA: command and response frame data.
CRC: 2-byte check code, high bytes followed by low bytes.
The total length of data frame is not more than 1024 bytes.
3. Communication flow
Communication principle
Cyclical Redundancy Check (CRC) can implement error detecting based on the principle of
division method and remainder. During actual application, the transmitter installation calculates
CRC value and sends it to the receiving device together with data; and the receiving device
recalculates CRC according to the received data and compares it with the received CRC. Two
different CRC values indicate wrong data communication.
The check algorithm of medium program is based on CRC-CCITT. CRC-CCITT code is used to
transmit 8-bit character in European countries and consists of two bytes. CRC-CCITT polynomial is
X16+X12+X5+1.
The implementation method of CRC-CCITT code includes a bit algorithm, a half-byte algorithm
and a byte algorithm. In case of high speed transmission, the bit algorithm is inefficient and CRC
remains lookup table of the byte algorithm occupies large program memory. Thus, the half-byte
algorithm is used to calculate CRC of data packet according to look-up table.
Main idea of the algorithm is as follows: data circulation moves four digits leftwards, then new
CRC high byte value can be obtained by looking up the high type remains lookup table according to
the obtained CRC high byte plus the four digits, and new CRC low byte value can be obtained by
looking up the low type remains lookup table according to the obtained CRC low byte plus the four
digits. After all data circulation is removed from CRC, the obtained CRC is the final value.
The algorithm is as follows: (Refer to the appendix in this document for specific realization
method of functions)
The value among CRC is the first two bytes of data (if data have one byte only, assign 0 to low byte
of CRC).
The calculation of MAC check code can be implemented by calling the function iGenerateMac() in
the GRGCDMMAC.dll file provided by the supplier. Refer to appendix of this document for
specific methods of using the function.
Second byte (bit7-0): NULL NULL NULL NULL PES TES RFS NULL
Third byte (bit7-0): NULL LOCK6 LOCK5 LOCK4 LOCK3 LOCK2 LOCK1 RVES
Fourth byte (bit7-0): NULL NULL NULL NULL NULL NULL NULL NULL
Fifth byte (bit7-0): NULL CLLS6 CLLS5 CLLS4 CLLS3 CLLS2 CLLS1 NULL
Sixth byte (bit7-0): CIDS2d CIDS2c CIDS2b CIDS2a CIDS1d CIDS1c CIDS1b CIDS1a
Seventh byte (bit7-0): CIDS4d CIDS4c CIDS4b CIDS4a CIDS3d CIDS3c CIDS3b CIDS3a
Eighth byte (bit7-0): CIDS6d CIDS6c CIDS6b CIDS6a CIDS5d CIDS5c CIDS5b CIDS5a
TES is the dispenser exit sensor, RFS is the retract entrance sensor, and SLS is the thickness
front-sensor,
PES is the bundle dispenser exit sensor, FCS(n) is the cassette exit sensor;
All the sensors are opposite-type transport sensors, 0 indicates that the sensors are not blocked, and
1 indicates that notes are blocked.
Command frame:
C TTTTT
C — Command code, 0x49, ‘I’
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE J O NIPPP NIPPP NIPPP NIPPP NIPPP NIPPP
C — Response code, 0x49, 'I', the same as the command code
S — Sensor status, 8 bytes in total
R — Response result: ’e’: command execution error; ’s’: correct command execution; ’w’:
command execution warning
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning
J — Number of rejected notes
O — Number of notes delivered to the presenter
N — Hopper number
I — Magnetic ID of cassette
P — Cassette parameters, i.e., note width, length and thickness
Notes:
Each NIPPP corresponds to a piece of cassette information;
The hopper number is fixed from 1 to 6 and cannot be modified;
The magnetic ID of cassette: from 0x01 to 0x0F;
Note width: from 60 to 82;
Note length: from 120 to 165;
Note thickness: from 60 to 180.
Command execution action:
Check whether the set values of note parameters are correct;
Check whether the diverter can move correctly, and finally remain the diverter in an upward
position;
Check the status of the reject vault and cassette;
Command frame:
C TTTTT
C — Command code, 0x53, 'S'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE PPPPPPPPPP
C — Response code, 0x53, 'S', the same as the command code
Command frame:
C TTTTT
C — Command code, 0x52, 'R'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE NIPPP NIPPP NIPPP NIPPP NIPPP NIPPP
C — Response code, 0x52, 'R', the same as the command code
Command frame:
C TTTTT NPPP NPPP NPPP NPPP NPPP NPPP
C — Command code, 0x50, 'P'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
N — Hopper number
P — Cassette parameters, i.e., width, length and thickness
Response frame:
C SSSSSSSS R EE
C — Response code, 0x50, 'P', the same as the command code
S — Sensor status, 8 bytes in total
R — Response result: ’e’: command execution error; ’s’: correct command execution; ’w’:
command execution warning
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning
Note:
Each NPPP corresponds to a piece of cassette information;
The hopper number is fixed from 1 to 6 and cannot be modified;
Note width: from 60 to 82;
Note length: from 120 to 165;
Note thickness: from 60 to 180;
The cassette parameters can be set at any time according to the configuration of the cassette in each
hopper.
Command function description:
Check the effectiveness of the set parameters;
Store effective parameters in EEPROM;
Display error code on the Nixie tube in case of any error.
Timeout:
The recommended timeout is 5s.
Command frame:
C TTTTT Y ID ID ID ID ID ID MMMM
C — Command code, 0x44, 'D'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Y — Fixed value: 0x55
I — Hopper number, fix from 1 to 6 and cannot be modified
D — Number of notes dispensed form cassettes; if D is 0, no notes are dispensed form cassettes.
M — MAC check, 4 bytes in total, 4-byte MAC check code obtained by calling iGenerateMac()
function, a total of 19 bytes from C to D are involved in the calculation. Refer to the appendix for
specific calling method of functions.
Response frame:
C SSSSSSSS R EE D J Y IDJA IDJA IDJA IDJA IDJA IDJA MMMM
C — Response code, 0x44, 'D', the same as the command code
S — Sensor status, 8 bytes in total
R — Response result: ’e’: command execution error; ’s’: correct command execution; ’w’:
command execution warning
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning
D — The first D is the total number of notes rejected, and the following 6 bytes are the number of
notes rejected by each cassette
J — The first J is the total number of notes rejected, and the following 6 bytes are the number of
notes rejected by each cassette
Y — Fixed value: 0x55
I — Hopper of the cassette
A — Corrected value, it is suspected to be the number of overlapped notes
M — MAC check, 4 bytes in total, 4-byte MAC check code obtained by calling iGenerateMac()
function, a total of 27 bytes from D to A are involved in the calculation.
Note: The maximum number of notes dispensed is 20.
Command execution action:
CDM self test, check to see if sensor and motor are normal;
Command frame:
C TTTTT
C — Command code, 0x76, 'v'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE VVVVVVV
C — Response code, 0x76, 'v', the same as the command code
S — Sensor status, 8 bytes in total
R — Response result: ’e’: command execution error; ’s’: correct command execution; ’w’:
command execution warning
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning
V — Version information
Note:
Version information (7 bytes in total) is in the form of vx.xbxx, the first, third and fifth bytes are
fixed at ‘v’‘.’‘b’.
Command function description:
Return the medium program version number;
Display error code on the Nixie tube in case of any error.
Timeout:
The recommended timeout is 3s.
Command frame:
C TTTTT
C — Command code, 0x43, 'C'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE J D
C — Response code, 0x43, 'C', the same as the command code
Note:
If invalid note and note jamming error exist in the sensor, clear notes through this command. In
order to prevent delivering out any invalid note, the notes cannot be cleared through this command
when invalid notes enter the TES or note jamming exists in the TES.
Timeout:
The recommended timeout is 30s.
Command frame:
C TTTTT
C — Command code, 0x46, 'F'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
Response frame:
C SSSSSSSS R EE J O
C — Response code, 0x46, 'F', the same as the command code
Command frame:
C TTTTT N S L DDDD...
C — Command code, 0x4D, 'M'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
N — Hopper number; 0: reject vault, 1-6: the corresponding hopper
S — Block address. See Appendix 3 “Storage structure of non-contact IC card”. It is recommended
to use the block address 0x0C
L — Data length, 1-16
D — Data, maximally 16 bytes
Response frame:
C SSSSSSSS R EE
C — Command code, 0x4D, 'M'
S — 8 bytes in total, sensor status
R — Response result: ’e’: command execution error; ’s’: correct command execution
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning, low bytes followed by high bytes
Command function description:
Directly write RFID data, RFID data can be written according to customer needs;
Display error code on the Nixie tube in case of any error.
Timeout:
The recommended timeout is 5s.
Command frame:
C TTTTT N S L
C — Command code, 0x4E, 'N'
T — Time, 5 bytes in total, i.e., “MM/DD/hh/mm/ss”
N — Hopper number; 0: reject vault; 1-6: the corresponding hopper
S — Block address. See Appendix 3 “Storage structure of non-contact IC card”. It is recommended
to use the block address 0x0C
L — Data length, 1-16
Response frame:
C SSSSSSSS R EE DDDD...
C — Command code, 0x4E, 'N'
S — 8 bytes in total, sensor status
R — Response result: ’e’: command execution error; ’s’: correct command execution
E — Error code presenting when the command is incorrectly executed and valid only when the
response result is error or warning, low bytes followed by high bytes
D — Data, maximally 16 bytes, the actual length is returned based on the length specified by the
command frame
Command function description:
Directly read RFID data, maximally 16 bytes;
Display error code on the Nixie tube in case of any error.
Timeout:
The recommended timeout is 5s.
Functional description: Calculate the CRC check value according to the input data.
Parameter description:
Parameter type Parameter name Input/output Description
char * p_pcData in Data to be checked
unsigned int p_uiLength in Input data length
Function return: Return check code, the type is word.
unsigned char j;
unsigned int i;
unsigned char kh,kl;
if(p_uiLength==0)
return(0);
kh=*p_pcData;
if(p_uiLength>1)
kl=*(p_pcData+1);
else
kl=0;
for(i=0;i<p_uiLength;i++)
{
kh=(byte)(kh*16);
kh=(byte)(kh+(kl/16));
kl=(byte)(kl*16);
if( (i+2)<p_uiLength )
kl=(byte)(kl + (*(p_pcData+i+2)/16));
kh=(byte)(kh^cst_H[j]);
kl=(byte)(kl^cst_L[j]);
j= (byte)(kh/16);
kh=(byte)(kh*16);
kh=(byte)(kh+(kl/16));
kl=(byte)(kl*16);
if( (i+2)<p_uiLength )
kl=(byte)(kl + (*(p_pcData+i+2)&0x0F));
kh=(byte)(kh^cst_H[j]);
kl=(byte)(kl^cst_L[j]);
}
return(word)(kh*256+kl);
}