Reader Communication Protocol Developer's Guide
Protocol Introduction
   
The serial communication between a computer (host) and the reader is based on a synchronized command-response/master-slave mechanism. Whenever the host sends a message to the reader, it cannot send another message until after it receives a response.
   
Note: The total number of bytes of the communication data must not exceed 255.

Host-to-Reader Communication Framework

Host-to-Reader Communication is packetized according to the following diagram. The reader can only accept one command at a time, and commands are executed serially, so the host waits for a reader-to-host response before issuing another host-to-reader command packet.
 
  
Header Data Length Command Code Data CRC-16
1 byte, must be 0XFF 1 byte, the number of bytes of the Data field 1 byte Data block, with high byte in front 2-byte cyclic redundancy code, with the high byte in front

Reader-to-Host Communication Framework

The following diagram defines the format of the generic Response Packet sent from the reader to the host.
   
Header Data Length Command Code Status Code Data CRC-16
1 byte, must be 0xFF 1 byte, the number of bytes of the Data field 1 byte 2 bytes, status code, 0 means the operation is successful, non-zero value means operation failure. Data block, with high byte in front 2-byte cyclic redundancy code, with the high byte in front
 
C Language Example of CRC-16
  
#define MSG_CRC_INIT		    0xFFFF
#define MSG_CCITT_CRC_POLY		0x1021
void CRC_calcCrc8(uint16 *crcReg, uint16 poly, uint16 u8Data)
{
	uint16 i;
	uint16 xorFlag;
	uint16 bit;
	uint16 dcdBitMask = 0x80;
	for(i=0; i<8; i++)
	{
		xorFlag = *crcReg & 0x8000;
		*crcReg <<= 1;
		bit = ((u8Data & dcdBitMask) == dcdBitMask);
		*crcReg |= bit;
		if(xorFlag)
		{
			*crcReg = *crcReg ^ poly;
		}
		dcdBitMask >>= 1;	
	}
}
uint16 CalcCRC(uint8 *msgbuf,uint8 msglen)
{
	uint16 calcCrc = MSG_CRC_INIT;
	uint8  i;
	for (i = 1; i < msglen; ++i)
		CRC_calcCrc8(&calcCrc, MSG_CCITT_CRC_POLY, msgbuf[i]);
	return calcCrc;
}
    
The return data obtained by calling the function uint16 CalcCRC(uint8 *msgbuf, uint8 msglen) is CRC-16, where the parameter *msgbuf is the communication protocol string data except CRC-16, and msglen is the total number of bytes of all communication protocol string data except CRC-16.

Command Classification and Workflow

Command Classification
Because there are many commands, in order to introduce each command conveniently, the commands are divided into four categories according to their functions: Bootloader Commands, Tag Inventory Commands, Tag Access Commands, Setting Commands, Getting Commands.
 
Command Set Table
Command Set Name Description
Bootloader Commands Any command that can be executed while the reader is in the bootloader phase is called Bootloader Commands.
Tag Inventory Commands Commands related to inventory operation
Tag Access Commands Commands related to Tag Access operations
Setting Commands  Used to set configurable values in the firmware
Getting Commands Used to get parameters, options and working state from the reader
 
In addition, some commands can be executed while the reader is in the Bootloader and App firmware phases. When we describe each command in detail, it will indicate whether the command has the Bootloader Command and App Firmware Command properties.
 
Command Workflow
The Bootloader is automatically started upon power up. All tag operations of the reader can only be used in the App Firmware layer, so you must first execute the Boot Firmware command(0x04) to let the reader enter the App firmware layer, and then you can execute Setting Commands, Getting Commands, Tag Inventory Commands, Tag Access Commands.

Special Note

The function and usage of each command will be described in detail in later chapters. When introducing each command, it will follow the following sequence:
 
Command overview
|
Command Attribute
|
Host to Reader(format of Data field)
|
Reader to Host(format of Data field)
|
Example
|
Remark
 
For a command, if the host-to-reader command does not contain a Data field, there is no Host to Reader section. If the data field is not included in the reader-to-host command, there is no Reader to Host section. Similarly, in the Example section, there is no relevant sub-example if the command does not contain a Data field.
 
Multibyte integers in commands is in MSB byte order.