EL-UHF-RC4 Protocol

Communication Protocol

EL-UHF-RC4 can communicate with external application through:

  • RS232
  • USB
  • TCP/IP depending on the reader interfaces.

Serial port communication parameter

115200 8N1:

  • Baud rate: 115200 bps
  • 8 data bit
  • 1 stop bit
  • Without parity check bit

Command

Command refers to the data packets sent by the external application to the EL-UHF-RC4 module.

HEADADDRCMDLENParamCHECK
1Byte1Byte2Bytes1Byte0~255Byte2Byte

Response

Response refers to the data packets returned by the module to the external application

HEADADDRCMDLENSTATUSParamCHECK
1Byte1Byte2Bytes1Byte1Byte0~254Byte2Byte

Data Frame Format

FieldLength
(Byte)
Description
HEAD1HEAD is always 0xCF,this byte is used for data frame synchronization.
ADDR1Reader address, ranges from 0x00 to 0xFE.

0xFF is a brodacast address.

Readers will response to command with 0xFF or ADDR that matches with its own address.

The default address of all readers is 0x00.
CMD2Command Code
LEN1Total length of STATUS and Data[] field in bytes, max length is 255 Bytes (0xFF).
STATUS1Execution status of the command.

Response contains STATUS field, while Command doesn’t.

0x00 indicates that the command was successfully executed.

Status list
Parameter0 - 255Parameter field, certain commands doesn’t use this field.
MSB-CRC161MSB of CRC16 calculated from HEAD to Data[].
LSB-CRC161
LSB of CRC16 calculated from HEAD to Data[].

Status List

STATUSError description
0x00Successful execution (this only means that the module successfully received the tag response data. If there is a tag execution status in the tag response, you should further judge whether the tag execution status is correct)
0x01The parameter value is wrong, out of range, or the module does not support the parameter value
0x02Command execution failed due to module internal error
0x03Reserved
0x12No tag found during inventory, or tag inventory has finished
0x14Tag response timeout
0x15Demodulation tag response error
0x16Protocol authentication failed
0x17Password error
0xFFNo more data

Status code returned by tag:

Operation status codeOperation statusDescription
0x81Other errorsUnknown error returned by label
0x82Storage overflowThe destination store does not exist
0x83Store lockWrite to the storage area locked as non writable, Perform or erase operation, and read the storage area locked as unreadable
0x84Insufficient powerThe tag does not have enough energy to complete the operation
0x85Unspecified errorUnknown error returned by label

CRC16 Calculation

CRC16 is calculated from HEAD to Data[].

#define PRESET_VALUE 0xFFFF
#define POLYNOMIAL  0x8408
 
unsigned int uiCrc16Cal(unsigned char const  * pucY, unsigned char ucX) {
    unsigned char ucI,ucJ;
	unsigned short int  uiCrcValue = PRESET_VALUE;
 
   	for(ucI = 0; ucI < ucX; ucI++) {
        uiCrcValue = uiCrcValue ^ *(pucY + ucI);
        for(ucJ = 0; ucJ < 8; ucJ++) {
            if(uiCrcValue & 0x0001) {
                uiCrcValue = (uiCrcValue >> 1) ^ POLYNOMIAL;
		   	} else {
		    	uiCrcValue = (uiCrcValue >> 1);
		   	}
		}
    }
    return uiCrcValue;
}

In Python:

def calculate_checksum(data: bytes) -> bytearray:
   value = 0xFFFF
   for d in data:
       value ^= d
       for ucJ in range(8):
           value = (value >> 1) ^ 0x8408 if value & 0x0001 else (value >> 1)
   crc_msb = value >> 0x08
   crc_lsb = value & 0xFF
   return bytearray([crc_msb, crc_lsb])
 
 
 
 
HEADER = 0xCF
BROADCAST_ADDRESS = 0xFF
INIT_DEVICE_COMMAND = bytearray([0x00, 0x50])
DATA = bytearray([])
DATA_LENGTH = len(DATA)  # 00
 
 
request_data = bytearray([HEADER, BROADCAST_ADDRESS])
request_data.extend(INIT_DEVICE_COMMAND)
request_data.extend(DATA)
request_data.extend(bytearray([DATA_LENGTH]))  # CF FF 00 50 00
 
 
checksum = calculate_checksum(request_data)  # 07 26
request_data.extend(checksum)
print(' '.join("{:02X}".format(d) for d in request_data))  # CF FF 00 50 00 07 26

Command list

Command NameCMDDescription
INVENTORY_ISO_CONTINUE0x0001Start tag inventory
INVENTORY_ISO_STOP0x0002Stop tag inventory
MODULE_INT0x0050Initialize the module
RESET0x0052Reset basic module settings to the default values.
SET_PWR0x0053Set RF power
SET_GET_NETWORK_SETTINGS0X005FSet/get module network settings
SET_GET_REMOTE_SETTINGS0x0064Set/get remote device settings
GET_DEVICEINFO0X0070Get the device/module version and SN
SET_BASIC_SETTINGS0x0071Set module basic settings
GET_BASIC_SETTINGS0x0072Get module basic settings
SET_GET_FILTER0x0073Controls filter settings
SET_GET_IO_SETTINGS0x0074Input/output IO settting
OPEN_CLOSE_RELAY0x0077Release/close relay

Inventory Commands

INVENTORY_ISO_CONTINUE

This command is the ISO 18000-6C Standard of multi-tag Inventory with anti-collision algorithm.

HEADADDRCMDLENReservedCRC16
0xCF0xFF0x00010x050x00000000000xF5B5

Command frame:

CFFF0001050000000000F5B5

Response:

HEADADDRCMDLENSTATUSInventoryParamCRC16
0xCF0x000x00011Byte1Byte2Byte

Status:

  • 0x00 - Inventory successful, Param will contain tag info
  • 0x01 - MemBank parameter is wrong, or length is inconsistent
  • 0x02 - Command execution failed due to module internal error
  • 0x12 - No tag found during inventory, or tag inventory has finished
  • 0x17 - Tag Info length exceeds maximum

InventoryParam

  • RSSI - 2Bytes
    • RSSI of the Tag ACK Response
    • Unit: 0.1dBm
    • Encoding: two’s complement format
    • 0xFE48 = -440 = -44 dBm
  • Antenna - 1Byte
    • Value: 0x01 for single antenna unit
  • Channel - 1Byte
  • Tag Info Length - 1Byte
    • Unit: Bytes
  • Tag Info - N Bytes
🔗

INVENTORY_ISO_STOP

Command:

HEADADDRCMDLENCRC16
0xCF0xFF0x00020x002Byte

Response:

HEADADDRCMDLENSTATUSCRC16
0xCF0x000x00020x011Byte2Byte

INVENTORY_ACTIVE

In active Work mode, the reader will always inventory and send this response as the result of the inventory:

HEADADDRCMDLENSTATUSInventoryParamCRC16
0xCF0x000x00011Byte1Byte2Byte

InventoryParam

  • RSSI - 2Bytes
    • RSSI of the Tag ACK Response
    • Unit: 0.1dBm
    • Encoding: two’s complement format
    • 0xFE48 = -440 = -44 dBm
  • Antenna - 1Byte
    • Value: 0x01 for single antenna unit
  • Channel - 1Byte
  • Tag Info Length - 1Byte
    • Unit: Bytes
  • Tag Info - N Bytes

Inventory Response Example

HEADADDRCMDLENSTATUSRSSIAntenna
0xCF0x000x00010x12000xFE480x01
OK-44 dBm
ChannelTag Info LengthTag InfoCRC16
0x000x0C0xE2806F1200000002215060940x7B78
12 Bytes

Setting Commands

MODULE_INT

Initialize the module. This command is used to confirm whether the module is online.

Command:

HEADADDRCMDLENCRC16
0xCF0xFF0x00500x002Byte

Response:

HEADADDRCMDLENSTATUSCRC16
0xCF0x000x00500x011Byte2Byte

Only STATUS 0x00 si valid.

RESET

Reset basic module settings to the default values.

Command:

HEADADDRCMDLENCRC16
0xCF0xFF0x00520x002Byte

Response:

HEADADDRCMDLENSTATUSCRC16
0xCF0x000x00520x011Byte2Byte

SET_PWR

Set RF power (0-30Bm).

Command:

HEADADDRCMDLENRF PowerResvCRC16
0xCF0xFF0x00530x021Byte0x002Byte

Response:

HEADADDRCMDLENSTATUSCRC16
0xCF0x000x00530x011Byte2Byte

SET_GET_NETWORK_SETTINGS

Set/get network parameters (Applicable to LAN)

  • Set/Get:
    • 0x01 = Set
    • 0x02 = Get

NetPara:

FieldByteDescription
IPAddr4IP address
192.168.1.1 = {0xC0, 0xA8 , 0x01, 0x01}
MacAddr6MAC address
00-08-DC-11-11-11 = {0x00, 0x08, 0xDC, 0x11, 0x11, 0x11}
Port2Listening port between 0 and 65536, default to 2022
NetMask4Netmask code, default to {0xFF, 0xFF, 0xFF, 0x00}
GateWay4Gateway, default to {0xC0, 0xA8, 0x01, 0x01}

Command:

HEADADDRCMDLENSet/GetNetParaCRC16
0xCF0xFF0x005F1Byte1Byte2Byte

Set response:

HEADADDRCMDLENSTATUSSet/GetCRC16
0xCF0x000x005F1Byte1Byte1Byte2Byte

Get response:

HEADADDRCMDLENSTATUSSet/GetNetParaCRC16
0xCF0x000x005F2+N1Byte1ByteN Byte2Byte

SET_GET_REMOTE_SETTINGS

Set/get remote network parameters, which is the device (PC, microcontroller, etc) that can receive the data sent from EL-UHF-RC4 Module.

  • Set/Get:
    • 0x01 = Set
    • 0x02 = Get

Netpara:

FieldByteDescription
Enable10 = Disabled
1 = Enabled
IPAddr4Remote IP address, 192.168.1.1 = {0xC0, 0xA8, 0x01, 0x01}
Port2Listening port, between 0 and 65536, default: 5000
Heartbeat1Heartbeat time (unit: 5 s)

Command:

HEADADDRCMDLENSet/GetNetParaCRC16
0xCF0xFF0x00641Byte1Byte2Byte

Set response:

HEADADDRCMDLENSTATUSSet/GetCRC16
0xCF0x000x00641Byte1Byte1Byte2Byte

Get response:

HEADADDRCMDLENSTATUSGet/SetNetParaCRC16
0xCF0x000x00642 + N1Byte1ByteN Byte2Byte

GET_DEVICEINFO

Get the device/module version and SN.

Command:

HEADADDRCMDLENCRC16
0xCF0xFF0x00700x002Byte

Response:

HEADADDRCMDLENSTATUS
0xCF0x000x00700x991Byte
HardVerFirmVerSN_codeReservedCRC16
32Bytes32Bytes12Bytes76Bytes2Byte

Field decription:

FieldByteDescription
HardVer32Module hardware version, in ASCII
FirmVer32Module firmware version, in ASCII
SNCode12Module serial number, in ASCII
Reserved76Reserved for future use

SET_BASIC_SETTINGS

Set module basic parameters.

Command:

HEADADDRCMDLENBASIC_SETCRC16
0xCF1Byte0x00711Byte25Bytes2Bytes
  • ADDR is the current module address that is being targetted by this command.

BASIC_SET Field

Total: 25Bytes:

🔗

Response:

HEADADDRCMDLENSTATUSCRC16
0xCF0xXX0x00710x011Byte2Byte
  • STATUS
    • 0x00 - Successful
    • 0x01 - Parameter error

GET_BASIC_SETTINGS

Get module basic settings.

Command:

HEADADDRCMDLENCRC16
0xCF0xFF0x00720x002Bytes

Response:

HEADADDRCMDLENSTATUSBASIC_SETCRC16
0xCF0xFF0x00720x1A1Byte25Bytes2Bytes

BASIC_SET Field

Total: 25Bytes:

🔗

SET_GET_FILTER

Controls the Tag filter settings, this device can filter the tags by data mask and/or access password

Command:

HEADADDRCMDLENParamCRC16
0xCF0xFF0x00730x1616Bytes2Bytes

Set response:

HEADADDRCMDLENSTATUSOptionCRC
0xCF0x000x00731Byte1Byte1Byte2Bytes

Get response:

HEADADDRCMDLENSTATUSParamCRC16
0xCF0xFF0x00730x171Byte16Bytes2Bytes

Param:

  • Command get or set - 1Byte
    • 0x01 - Set
    • 0x02 - Get
  • Enable access password filter - 1Byte
    • 0x00 - Disabled (Default)
    • 0x01 - Enabled
  • Access password filter - 4Bytes
    • Default: {0x00, 0x00, 0x00, 0x00}
  • Enable mask filter - 1Byte
    • 0x00 - Disabled (Default)
    • 0x01 - Enabled
  • Start address - 1 Byte
    • The starting address of the memory that is being matched with the mask
    • Default: 0x00
  • Mask length - 1Byte
    • Value range: [0, 12]
  • Mask data - 12Bytes
    • If mask is less than 12Bytes, fill the rest of the field with 0x00
    • Default: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
  • Filter setting - 1Byte
    • 0x00 - Access password or mask match (Default)
    • 0x01 - Access password and mask match

SET_GET_IO_SETTINGS

Command:

HEADADDRCMDLENParamCRC16
0xCF0xFF0x00740x1218Bytes2Bytes

Get Response:

HEADADDRCMDLENSTATUSParamCRC16
0xCF0xFF0x00740x131Byte18Bytes2Bytes

Param:

  • Command get or set - 1Byte
    • 0x01 - Set
    • 0x02 - Get
  • Automatic Relay Enabled - 1Byte
    • 0x00 - Disabled (Default)
    • 0x01 - Enabled
  • Automatic Relay Time - 1Byte
    • Unit: seconds
    • Default value: 0x03
  • Trigger Enabled - 1Byte
    • 0x00 - Disabled (Default)
    • 0x01 - Enabled
  • Trigger Level - 1Byte
    • 0x00 less than 0.5V triggers inventory
    • 0x01 higher than 2V triggers inventory (Default)
  • Buffer Enabled - 1Byte
    • 0x00 - Disabled (Default)
    • 0x01 - Enabled
  • Reserved - 12Bytes
    • [0x00] * 12

OPEN_CLOSE_RELAY

Manually open or close relay regardless of the automatic relay caused by inventory. It is recommended to use this while disabling the automatic relay setting in the SET_GET_IO_SETTINGS.

Command:

HEADADDRCMDLENOptionValidTimeCRC16
0xCF0xFF0x00771Byte1Byte1Byte2Byte
  • Option - 1Byte
    • 0x01 - Open
    • 0x02 - Close
  • ValidTime - 1Byte
    • Unit: seconds
    • 0x00 - The relay will always be set as the option selected
    • 0x01 - The relay will be set for 1 seconds
    • 0x02 - The relay will be set for 1 seconds
    • and so on..

Response:

HEADADDRCMDLENSTATUSOptionValidTimeCRC16
0xCF0x00
0x00771Byte1Byte1Byte1Byte2Byte

BASIC_SET

BASIC_SET is a 25 bytes of field to be used in SET_BASIC_SETTINGS and GET_BASIC_SETTINGS command.

BASIC_SET Field

Total: 25Bytes:

Addr

Addr is the new module IP Address, ranges from 0x00 to 0xFE.

Work mode

  • 0 - Answer mode
  • 1 - Active mode
  • 2 - Trigger mode

Interface

  • 0x80 - RS232
  • 0x20 - RJ45

Baud rate

  • 0 - 9600 bps
  • 1 - 19200 bps
  • 2 - 38400 bps
  • 3 - 57600 bps
  • 4 - 115200 bps

WG

  • 1 Byte of Wiegand parameter:
    • Bit7
      • 0 - close WG output
      • 1 - open WG output
    • Bit6
      • 0 - wg26
      • 1 - wg34
    • Bit5
      • 0 - low bit first
      • 1 - high bit first
    • Bit4 - Bit0
      • Reserved

RFID Freq

  • 8 Bytes of RFID Frequency parameter:

    • 1Byte - Region
      • 0x00 - User defined
      • 0x01 - US [902.75~927.25]
      • 0x02 - Korea [917.1~923.5]
      • 0x03 - EU [865.1~868.1]
      • 0x04 - JAPAN [952.2~953.6]
      • 0x05 - MALAYSIA [919.5~922.5]
      • 0x06 - EU3 [865.7~867,5]
      • 0x07 - CHINA_BAND1 [840.125~844.875]
      • 0x08 - CHINA_BAND2 [920.125~924.875]
    • 4Bytes - Frequency Min defines the integer and decimal part of the frequency start, for example for 920.125 MHz:
      • 2Bytes - Integer part, example:
        • 0x0398 - 920 MHz
      • 2Bytes - Decimal part, example:
        • 0x007D - 0.125 MHz
    • 2Bytes - Frequency Step defines the width of each frequency channel
      • 0x7D - 0.125 MHz
    • 1Byte - Channel Number
  • Frequency calculation

    • Min Freq = {Frequency Min}
    • Max Freq = {Frequency Min} + {Channel Number} * {Frequency Step}
  • Calculation formula for each frequency region

    • Chinese band2: Fs = 920.125 + CN * 0.25 (MHz) CN∈[0, 19]。
    • US band: Fs = 902.75 + CN * 0.5 (MHz) CN∈[0,49]。
    • Korean band: Fs = 917.1 + CN * 0.2 (MHz) CN∈[0, 31]。
    • EU band: Fs = 865.1 + CN*0.2(MHz) CN∈[0, 14]。
    • Ukraine band: Fs = 868.0 + CN*0.1(MHz) CN∈[0, 6]。
    • Peru band: Fs = 916.2 + CN*0.9(MHz) CN∈[0, 11]。
    • Chinese band1: Fs = 840.125 + CN * 0.25 (MHz) CN∈[0, 19]。
    • EU3 band: Fs = 865.7 + CN * 0.6(MHz) CN∈[0, 3]。
    • US band3: Fs = 902 + CN * 0.5 (MHz) CN∈[0,52]。
    • Taiwan band: Fs = 922.25 + CN * 0.5 (MHz) CN∈[0,11]。

RF Power

RF power of the module, range: [0, 30]

MemBank

Memory Bank to be read during Inventory

  • 0x01 - EPC (Default)
  • 0x02 - TID
  • 0x03 - User

QValue

Q-parameter - Default: 0x04 - Range: [0, 15]

Session

  • Session - The session value used when querying the EPC tag
    • 0x00 - S0 (default)
    • 0x01 - S1
    • 0x02 - S2
    • 0x03 - S3

Acs Addr

  • Address of the memory bank being read during tag inventory
    • Unit: Byte
    • Default value: 0
    • When accessing the EPC memory, 0x00 indicates the starting address of the EPC number segment of the EPC area without the CRC and PC segment

Acs Data Len

  • Acs Data Len - Length of data in memory bank to be read during inventory
    • Unit: Byte

Filter Time

Filters tag with the same data so it will only returned once for the duration of the filter time

  • Unit: seconds
  • Default value: 0 (No filter)

Trigger Time

The duration of inventory after the trigger signal is stopped - Unit: seconds - Value range: [0, 255] - Default: 1

Buzzer Time

The duration of buzzer when the reader finds tag - Unit: 10ms - Value range: [0, 255] - Default: 1 - 0 - Buzzer off

Polling Interval

Inventory interval - Unit: 10ms - Value range: [0, 255] - Default: 1