RFID Reader Development Guide-C_C++_linux
RFID Reader Development Guide-C_C++_linux
V0.1.4.0
Contents
1. Preface .........................................................................................................................................4
1.1. Overview .........................................................................................................................4
1.2. Applicable Devices ..........................................................................................................4
1.3. Copyright Statements .....................................................................................................4
1.4. Basic Flow of Reader and Write ......................................................................................5
2. Quick Start ...................................................................................................................................5
3. Connection Description ..............................................................................................................8
3.1. RS232 Connection ...........................................................................................................8
3.2. RS485 Connection ...........................................................................................................9
3.3. TCP Client Connection.....................................................................................................9
3.4. TCP Server Listening ........................................................................................................9
3.5. Close TCP Server Listening ..............................................................................................9
3.6. USB-HID Connection .....................................................................................................10
3.7. Close Connection ..........................................................................................................10
4. Events Description.....................................................................................................................10
4.1. ISO18000-6C Tag Reports Event ...................................................................................10
4.2. ISO18000-6C Tag Reports Over Event ...........................................................................11
4.3. ISO18000-6B Tag Report Event .....................................................................................11
4.4. ISO18000-6B Tag Reports Over Event...........................................................................12
4.5. GPI Triggers Start Event.................................................................................................13
4.6. GPI Trigger End Event....................................................................................................13
4.7. TCP Listening Connection Event ...................................................................................14
4.8. TCP Connection Disconnect Event ................................................................................14
5. Messages Configuration and Query Description ......................................................................15
5.1. Send Synchronized Messages .......................................................................................15
6. Messages Description ...............................................................................................................16
6.1. Reader Configuration and Management ......................................................................16
6.1.1. Reboot Reader ..................................................................................................16
6.1.2. Configure and Query COM Parameter .............................................................16
6.1.3. Configure GPO State Parameter .......................................................................17
6.1.4. Query GPI State Parameter...............................................................................17
6.1.5. Configure and Query GPI Trigger Parameter ....................................................17
6.1.6. Query Version for Software Baseband .............................................................18
6.1.7. Query the information of the Reader Capabilities ...........................................19
6.1.8. Query the Information of the Reader...............................................................19
6.1.9. Buzzer control ...................................................................................................20
6.2. RFID Configuration and Operation ...............................................................................20
6.2.1. Stop Command .................................................................................................20
6.2.2. Configure and Query Power of the Reader ......................................................21
6.2.3. Configure and Query the working frequency band of the reader ...................22
6.2.4. Configure and Query EPC Baseband Parameter...............................................22
6.2.5. Configure and Query Tag for Uploading Paramater .........................................23
6.2.6. Inventory ISO18000-6C Tag ..............................................................................23
6.2.7. Write ISO18000-6C Tag .....................................................................................24
6.2.8. Lock ISO18000-6C Tag.......................................................................................25
6.2.9. Kill ISO18000-6C Tag .........................................................................................25
6.2.10. Inventory ISO18000-6B Tag ..............................................................................26
6.2.11. Write ISO18000-6B Tag .....................................................................................26
6.2.12. Lock ISO18000-6B Tag....................................................................................... 27
6.2.13. Locking Query ISO18000-6B Tag....................................................................... 27
7. Parameter Description ..............................................................................................................28
7.1.1. ISO18000-6C Tag Select Tag Parameter ............................................................28
7.1.2. ISO18000-6C Tag Read TID Parameter..............................................................28
7.1.3. ISO18000-6C Tag Read User Data Area Parameter...........................................29
7.1.4. ISO18000-6B Tag Read User Data Area Parameter...........................................29
8. Appendix 1 ................................................................................................................................29
1. Preface
1.1. Overview
We provide the function that can run on linux platform for the convenience of add-on development. This
library is written by C++ language and zipped up to be a standard DII library.
All contents of this document, including text and pictures, are original and we reserve the right to pursue the
legal liability for any unauthorized commercial use. The user should not add, modify or delete any content of this
document and transmit the content via internet or CDs, etc. Anyone who violate will take the consequence at his
or her own expensive.
1.4. Basic Flow of Reader and Write
2. Quick Start
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "delegate.h"
#include "message.h"
#include "GClient.h"
GClient *client;
int main() {
switch (way) {
case 1: {
client = OpenRS232("/dev/ttyUSB0:115200", 3);
}
break;
case 2: {
client = OpenRS485("/dev/ttyUSB0:115200:1", 3);
}
break;
case 3: {
client = OpenTcpClient("192.168.1.168:8160", 3);
}
break;
}
}
if (client == nullptr) {
printf("failed to connection \n");
return 0;
} else {
printf("success to connection \n");
}
//Debug log
client->isPrint = true;
//STOP COMMAND
MsgBaseStop stop;
memset(&stop, 0, sizeof(stop));
SendSynMsg(client, EMESS_BaseStop, &stop);
if (stop.rst.RtCode != 0) {
printf("Failed to MsgBaseStop: %s. \n", stop.rst.RtMsg);
} else {
printf("Success to MsgBaseStop. \n");
}
//msg.Filter.Area = 2; // TID
//msg.Filter.Start = 0;
//memcpy(msg.Filter.HexData, "E2801130200020190FFD019B", 25);
//msg.Filter.BitLen = strlen(msg.Filter.HexData) * 4;
msg.ReadTid.Mode = 0;
msg.ReadTid.Len = 6;
//msg.ReadUserdata.Start = 0;
//msg.ReadUserdata.len = 4;
SendSynMsg(client, EMESS_BaseInventoryEpc, &msg);
if (msg.rst.RtCode != 0) {
printf("Failed to MsgBaseInventoryEpc: %s. \n", msg.rst.RtMsg);
} else {
printf("Success to MsgBaseInventoryEpc. \n");
}
sleep(5);
//STOP COMMAND
SendSynMsg(client, EMESS_BaseStop, &stop);
if (stop.rst.RtCode != 0) {
printf("Failed to MsgBaseStop: %s. \n", stop.rst.RtMsg);
} else {
printf("Success to MsgBaseStop. \n");
}
usleep(500);
//CLOSE
if (client->isOpened) {
Close(client);
}
return 0;
}
3. Connection Description
Description timeout: connection time is confirmed exceeded limits (ms), like “5”
4. Events Description
Reporting Object
Object LogBaseEpcInfo
Epc: Hexadecimal EPC character string
Pc:PC Value
AntId:Antenna No.
Rssi:Signal strength
Attribute
Result:Tag reading result, 0 means success and non-zero value means failure
Tid:Hexadecimal TID character string
Userdata: Hexadecimal Userdata character string
Reserved: Hexadecimal reserved area character string
Reporting Object
Object LogBase6bInfo
Reporting Object
Object LogAppGpiStart
Reporting Object
Object LogAppGpiOver
}
Description RegGServerCallBack(gserver, GClientConnected);
Description:
➢ TCP listens successfully, this event is reported when the remote connection is successful.
➢ After the event is reported, the upper computer (caller) needs to receive and store the
GClient to communicate with the module.
s:Connected Object
Parameter type:Message Type
Msg: Message
msg.rst.RtCode:message return code,0 means sucess, and non-zero value means failure.
Msg.rst.RtMsg: The reason of the failed operation
Instruction Send synchronized messages, detailed in Code Example
Tips: “Reader configuration and management”, “RFID configuration and operation” and other
message are sent with this method
Code Example
// stop command,idle state
MsgBaseStop stop;
memset(&stop, 0, sizeof(stop));
SendSynMsg(s, EMESS_BaseStop, &stop);
if (stop.rst.RtCode != 0) {
printf("failed to MsgBaseStop: %s \n", stop.rst.RtMsg);
}
else
{
printf("Success to MsgBaseStop. \n");
}
6. Messages Description
Category EMESS_AppReboot
Message MsgAppReboot
Normally the restart message of the device will be executed after the modification of the
Description
configuration that need to come in to effect after restart.
Configuration
MsgAppSetSerialParam
messages
Configuration
MsgAppGetSerialParam
messages
BaudrateIndex: Baud rate index(0,9600 bps; 1,19200 bps; 2,115200 bps; 3,230400
Attribute
bps; 4,460800bps)
(Persistent configuration, which means the information will be saved when it is powered off)
Description
configure the COM parameter of the device.
6.1.3. Configure GPO State Parameter
Namespace EMESS_AppSetGpo
(Persistent configuration, which means the information will be saved when it’s powered off)
Configure the device GPO parameter。
Description
Note: For GPO that do not require state control, no assignment is needed.
Namespace EMESS_AppGetGpiState
Namespace EMESS_AppSetGpiTrigger
Configuration Class MsgAppSetGpiTrigger
Message EMESS_AppGetGpiTrigger
(Presistent configuration, which means the information will be saved when it is powered off
configure the device GPI trigger parameter)
Description
Notes:This configuration needs to be modified when the device is idle(that is, the
configuration can be changed under loop reading)
Namespace EMESS_AppGetBaseVersion
Namespace EMESS_BaseGetCapabilities
Description N/A
Namespace EMESS_AppGetReaderInfo
Description N/A
Namespace EMESS_AppSetBuzzerCtrl
Status: 0,stop;1,ring
Attribute
Mode: 0,ring once;1,always ring
Description N/A
Namespace EMESS_BaseStop
Category MsgBaseStop
Attribute N/A
Stop all RFID operations of the reader and make the reader idle
Description Tips: When the reader is reading, all configuration messages will not be able to send, a stop
command must be sent.
Namespace EMESS_BaseSetPower
Category EMESS_BaseGetPower
Namespace EMESS_BaseSetFreqRange
Category EMESS_BaseGetFreqRange
(Permanent configuration, saved when power off) Used to configure the current working
Description
frequency band of the reader.
Namespace EMESS_BaseSetBaseband
Category EMESS_BaseGetBaseband
Namespace EMESS_BaseSetTagLog
Category EMESS_BaseGetTagLog
(Persistent configuration, saved when power off) Used to configure reader upload
Description
parameters.
Category EMESS_BaseInventoryEpc
Information MsgBaseInventoryEpc
AntennaEnable: Antenna Port(using antenna enumeration is detailed in Quick Start)
InventoryMode: Continuous/Single Read (0: single read,the reader read one time on each
enacling antenna then stop reading and automatically enter idle state; 1: continuous read,
the reader keeps reading and stop reading after receiving a stop command..)
Attribute Filter: select reading parameter(optional)(detailed in parameter description)
ReadTid: TID read parameter(optional)(detailed in parameter description)
ReadUserdata: user data area read parameter(optional) (detailed in parameter description)
ReadReserved: reserved area read parameter(optional)(detailed in parameter description)
StrHexPassword: access password(optional)
Using for configuring the reader parameter for tag reading and start reading. Any reading
Description operation for the tag data require the EPC code of the tag, so a EPC code can be acquired
through any reading operation.
Namespace EMESS_BaseWriteEpc
Category MsgBaseWriteEpc
➢ Reader writes ISO18000-6C Tags, the writing that this command refined should be single
operation.
➢ ISO18000-6C The protocol specifies that the minimum data unit for R/W operations is a
word.
Description ➢ EPC are include CRC-16(the zeroth word) + PC(the first word) + EPC:
CRC16: the zeroth word, not writable.
PC:the first word,the fisrt 5 bit is the word length of EPC,which means the
computingmethod of PC to move the word length of EPC 11 bit to the left.
0, Write Success
1, Antenna port parameter error
2, Choice parameter error
3, Write parameter error
4, CRC checksum error
5, Insufficient power
Write results
6, Data area overflow
7, Data area is locked
8, Wrong access password
9, Other Tag errors
10,Loss the Tag
11,Reader sends command error
Namespace EMESS_BaseLockEpc
Category MsgBaseLockEpc
Lock or unlock the ISO18000-6C tag. The operation defined by this command is a single
Description
operation.
Namespace EMESS_BaseDestroyEpc
Category MsgBaseDestoryEpc
AntennaEnable: antenna Port
Attribute StrHexPassword: destroy passwords
Filter: Select read parameters(optional)(detailed in parameter description)
Kill the ISO18000-6C tag. The tag inactivated will be in permanent failure and this operation is
Description
irreversible. The operation this command defined is single.
Namespace EMESS_BaseInventory6b
Category MsgBaseInventory6b
Namespace EMESS_BaseWrite6b
Category MsgBaseWrite6b
AntennaEnable: Antenna Port
StrHexMatchTid:TID code of the 6B tag to be matched (hex)
Attribute
Start:word initial address of the tag data area to be written
StrHexWriteData:Data content to be written (hex)
Description Write ISO18000-6B tag, The writing operation this command defined is single.
Namespace EMESS_BaseLock6b
Category MsgBaseLock6b
Lock 6B tag. The operation is irrevocable and reversible. The locking operation this command
Description
defined is single.
Namespace EMESS_BaseLockGet6b
Category MsgBaseLockGet6B
7. Parameter Description
Category ParamFilter
Description Optional parameter (The start bit address when matching EPCs is usually 32)
Category ParamEpcReadTid
Category ParamEpcReadUserdata
Category Param6bReadUserdata
8. Appendix 1
List of the frequency band the Readers Supported
Index Description
0 National standard 920~925MHz
1 National standard 840~845MHz
2 National standard 840~845MHz and 920~925MHz
3 FCC,902~928MHz
4 ETSI,866~868MHz
5 JP, 916.8~920.4 MHz
6 TW, 922.25~927.75 MHz
7 ID, 923.125~925.125 MHz
8 RUS, 866.6~867.4 MHz
9 TEST 802.75~998.75MHz