Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
92 views

ModuleAPI - C - v1.3 - en

The document describes the API for a reader module. It includes enumerations for error codes, tag protocols, region configurations, lock objects, and lock types. It also describes structures for tag data and parameters. Finally it outlines functions for initialization, parameter settings, GPIO operations, tag operations, tag filtering, and additional data settings.

Uploaded by

yibat23123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

ModuleAPI - C - v1.3 - en

The document describes the API for a reader module. It includes enumerations for error codes, tag protocols, region configurations, lock objects, and lock types. It also describes structures for tag data and parameters. Finally it outlines functions for initialization, parameter settings, GPIO operations, tag operations, tag filtering, and additional data settings.

Uploaded by

yibat23123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

1 INTRODUCTION...................................................................................................................................

2 ENUMERATION.....................................................................................................................................3

READER_ERR...........................................................................................................................................3
REGION_CONF............................................................................................................................................4
MTR_PARAM................................................................................................................................................4
LOCK_OBJ.................................................................................................................................................5
LOCK_TYPE................................................................................................................................................5
CUSTOM CMD TYPE.....................................................................................................................................6

3 STUCTURES.........................................................................................................................................6

TAGINFO.................................................................................................................................................6
NXPCHANGEEASPARA..................................................................................................................................7
NXPEASALARMPARA....................................................................................................................................8
NXPEASALARMRESULT.................................................................................................................................8
ALIENHIGGS3BLOCKREADLOCKPARA..............................................................................................................8
IMPINJM4QTPARA.....................................................................................................................................9
IMPINJM4QTRESULT..................................................................................................................................9

4 FUNCTIONS:.........................................................................................................................................9

4.1 INITIALIZATION AND CLOSE FUNCTIONS.........................................................................................10


InitReader_Notype.......................................................................................................................10
CloseReader...................................................................................................................................11
4.2 FUNCTIONS OF SETTING READER’S PARAMETER...................................................................................11
ParamGet.........................................................................................................................................11
ParamSet.........................................................................................................................................11
4.3 GPIO OPERATING FUNCTION..............................................................................................................18
SetGPO.............................................................................................................................................18
GetGPI.............................................................................................................................................19
4.4 TAG OPERATING FUNCTIONS...............................................................................................................20
TagInventory.................................................................................................................................21
TagInventory_BaseType...............................................................................................................22
TagInventory_Raw.........................................................................................................................24
GetNextTag.....................................................................................................................................25
GetTagData.....................................................................................................................................26
WriteTagData.................................................................................................................................27
WriteTagEpc...................................................................................................................................29
WriteTagEpcEx...............................................................................................................................30
LockTag...........................................................................................................................................32
KillTag...........................................................................................................................................35
CustomCmd.......................................................................................................................................36
4.6 TAG FILTER....................................................................................................................................37
4.7 ADDITIONAL DATA SETTING..............................................................................................................37
5 LIFE CYCLE OF READER.................................................................................................................38

6 ERROR HANDLING.............................................................................................................................38

7 THREAD SAFETY...............................................................................................................................39
1 Introduction

ModuleAPI_C.dll internally call ACE.dll and PCOMM.DLL , please put them in

the same catalog.

2 Enumeration

READER_ERR

typedef enum

MT_OK_ERR, // Operation Succeeded

MT_IO_ERR, //Errors occur in network connection or serial

connection.

MT_INTERNAL_DEV_ERR, //Deprecated error code

MT_CMD_FAILED_ERR, //Operation Failed

MT_CMD_NO_TAG_ERR, //No tags found

MT_M5E_FATAL_ERR, // Deprecated error code

MT_OP_NOT_SUPPORTED, //Operation not supported

MT_INVALID_PARA, //Invalid Parameter

MT_INVALID_READER_HANDLE, //Invalid reader handle

MT_HARDWARE_ALERT_ERR_BY_HIGN_RETURN_LOSS,//High return

loss , check the

antenna and

environment

MT_HARDWARE_ALERT_ERR_BY_TOO_MANY_RESET, //Reset too many times

MT_HARDWARE_ALERT_ERR_BY_NO_ANTENNAS, //No antenna detected

MT_HARDWARE_ALERT_ERR_BY_HIGH_TEMPERATURE, //High temperature

MT_HARDWARE_ALERT_ERR_BY_READER_DOWN, //Reader crashed

MT_HARDWARE_ALERT_ERR_BY_UNKNOWN_ERR, //Unknown error

M6E_INIT_FAILED, //M6E Initialization Failed

MT_OP_EXECING, //Reader busy


MT_UNKNOWN_READER_TYPE, //Unknown reader type

MT_OP_INVALID, //Invalid operation

MT_HARDWARE_ALERT_BY_FAILED_RESET_MODLUE, //reset rfid module

failed

MT_MAX_ERR_NUM,

}READER_ERR; //Return value of Reader API

SL_Tag Protocol

typedef enum

SL_TAG_PROTOCOL_NONE = 0x00, //None

SL_TAG_PROTOCOL_ISO180006B = 0x03, //ISO18000-6b

SL_TAG_PROTOCOL_GEN2 = 0x05, //GEN2

SL_TAG_PROTOCOL_ISO180006B_UCODE = 0x06, //ISO18000-6B-UCODE

SL_TAG_PROTOCOL_IPX64 = 0x07, //IPX64

SL_TAG_PROTOCOL_IPX256 = 0x08, //IPX256

} SL_TagProtocol;

Region_Conf

typedef enum

RG_NA = 0x01, // FCC 47 CFG Ch. 1 Part 15 Industrie Canada RSS-210

RG_EU = 0x02, //ETSI EN 302 208

RG_EU2 = 0X07, // ETSI EN 300 220

RG_EU3 = 0x08, // Revised ETSI EN 302 208

RG_KR = 0x03, // MIC

RG_PRC = 0x06, // SRRC, MII

RG_OPEN = 0xFF, // No regulatory compliance enforced

} Region_Conf; // Frequency regulatory of regions

Mtr_Param
For setting parameters of reader. For detailed information please check the

introduction of ParamGet and ParamSet.

Lock_Obj

typedef enum

LOCK_OBJECT_KILL_PASSWORD = 0x01, //Locked object is kill password

LOCK_OBJECT_ACCESS_PASSWD = 0x02, // Locked object is access password

LOCK_OBJECT_BANK1 = 0x04, // Locked object is bank1

LOCK_OBJECT_BANK2 = 0x08, // Locked object is bank2

LOCK_OBJECT_BANK3 = 0x10, // Locked object is bank3

} Lock_Obj;

Lock_Type

typedef enum

KILL_PASSWORD__UNLOCK = 0x0000, //Unlock kill password

KILL_PASSWORD__LOCK = 0x0200, //Temporarily lock kill password

KILL_PASSWORD_PERM_LOCK = 0x0300, //Permanently lock kill password

ACCESS_PASSWD_UNLOCK = 0x00, //Unlock access password

ACCESS_PASSWD_LOCK = 0x80, //Temporarily lock access password

ACCESS_PASSWD_PERM_LOCK = 0xC0, //Permanently lock access password

BANK1_UNLOCK = 0x00, //Unlock bank1

BANK1_LOCK = 0x20, //Temporarily lock bank1

BANK1_PERM_LOCK = 0x30, //Permanently lock bank1

BANK2_UNLOCK = 0x00, //Unlock bank2

BANK2_LOCK = 0x08, //Temporarily lock bank2

BANK2_PERM_LOCK = 0x0C, //Permanently lock bank2


BANK3_UNLOCK = 0x00, // Unlock bank3

BANK3_LOCK = 0x02, //Temporarily lock bank3

BANK3_PERM_LOCK = 0x03, //Permanently lock bank3

} Lock_Type;

Custom Cmd Type

typedef enum

NXP_SetReadProtect, // SetReadProtect command of NXP IC

NXP_ResetReadProtect, // ResetReadProtect command of NXP IC

NXP_ChangeEAS, // ChangeEAS command of NXP IC

NXP_EASAlarm, // EASAlarm command of NXP IC

NXP_Calibrate, // Calibrate command of NXP IC

ALIEN_Higgs2_PartialLoadImage, // PartialLoadImage command of ALIEN Higgs2

IC

ALIEN_Higgs2_FullLoadImage, // FullLoadImage command of ALIEN Higgs2 IC

ALIEN_Higgs3_FastLoadImage, // FastLoadImage command of ALIEN Higgs3 IC

ALIEN_Higgs3_LoadImage, // LoadImage command of ALIEN Higgs3 IC

ALIEN_Higgs3_BlockReadLock, // BlockReadLock command of ALIEN Higgs3 IC

IMPINJ_M4_Qt,// QT command of IMPINJ Monza4 IC

} CustomCmdType;

3 Stuctures

TAGINFO

typedef struct

{
unsigned char ReadCnt; //Number of times of the tags have been read

unsigned char RSSI; //Received signal strength of tag

unsigned char AntennaID; //The antenna ID that read tag

unsigned int Frequency; //The frequency point that read tag

unsigned int TimeStamp; // The time the tag was read, relative to the

time the command to read was issued

read was issued, in milliseconds

unsigned short EmbededDatalen; //The length of embedded data, in bytes

unsigned char EmbededData[MAXEMBDATALEN]; //Embedded data

unsigned char Res[2]; //Reserve

unsigned short Epclen; //length of EPC, in bytes

unsigned char PC[2]; //PC segment

unsigned char CRC[2]; //CRC segment

unsigned char EpcId[MAXEPCBYTESCNT]; //EPC code

int Phase; //

SL_TagProtocol protocol; //Tag protocol

} TAGINFO; //For inventory operation,this structure is applied to show all the

information of every tag.

NXPChangeEASPara

typedef struct

unsigned char AccessPwd[4]; //Access password;if want successfully execute

ChangeEAS instructions ,tags must set nonzero

password

int isSet; //EAS status,when isSet is set as 1 means it is set,tags would

response to EASAlarm instructions; When isSet is

set as 0 means it is reset,tags would not response

to EASAlarm

unsigned short TimeOut; // the timeout of executing instructions

} NXPChangeEASPara;
NXPEASAlarmPara

typedef struct

unsigned char DR; // Divide Ratio as Per Gen2,only support 0x01 currently

unsigned char MC; // Miller Cycles,only support 0x02 currently

unsigned char TrExt; // TrExt as Per Gen2,only support 0x01 currently

unsigned short TimeOut; // the timeout of executing instructions

} NXPEASAlarmPara;

NXPEASAlarmResult

typedef struct

unsigned char EASdata[8];//the return data when successfully executing

EASAlarm instructions.

} NXPEASAlarmResult;

ALIENHiggs3BlockReadLockPara

typedef struct

unsigned char AccessPwd[4]; //the access password

unsigned char BlkBits; //8 bits and every bit correspond to one user

bank’s piece(each piece include 8 bytes, if the

corresponded bit is 1 which means enable read

protection for this piece, when it is 0 means

disable read protection)

unsigned short TimeOut; // the timeout of executing instructions

} ALIENHiggs3BlockReadLockPara;
IMPINJM4QtPara

typedef struct

unsigned char AccessPwd[4]; //the access password.

int CmdType; //0 means read QT control bits; 1 means write QT control bits.

When it is 0 the private instruction function would ignore

parameters of MemType, PersistType, RangeType.

int MemType; //0 means it will use private data profile;1 means it will use

public data profile.

int PersistType; //0 means change QT control bits temporarily;1 means

change

QT control bits permanently.

int RangeType; //0 means the read range is distant field;1 means the read

range type is near field.

unsigned short TimeOut; // the timeout of executing instructions

} IMPINJM4QtPara;

IMPINJM4QtResult

typedef struct

int MemType; //0 means it will use private data profile;1 means it will use

public data profile.

int RangeType; //0 means the read range is distant field;1 means the

read range type is near field.

} IMPINJM4QtResult;

4 Functions:
All of the following examples of functions are based on the hypothesis that

the hReader is the handle of reader. All the functions with return value will

return to MT_OK_ERR after successfully executed.

4.1 Initialization and close functions

InitReader_Notype

READER_ERR stdcall InitReader_Notype(int *hReader, char * src, int antscnt)

Functional description

Initialize the reader

Parameters

Parameters Description

hReader output parameter, reader handle return

to user.

src The address of reader , serial number

or IP address.

antscnt Amount of the antenna port of reader,

it should be set to 1 for desktop card

reader and Integrated reader, other

types of reader would set to the

corresponding value according to the

amount of antenna port.

Example:

int hReader;

char *ip = “192.168.0.250”;

if (InitReader_Notype(&hReader, ip, 4) != MT_OK_ERR)

printf(“error in InitReader_Notype\n”);

}
CloseReader

void __stdcall CloseReader(int hReader);

Functional description

Close readers

Parameters

Parameters Description

hReader Handle of reader

Example

CloseReader(hReader);

4.2 functions of setting reader’s parameter

ParamGet

ParamSet

READER_ERR __stdcall ParamGet(int hReader, Mtr_Param key, void *val);

READER_ERR __stdcall ParamSet(int hReader, Mtr_Param key, void *val);

Functional description

The two functions can get and set all the parameters of reader.The key

parameter shows which parameter will be got and set, the type of val parameter

depend on key parameter. See the table below. A parameter of reader will work

consistently g until it is set to other value.

key Definition of key val Definition of val Writab

le

MTR_PARAM_POTL_GEN2_SES Gen2 Protocol int Legal values:0,1,2,3 Write


& Read
SION Parameters Session

MTR_PARAM_POTL_GEN2_Q Gen2 Protocol int Legal value: -1-—15. (- Write


& Read
Parameters 1:automatically adjust Q
Q value value;0---15:static Q value)

MTR_PARAM_POTL_GEN2_TAG Gen2 Protocol int Legal value:0,1,2,3(0:FM0 only Write


& Read
ENCODING baseband encoding support the readers with m6e

architecture;1:the M value of

MILLER is 2;2:the M value of

MILLER is 4;3:the M value of

MILLER is 8)

MTR_PARAM_POTL_GEN2_MAX the maximum int Legal value: 96,496 Write


& Read
EPCLEN supported EPC

length in bits

MTR_PARAM_RF_ANTPOWER transmitting power AntPow powers:the array of AntPower Write


& Read
of reader erConf type and Each element

represents the power of an

antenna

configurations(antid:the

antenna ID(starting from 1);

The unit of read Power and

write Power is centi-dbm)

antcnt:the number of elements

has been set up in Powers

array.

Note:the default power when

reader power on is the 2/3 of

the maximum transmitting power

of reader

MTR_PARAM_RF_MAXPOWER The maximum unsign Unit is centi-dbm Write


& Read
transmitting power ed

of reader short

MTR_PARAM_RF_MINPOWER The minimum unsign Unit is centi-dbm Write


& Read
transmitting power ed
of readers short

MTR_PARAM_TAG_FILTER Tag filter is the TagFil bank:the memory bank to be Write


& Read
selection criteria ter_ST matched , legal value is

for tags when 0,1,2,3,4(0--3:gen2 tag’s

reading, writing, bank0-3;

locking, killing 4:iso180006b memory)

and inventory Startaddr:the memory bank

operation offset, in bits, at which to

begin comparing the Fdata

Fdata: the comparing data

Flen: the length, in bits, of

the Fdata

isInvert: whether to invert

the selection ;0 means

matching the filter

criteria,1 means not matching

the filter criteria.

When you don’t use filter

criteria you could set

TagFilter_ST as NULL.

MTR_PARAM_TAG_EMBEDEDDA Read data of Embede bank: which bank to read when Write
& Read
TA another bank while dData_ inventory , legal value is

inventory ST 0,1,2,3;

operation running. startaddr: memory bank offset,

in blocks, at which to begin

reading

bytecnt: how many bytes would

be read from the starting

address;

accesspwd: access password, if


the password is not required

you could be set as NULL.

If reading extra data when

inventory is not Required

you should set

EmbededData_ST as NULL.

MTR_PARAM_TAG_INVPOTL Set protocol of Inv_Po potls:the array of Inv_Potl Write


& Read
inventory(only tls_ST type. Every element represent

supported by the the inventory operation of

readers with M6e some kind of protocol. ( potl

architecture) in Inv_Potl means protocol,

weight in Inv_Potl is an

integer, the relative weight

of each of the Inv_Potl is

used to determine what

fraction of the total read

time is allotted to that

protocol when executing

inventory of multiply

protocols)

potlcnt:the number of elements

in potls array.

MTR_PARAM_READER_CONN_A the antennas ConnAn connectedants: the antennas Read

NTS detected ( not ts_ST found. only

all the antennas antcnt: the number of the id

could be of antenna within

detected) connectedants.

MTR_PARAM_READER_AVAILA The number of int the number of antenna ports of Read

BLE_ANTPORTS antenna ports of reader only


reader

MTR_PARAM_READER_IS_CHK Whether to detect int Legal value:0,1(0:do not Write

_ANT the antennas on detect antenna before & Read

antenna ports transmitting power;1:detect

before antenna before transmitting

transmitting power power which is strongly

recommended)

MTR_PARAM_READER_VERSIO Version number of Reader Currently unavailable Read

N reader _Ver only

MTR_PARAM_READER_IP Set or get IP Reader ip:ip address Write

address of reader _Ip mask:subnet mask & Read

MTR_PARAM_FREQUENCY_REG Frequency Region Write

ION regulatory of _Conf & Read

reader

MTR_PARAM_FREQUENCY_HOP frequency hopping Hoptab htb: frequency points Write

TABLE table of reader leData lenhtb: the number of & Read

_ST frequency points.

MTR_PARAM_POTL_GEN2_BLF Gen2 backscatter int Typical value are 250,640 Write

link frequency, in Only using FMO gen2 encoding & Read

KHz it could be set as 640 ,

when using Miller gen2

encoding it could only be set

as 250

MTR_PARAM_POTL_GEN2_WRI Writing mode of int Legal value:0,1(0:write in Write

TEMODE Gen2 protocol words;1:wirte in blocks) & Read

MTR_PARAM_POTL_GEN2_TAR Target of Gen2 int Legal value:0,1,2,3(0:A; 1:B; Write

GET protocol 2:A->B; 3:B->A) & Read

MTR_PARAM_TAGDATA_UNIQU For the same tag, int Legal value:0,1(0:no matter Write

EBYANT whether it would how many antennas read the tag & Read
be regarded as there would be only one tag
several different record;1: different tag

tag records when records when it was read by

it was read by different antenna for the same

different tag)

antennas.

MTR_PARAM_TAGDATA_UNIQU when inventory int Legal value:0,1(0:regard as Write

EBYEMDDATA with embedded one tag record;1:regard as & Read

read another multiply tag records)

bank, some tags

are the same epc

data but with

different other

bank data

whether consider

these tags as

different tag

data records

MTR_PARAM_TAGDATA_RECOR Whether or not int Legal value:0,1(0:record the Write

DHIGHESTRSSI only record the highest rssi value;1 : not to & Read

highest rssi value record the highest rssi value)

MTR_PARAM_RF_HOPTIME Frequency hopping int Write


& Read
time in milisecond

MTR_PARAM_RF_LBT_ENABLE Enable or disable int Legal value:0,1(0: Write


& Read
lbt disable;1:enable)

MTR_PARAM_POTL_ISO18000 180006b int Legal value:40,160 Write


& Read
6B_BLF backscatter link

frequency, in KHz

MTR_PARAM_POTL_GEN2_TAR Gen2 protocol Tari int Legal value:0,1,2(0:25 ms; Write


& Read
I 1:12.5 ms;2:6.25 ms)

MTR_PARAM_TRANSMIT_MODE Transmit mode of int Legal value: 0, 1(0:high Write


reader performance;1:low power. Only & Read

supported by m5e reader)

MTR_PARAM_POWERSAVE_MOD Power saving mode int Legal value:0,1,2,3(0: no Write


& Read
E power saving;3: highest power

saving)

MTR_PARAM_TAG_SEARCH_MO Tag search mode int Legal value:0,1 (0:normal Write


& Read
DE mode;1:high speed mode. Only

supported by m6e series

reader, appropriate to small

amount of tags with high

speed)

MTR_PARAM_POTL_ISO18000 Iso180006b int Legal value: 0, 1(0:99% Write


& Read
6B_MODULATION_DEPTH modulation depth modulation depth;1:11%

modulation depth. Only

supported by m6e series

reader)

MTR_PARAM_POTL_ISO18000 Iso180006b int Legal value: 0, Write


& Read
6B_DELIMITER Delimiter 4(1:Delimiter1; 4:Delimiter4.

Only supported by m6e series

reader)

MTR_PARAM_RF_ANTPORTS_V Antenna ports AntPor reserved for get standing-wave Read

SWR standing-wave tsVSWR ratio of antenna ports, only

ratio readers is not supported

currently.

MTR_PARAM_SAVECONFIGURA Permanently save int Legal value: 0,1(1:permanently Write

TION the configuration save configuration;0:delete Only

of reader the configuration , after

deletion the reader would

apply the default parameters


when it power on. This

function is not supported by

slr1000 and slr1100 modules

and the USB port reader made

of these modules.

Not all parameters can be

saved by all kinds of readers,

for details please see the

table below)

Parameter configuration M5e series M6e series slr1100 Ethernet port readers
Gen2Session Yes Yes Yes
Gen2Target Yes Yes Yes
Gen2Qvalue Yes Yes Yes
Working area Yes Yes Yes
gen2encoding Yes ( no Yes No
FMO)
Antenna detection Yes Yes No
transmitting power Yes Yes Yes
Uniqueness of data antenna Yes Yes Yes
Uniqueness of the attachment data Yes Yes Yes
Record the highest Rssi Yes Yes Yes
Frequency hopping table Yes Yes Yes
power saving mode Yes Yes No
Maximum EPC length Yes No No
Gen2 writing mode Yes Yes Yes
Gen2Trai No Yes No
Gen2 backward Scattering rate No Yes No
Counting mode No Yes No
Iso180006b backward Scattering No Yes No
rate

4.3 GPIO operating function

The GPIO function is optional,not all kinds of readers support GPIO.


SetGPO

READER_ERR __stdcall SetGPO(int hReader, int gpoid, int state);

Functional description

Set GPO pin’s status

Parameters

parameters description

hReader Handle of reader

gpoid GPO id,one-based numbering

state Status value,1 is high,0 is low

Example

if (SetGPO(hReader, 1, 1) != MT_OK_ERR)

printf(“SetGPO failed\n”);

GetGPI

READER_ERR __stdcall GetGPI(int hReader, int gpiid, int *state);

Functional description

Get GPI pin’s status

Parameters

parameters Description

hReader Handle of reader

gpiid GPI ID,one-based numbering

state output parameter,return to 1 when GPI

is high,return to 0 when GPI is low


Example

int state;

if (GetGPI(hReader, 1, &state) != MT_OK_ERR)

printf(“GetGPI failed \n”);

4.4 Tag operating functions

Gen2 tag is divided into four banks which are bank 0 ,bank 1,bank 2 and bank

3. Bank 0 is also called the reserve bank which contains the access password

and the kill password while each password has 32 bits. Bank 1 is called EPC

bank, which contains CRC field ( 16 bits ) , PC field ( 16 bits ) and EPC

field(maximum length is 496 bits and the common length is 96 bits ). Bank 2

also known as TID bank, which contains tag–and vendor-specific data (for

example, a tag serial number). Bank 3 is called user bank , allows user-

specific data storage,different tag IC may has different capacity and lots of

tags do not have bank 3.


In different bank,the minimum unit of tag operating function is block , zero-

based numbering, which is 16 bits. All the tag operations except inventory

could be set a timeout period. If the operation is finished before the timeout

expires, the function would return before timeout. Otherwise, the function

would block until the timeout expires. Inventory operation can use several

antennas to search tags while for other tag operations like read, write, lock

or kill only one antenna must be specified used for these operations.

For the operations like read, write, lock and kill except inventory, if

there are several tags in the antenna field, the first tag response to the

reader would be operated. Therefore, to ensure the operation aim at the

specific tag, there must be only one tag in the antenna field or setting the

tag filter.

Attention : Do not operate the tag on the antenna ports without antenna

connection, this may cause hardware damage.


TagInventory

READER_ERR __stdcall TagInventory(int hReader, int *ants, int antcnt, unsigned

short timedur, TAGINFO *pTInfo, int *tagcnt);

Functional description

Read the EPC code of tags. Please set MTR_PARAM_TAG_INVPOTL parameters before

call this function.

Parameters

Parameters Description

hReader Handle of reader

ants Store operating antennas in this

array

antcnt The number of antennas in ants array

timedur The time period of operation , in

milliseconds, for the inventory

operation the function would block

until timedur is expired.

pTInfo Output parameter, store the tag data.

The memory of this parameter is

allocated by users, but the users

should estimate the number if the

tags within the antenna fields then

allocate enough memory space for

pTInfo so that it could store all the

tag data read.

tagcnt Output parameter , the number of the

tags read, all the tag data store

at pTInfo.

Example
int ants[] = {1, 2, 3, 4}

int antcnt = 4;

TAGINFO tags[200];

int tagnum;

if (TagInventory(hReader, ants, antcnt, 1000, tags, & tagnum) != MT_OK_ERR)

printf(“TagInventory failed”);

Attention: the tags buffer in reader can store 200-1000 tags (depend on reader

type).if there are many tags ( more than 1000 ) in the antenna fields, the

parameter timedur should not set to a too large value, this can avoid the

reader reporting Buffer Full error.

TagInventory_BaseType

READER_ERR __stdcall TagInventory_BaseType(int hReader, int *ants, int antcnt,

unsigned short timedur, unsigned char *outbuf, int *tagcnt);

Functional description

Read EPC code of tags , this function differs from TagInventory function in

the format of tags information returned by reader, this function does not use

TAGINFO structure in order to adapt to more development environments like VB,

Delphi. Please set MTR_PARAM_TAG_INVPOTL parameters before call this function.

Parameters

Parameters Description

hReader Handle of reader

ants Store operating antennas in this

array

antcnt The number of antennas in ants array


timedur The time period of operation , in

milliseconds, for the inventory

operation the function would block

until timedur is expired.

outbuf Output parameter , all the data of

tags was stored in outbuf in a

specific order , for the data of one

tag the order are as follows,

readcnt ( 1byte ) , rssi ( 1 byte ) ,

antennaid (1 byte), Frequency (3 个

bytes ) , TimeStamp ( 4 bytes ) ,

reserved ( 2 bytes ) , Epclen (2

bytes ) , PC ( 2 bytes ) , epc id

( Epclen byte ) , crc ( 2

bytes ) , EmbededDatalen ( 2

bytes ) , EmbededData ( if

EmbededDatalen is 0 there is no this

field)

tagcnt Output parameter , the number of the

tags read, all the tag data store in

outbuf.

Example

int ants[] = {1, 2, 3, 4}

int antcnt = 4;

unsigned char tags[30*200];

int tagnum;

if (TagInventory_BaseType (hReader, ants, antcnt, 1000, tags, &tagnum) !=

MT_OK_ERR)
{

printf(“TagInventory_BaseType failed”);

TagInventory_Raw

READER_ERR stdcall TagInventory_Raw(int hReader, int *ants, int antcnt,

unsigned short timedur, int *tagcnt)

Functional description

Read EPC code of tags , but you cannot get any EPC code from this function

except the number of tags read. After calling this function users must

immediately call GetNextTag function to get the detailed data of tags.

Parameters

Parameters Description

hReader Handle of reader

ants Store operating antennas in this

array

antcnt The number of antennas in ants array

timedur The time period of operation , in

milliseconds, for the inventory

operation the function would block

until timedur is expired.

tagcnt Output parameter , the number of the

tags read.

例子:

int ants[] = {1, 2, 3, 4}

int antcnt = 4;
int tagnum;

if (TagInventory_Raw(hReader, ants, antcnt, 1000, &tagnum) != MT_OK_ERR)

printf(“TagInventory_Raw failed”);

GetNextTag

READER_ERR __stdcall GetNextTag(int hReader, TAGINFO *pTInfo);

Functional description

Get the data of next tag, users could get the number of tags read by calling

TagInventory_Raw function, and then execute GetNextTag function as many times

as the number of tags to get all the data of tags read.

Parameters

Parameters Description

hReader Handle of reader

pTInfo Output parameter, store the tag data.

example:

TAGINFO tag;

if (GetNextTag(hReader, &tag) != MT_OK_ERR)

printf(“GetNextTag failed”);

GetTagData
READER_ERR __stdcall GetTagData(int hReader, int ant, unsigned char bank,

unsigned int address, unsigned char blkcnt, unsigned char *data, unsigned char

*accesspasswd, unsigned short timeout);

Functional description

Read data of tag bank. Before calling this function for ISO18000-6b tag

operation the tag filter must be set and the detailed setting should be as

follows: bank is 4, flen is 64, startaddr is 0, isInvert is 0. Fdata is the uid

of 18000-6b.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

bank The bank to read, Value range: from 0

to 4;0-3:use for Gen2 tag;4:use for

ISO18000-6b tag.

address Starting address in bank,in blocks.

blkcnt The number of block to read.

data Output parameter, to store the read

data.

accesspasswd If need access password , please fill

in the password ( 4 bytes ) , if the

access password is not necessary this

parameter is NULL

timeout The timeout period of operation

Example

Read two blocks of data from the second block of the bank 0(i.e. access
password), and the access password is locked, the access password is

0x12345678.

int ant = 1;

unsigned char bank = 0;

unsigned int addr = 2;

unsigned int blks = 2;

unsigned char data[4];

unsigned char pwd[4];

pwd[0] = 0x12;

pwd[1] = 0x34;

pwd[2] = 0x56;

pwd[3] = 0x78;

if (GetTagData(hReader, ant, bank, addr, blks, data, pwd, 1000) != MT_OK_ERR)

printf(“GetTagData failed”);

WriteTagData

READER_ERR __stdcall WriteTagData(int hReader, int ant, unsigned char bank,

unsigned int address, unsigned char *data, int datalen, unsigned char

*accesspasswd, unsigned short timeout);

Functional description

Write data into tag bank. Before calling this function for ISO18000-6b tag

operation the tag filter must be set and the detailed setting should be as

follows: bank is 4, flen is 64, startaddr is 0, isInvert is 0. Fdata is the uid

of 18000-6b.

Parameters

Parameters Description
hReader Handle of reader

ant The operating antenna

bank The bank to read, Value range: from 0

to 4;0-3:use for Gen2 tag;4:use for

ISO18000-6b tag.

address Starting address in bank,in blocks.

data Data to write

datalen Length of data, in bytes. Note:

datalen must be multiple of 2.

accesspasswd If need access password , please fill

in the password ( 4 bytes ) , if the

access password is not necessary this

parameter is NULL

timeout The timeout period of operation

Example

Write data ”0x111122223333” into bank 3 staring at the second block. No

access password.

int bank = 3;

int ant = 1;

int addr = 2;

unsigned char data[6];

data[0] = 0x11;

data[1] = 0x11;

data[2] = 0x22;

data[3] = 0x22;

data[4] = 0x33;

data[5] = 0x33;

if (WriteTagData(hReader, ant, bank, addr, data, 6, NULL, 1000) != MT_OK_ERR)

printf(“WriteTagData failed\n”);
}

WriteTagEpc

READER_ERR __stdcall WriteTagEpc(int hReader, int ant, unsigned char *Epc, int

epclen, unsigned short timeout);

Functional description

Write epc code to EPC bank. The epc code also can be rewritten using

WriteTagData function with bank parameter setting to 1, address parameter

setting to 2. However there are still differences with WriteTagEpc :

WriteTagEpc would change the PC field of EPC bank while writing epc code. PC

stores the epc length filed (this function may change the length) and this

function does not support tag filter and access password. This function is

used in initializing tag.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

Epc EPC data to write

epclen Length of EPC data, in bytes. Note:

epclen must be multiple of 2.

timeout The timeout period of operation

Example

Write EPC code 0x111122223333111122223333 to EPC bank.

char *epcstr = ”111122223333111122223333”;

unsigned char epcdata[12];

epcdata[0] = 0x11;

epcdata[1] = 0x11;

epcdata[2] = 0x22;
epcdata[3] = 0x22;

epcdata[4] = 0x33;

epcdata[5] = 0x33;

epcdata[6] = 0x11;

epcdata[7] = 0x11;

epcdata[8] = 0x22;

epcdata[9] = 0x22;

epcdata[10] = 0x33;

epcdata[11] = 0x33;

if (WriteTagEpc(hReader, 1, epcdata, 12, 1000) != MT_OK_ERR)

printf(“WriteTagEpc failed\n”);

WriteTagEpcEx

READER_ERR __stdcall WriteTagEpcEx(int hReader, int ant, unsigned char *Epc,

int epclen, unsigned char *accesspwd, unsigned short timeout);

Functional description

Do the same thing as WriteTagEpc except for supporting setting tag filter and

adding access password parameter.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

Epc EPC data to write

epclen Length of EPC data, in bytes. Note:

epclen must be multiple of 2.


accesspwd If need access password , please fill

in the password ( 4 bytes ) , if the

access password is not necessary this

parameter is NULL

timeout The timeout period of operation

Example

Write EPC code 0x111122223333111122223333 to EPC bank with access password

0x12345678.

char *epcstr = ”111122223333111122223333”;

unsigned char epcdata[12];

unsigned char pwd[4];

pwd[0] = 0x12;

pwd[1] = 0x34;

pwd[2] = 0x56;

pwd[3] = 0x78;

epcdata[0] = 0x11;

epcdata[1] = 0x11;

epcdata[2] = 0x22;

epcdata[3] = 0x22;

epcdata[4] = 0x33;

epcdata[5] = 0x33;

epcdata[6] = 0x11;

epcdata[7] = 0x11;

epcdata[8] = 0x22;

epcdata[9] = 0x22;

epcdata[10] = 0x33;

epcdata[11] = 0x33;

if (WriteTagEpcEx(hReader, 1, epcdata, 12, pwd, 1000) != MT_OK_ERR)

printf(“WriteTagEpcEx failed\n”);
}

LockTag

READER_ERR __stdcall LockTag(int hReader, int ant, unsigned char lockobjects,

unsigned short locktypes, unsigned char *accesspasswd, unsigned short timeout);

Functional description

Lock the tag. The following objects are able to be locked: kill

password , access password , EPC bank , TID bank , USER bank. The accesspasswd

parameter cannot be NULL. This function could lock multiple objects of one tag

at the same time. The lock type can be unlock, temporarily lock or permanently

lock. This function only supports gen2 tag.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

lockobjects Objects to lock,this parameter can be

the value of OR operation on multiple

Lock_Obj enumeration values when

locking multiple objects.

locktypes Lock type , this parameter can be the

value of OR operation on multiple

Lock_Type enumeration values when

locking multiple objects.

accesspasswd Access password

timeout The timeout period of operation

Example

Temporarily locked bank1,bank3,unlock access password, the access password is


”0x12345678”

unsigned char pwd[4];

pwd[0] = 0x12;

pwd[0] = 0x34;

pwd[0] = 0x56;

pwd[0] = 0x78;

if (LockTag(hReader, 1,

LOCK_OBJECT_ACCESS_PASSWD | LOCK_OBJECT_BANK1 | LOCK_OBJECT_BANK3,

ACCESS_PASSWD_UNLOCK | BANK1_LOCK | BANK3_LOCK, pwd, 1000) != MT_OK_ERR)

printf(“LockTag failed\n”);

Attention : There must be a Lock_Type enumeration value in locktypes

corresponding to each Lock_Obj enumeration value in lockobjects.

Lock180006BTag

READER_ERR __stdcall Lock180006BTag(int hReader, int ant, int startblk,

int blkcnt, unsigned short timeout);

Functional description

Lock 18000-6b tag. Before calling this function for ISO18000-6b tag operation

the tag filter must be set and the detailed setting should be as follows: bank

is 4, flen is 64, startaddr is 0, isInvert is 0. Fdata is the uid of 18000-6b.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

startblk starting block,


blkcnt The number to lock

timeout The timeout period of operation

Example

Lock 8 consecutive blocks from the ninth block.

unsigned char uid[] = {1,2,3,4,5,6,7,8};//tag uid

TagFilter_ST filter;

filter.bank = 4;

filter.fdata = uid;

filter.flen = 64;

filter.startaddr = 0;

filter.isInvert = 0;

ParamSet(hReader, MTR_PARAM_TAG_FILTER, &filter);

if (Lock180006BTag(hReader, 1, 9, 8,1000) != MT_OK_ERR)

printf(“Lock180006BTag failed\n”);

KillTag

READER_ERR __stdcall KillTag(int hReader, int ant, unsigned char *killpasswd ,

unsigned short timeout);

Functional description

Destroy tags. Once the tags was destroyed, they can no longer in use. Before

destroy a tag users must set the kill password instead of 0.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

killpasswd Kill password


timeout The timeout period of operation

Example

Destroy a tag, its kill password is ”0x43215678”

unsigned char kpwd[4];

kpwd[0] = 0x43;

kpwd[0] = 0x21;

kpwd[0] = 0x56;

kpwd[0] = 0x78;

if (KillTag(hReader, 1, kpwd, 1000) != MT_OK_ERR)

printf(“KillTag failed \n”);

CustomCmd

READER_ERR __stdcall CustomCmd(int hReader, int ant, CustomCmdType cmdtype,

void *CustomPara, void *CustomRet);

Functional description

Tag operation of custom command of tag IC.

Parameters

Parameters Description

hReader Handle of reader

ant The operating antenna

cmdtype The custom command type. For detailed

information see the CustomCmdType

enumeration.

CustomPara Input parameter, different custom

command would require different type


of parameter.

CustomRet Output parameter, the return data from

custom command, different custom

command would return different type of

data.

Below is the type of CustomPara and CustomRet with different custom command

cmdtype CustomPara CustomRet

NXP_ChangeEAS NXPChangeEASPara NONE

NXP_EASAlarm NXPEASAlarmPara NXPEASAlarmResult

ALIEN_Higgs3_BlockReadLock ALIENHiggs3BlockReadLockPar NONE

IMPINJ_M4_Qt IMPINJM4QtPara IMPINJM4QtResult

Example

Execute the custom command of ChangeEAS of NXP tag IC , access password is

0x00000001,set the EAS.

NXPChangeEASPara para;

para.AccessPwd[0] = 0;

para.AccessPwd[1] = 0;

para.AccessPwd[2] = 0;

para.AccessPwd[3] = 1;

para.isSet = 1;

para.TimeOut = 500;

if (CustomCmd(m_pdlg->m_reader, 1, NXP_ChangeEAS, &para, NULL) != MT_OK_ERR)

printf("CustomCmd failed\n");

4.6 Tag Filter


Tag operations like inventory, read, write, lock and kill can operate on a

specific tag by setting MTR_PARAM_TAG_FILTER parameter. You can specify

filter criteria which allow specifying a bank (ban k1, bank 2, bank 3), a

starting address in the bank and data to be compared in the bank. As for

ISO18000-6b tag, it is meaningless to set tag filter for inventory. Once a

tag filter has been set, it will work until another tag filter is set or

the tag filter is canceled by setting as NULL.

4.7 Additional Data Setting

When executing the inventory operation, users could get another bank data

(we call it additional data) by setting MTR_PARAM_TAG_EMBEDEDDATA parameter

except epc code. The member EmbededDatalen of TAGINFO structure indicates

the number of bytes of additional data. If the EmbededDatalen is 0 it means

there is no additional data read. The additional data stores in the member

EmbededData of TAGINFO structure. This parameter only supports gen2 tag.

Setting as NULL will cancel the parameter.

5 Life Cycle of Reader


Firstly you should call InitReader_Notype function to initialize reader, after
that you may call ParamSet or ParamGet function to configure reader. Now you
can call tag operations and GPIO functions. Calling CloseReader means you no
longer use reader.

6 Error Handling

All the API functions with returned value will return MT_OK_ERR on success. If

the return value is MT_IO_ERR it means there are something wrong with network

connection or serial port connection, you should call CloseReader and check

these connections firstly, then try to call InitReader_Notype. As for

MT_CMD_FAILED_ERR, it just means the failure of the function, it is not a fatal

error, and you can do any operation next. As for MT_CMD_NO_TAG_ERR , strictly

speaking, it cannot be called an error, and means there is no tag was found.

The errors starting with MT_HARDWARE_ALERT_ERR_BY are serious errors which

cannot be ignored. Some improper operations can cause these errors and hardware
damage. These operations include: transmit power through antenna ports without

antenna connection, the use of unqualified antenna, high ambient temperature

and the high return loss caused by metal plate in front of antennas . It would

be best to turn off the reader and check the working condition and working

environment for these errors.

7 Thread Safety

All the functions, except for InitReader_Notype function, of the current

version of SDK are not thread-safe for the same handle of reader. Users should

make certain that there is no race condition for the API functions calling or

use some synchronization ways of multithread. There is no restriction above for

different handles of readers.

You might also like