Animal electronic ear tag reader|reader|card reader L8600 series Modbus RTU communication protocol and secondary development instructions are suitable for L8600-S-02, L8600- R-02 , more MODBUS TCP protocol information welcome to exchange!
Factory default configuration:
Slave address |
02 |
Reset configuration |
Standard master-slave mode, antenna is on |
If you want the card reader to read the card, then send data (slave active sending mode): Send a command after powering on: 02 06 00 00 00 03 C9 F8
Serial port configuration (8 data bits):
Baud rate |
19200 |
check |
1 bit even parity |
Stop bit |
First place |
System configurable content: (hexadecimal communication)
- Antenna switch and response mode. In (slave active transmission) mode, the reader will actively send card reading data to the bus after reading the card; (master-slave mode) the card reader will not actively return data, and wait until the host accesses it. Reply to the data. This configuration data will not be saved when the power is off, and it needs to be configured every time the power is turned on . (Hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 06 00 00 00 03 C9 F8 |
The antenna is on, and the slave sends actively |
02 06 00 00 00 03 C9 F8 |
Usually used in a master-slave communication |
02 06 00 00 00 02 08 38 |
Antenna on, master-slave mode |
02 06 00 00 00 02 08 38 |
|
02 06 00 00 00 01 48 39 |
The antenna is off, and the slave sends actively |
02 06 00 00 00 01 48 39 |
|
02 06 00 00 00 00 89 F9 |
Antenna off, master-slave mode |
02 06 00 00 00 00 89 F9 |
|
- The back of the card carries the data length and the address of the card reader. The back data refers to the data sent by some cards in addition to the card number and country code, but also other data. The current product supports access to up to 20 bytes of data (160 bits). This configuration data is saved and will not be lost after power off. (Hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 06 00 01 A0 02 21 F8 |
A0 (160) bits. Address 0x02 (range: 1-247) |
02 06 00 01 A0 02 21 F8 |
160 bits of data after reading, the address is configured as 0x02 |
02 06 00 01 00 02 59 F8 |
No data added (range: 0-160), address 0x02 (range: 1-247) |
02 06 00 01 00 02 59 F8 |
When the configuration value is out of the range, the return value is normal, but the system ignores it. |
Read data: (Hexadecimal communication)
- Read antenna switch and response mode information. (Hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 03 00 00 00 01 84 39 |
Read back 0x00 address information |
02 03 02 00 03 BC 45 |
The antenna is on, and the slave sends actively |
2. After reading, the data length, address, and version number information will be attached. (Hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 03 00 01 00 04 15 FA |
Read back 0x01-0x04 address information |
02 03 08 A0 02 17 05 B1 FA 00 01 BA C1 |
With data length 0xA0, address: 0x02, version information: 17 05 B1 FA 00 01 |
3. Read system tuning status information (hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 03 00 05 00 09 95 FE |
Read back 0x05-0x0D address information |
02 03 12 B5 3F 50 62 81 9C B9 B6 98 8A 70 60 52 4A 41 3C 37 05 26 AA |
System tuning status information, used to view the working status of the module, usually do not need to read |
4. Card reading data reading: (hexadecimal communication)
Host sends commands |
Configuration content |
Reader returns |
Remarks |
02 03 00 0E 00 07 65 F8 |
Read back 0x0E-0x15 address information, the length is 0x07 |
02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 3E DC F6 |
Read card information such as card number |
02 03 00 0E 00 11 E4 36 |
Read back 0x0E-0x1F address information, the length is 0x11 |
02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 FF 20 D5 CF |
读取到卡号信息和后带数据信息 |
读卡数据读取的长度可以从0x07-0x11(就是说回读信息地址可以从(0x0E-0x15)到(0x0E-0x1F))。
发送命令分析(02 03 00 0E 00 07 65 F8)
02: 从机地址;
03: 读取功能(MODBUS-RTU);
000E:读取寄存器地址;
0007:读取数据长度(7个字14 Bytes);
65F8:前面所有数据(02 03 00 0E 00 07)的CRC检验值,低字节先发。
接收命令分析:(02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 3E DC F6)
02:从机地址;
03: 读取功能(MODBUS-RTU);
0E:回读数据长度(14 Bytes);
0262:国家代号(10进制610)
07B660CB53:卡号数据(10进制33124567891)
00:0000 0000最低位代表后加数据是否有效(0无效、1有效),其他7位是未定义数据。
80:1000 0000最高位代表动物标志,其他7位是未定义数据。
000000:卡内其他数据,未定义数据。
00:数据传输补充够偶数字节(14 Bytes),无意义
3E: 当前数据的读卡时间(0x3E*0.02s) 证明是1.24s 前读到的,最多计算到5.1s前。
DCF6:前面整个数据包(02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 3E)的CRC检验。DC为低字节,F6为高字节。
接收命令分析:(02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 FF 20 D5 CF)
02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00:和以上分析一致。
11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43:20字节的后加数据。
FF:数据传输补充够偶数字节(34 Bytes),无意义。
20:当前数据的读卡时间(0x20*0.02s) 证明是0.64s 前读到的,最多计算到5.1s前。
D5CF: 前面整个数据包的CRC检验,D5为低字节,CF为高字节。
从机主动发信息的方式:机器读到卡会马上发一帧数据,如果卡片一直不离开数据不会重复发送,如果卡离开0.2s以上再进入机器会再发一帧数据(每次卡片进入都会实时往总线发送一帧数据)
当将读卡器配置为从机主动发送模式后,读卡器读到卡就马上往总线上发卡号信息,信息的长度可以配置,比如我们将后加数据长度配置为30位(16位以下不发送后带数据,后带数据从16-160有效),35位为4个字节3位需要5个字节来发送,所以字符串数据长度为12(卡号信息长度)+5=17字节,但是由于数据长度数要偶数(字),所以后面要补个随机数,即18个。所以字符串的构成就是0xxx(从机地址)+0x03(功能)+0x12(18个字节)+18个字节数据+2字节CRC。总共23个字节。(后加数据如果没有需要时最好配0,有利于数据传输)
例如后加数据配置A0(160位、20字节)。卡片有后加数据时收到的数据为:
03 03 20 02 62 07 B6 60 CB 53 01 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 C1 26
03:从机地址;
03: 读取功能(MODBUS-RTU);
20:回读数据长度(32 Bytes);
0262:国家代号(10进制610)
07B660CB53:卡号数据(10进制33124567891)
01:0000 0001最低位代表后加数据是否有效(0无效、1有效),其他7位是未定义数据。
80:1000 0000最高位代表动物标志,其他7位是未定义数据。
000000:卡内其他数据,未定义数据。
11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43:是后加数据20个字节。
C126:CRC校验。
将后加数据配置为0后读到数据:02 03 0C 02 62 07 B6 60 CB 53 01 80 00 00 00 17 35
02:从机地址;
03: 读取功能(MODBUS-RTU);
0C:回读数据长度(12 Bytes);
0262:国家代号(10进制610)
07B660CB53:卡号数据(10进制33124567891)
01:0000 0001最低位代表后加数据是否有效(0无效、1有效),其他7位是未定义数据。
80:1000 0000最高位代表动物标志,其他7位是未定义数据。
000000:卡内其他数据,未定义数据。
1735: CRC校验
本协议符合MODBUS- RTU标准,支持0地址广播监听功能(可以用于配置从机地址等信息)。但是广播命令从机不做回复。
CRC校验函数:
unsigned int CRC16_MB(unsigned char *cBuffer, unsigned int iBufLen)
{
unsigned int i, j;
unsigned int wPolynom = 0xa001;
unsigned int wCrc = 0xffff;
for (i = 0; i < iBufLen; i++)
{
wCrc ^= cBuffer[i];
for (j = 0; j < 8; j++)
{
if (wCrc &0x0001)
{
wCrc = (wCrc >> 1) ^ wPolynom;
}
else
{
wCrc = wCrc >> 1;
}
}
}
return wCrc;
}
附录:
设备地址 |
命令 |
寄存器地址 |
内容 |
实现的功能 |
02
|
06
|
00 00 (配置后断电不保存)
|
b15- b3:无定义,(上电默认:00 02) |
b0==1:从机主动发送通常应用在一主一从的通信中 |
b0==0:主从模式 |
||||
b1==1:天线开 |
||||
b1==0:天线关 |
||||
b2==1:从机主动发送模式下,读到卡连续发送数据 |
||||
b2==0:从机主动发送模式下,卡进入一次场区发送一次数据 |
||||
00 01 (配置后断电保存) |
A0 02 |
读取后带数据160(0xA0)位,设备地址配置为0x02 |
||
00 02 |
无后加数据,设备地址0x02 |
|||
03
|
00 00 |
00 01 |
返回0x00地址信息,即天线状态和发送模式 |
|
00 01 |
00 04 |
后带数据长度和地址以及版本信息 |
||
00 05 |
00 09 |
系统调谐状态信息,用于查看模块工作状态,平常不用读取 |
||
以上命令仅支持以上格式读写 |
||||
02 |
03 |
00 0E |
00 01 ~ 00 11 |
读取到卡号信息和后带数据信息 |