No part of this publication may be reproduced or used in any form, or by any electrical or mechanical means, without permission in writing from
Symbol. This includes electronic or mechanical means, such as photocopying, recording, or information storage and retrieval systems. The material
in this manual is subject to change without notice.
The software is provided strictly on an “as is” basis. All software, including firmware, furnished to the user is on a licensed basis. Symbol grants
to the user a non-transferable and non-exclusive license to use each software or firmware program delivered hereunder (licensed program). Except
as noted below, such license may not be assigned, sublicensed, or otherwise transferred by the user without prior written consent of Symbol. No
right to copy a licensed program in whole or in part is granted, except as permitted under copyright law. The user shall not modify, merge, or
incorporate any form or portion of a licensed program with other program material, create a derivative work from a licensed program, or use a
licensed program in a network without written permission from Symbol. The user agrees to maintain Symbol’s copyright notice on the licensed
programs delivered hereunder, and to include the same on any authorized copies it makes, in whole or in part. The user agrees not to decompile,
disassemble, decode, or reverse engineer any licensed program delivered to the user or any portion thereof.
Symbol reserves the right to make changes to any software or product to improve reliability, function, or design.
Symbol does not assume any product liability arising out of, or in connection with, the application or use of any product, circuit, or application
described herein.
No license is granted, either expressly or by implication, estoppel, or otherwise under any Symbol Technologies, Inc., intellectual property rights.
An implied license only exists for equipment, circuits, and subsystems contained in Symbol products.
Symbol, Spectrum One, and Spectrum24 are registered trademarks of Symbol Technologies, Inc. Bluetooth is a registered trademark of Bluetooth
SIG. Microsoft, Windows and ActiveSync are either registered trademarks or trademarks of Microsoft Corporation. Other product names mentioned
in this manual may be trademarks or registered trademarks of their respective companies and are hereby acknowledged.
Symbol Technologies, Inc.
One Symbol Plaza
Holtsville, New York 11742-1300
http://www.symbol.com
Patents
This product is covered by one or more of the patents listed on the webbiest: www.symbol.com/patents
This guide provides information on using C API to develop applications to read and write tags on an XR Series RFID reader. The
C API provides an interface with the XR Series readers using the parameters defined in the XR Series Interface Control Guide, p/n 72E-71803-xx.
Chapter Descriptions
Topics covered in this guide are as follows:
•Chapter 1, Getting Started provides an overview of the RFID C API.
•Chapter 3, Initialization describes commands associated with device initialization and discovery.
•Chapter 4, Device Capabilities Discovery describes how to discover and change the RFID API capabilities.
•Chapter 5, Reading and Writing Tags describes tag reading and writing functions.
•Chapter 6, General Helper Functions includes commands for retrieving API status codes and module statistics.
•Appendix A, RFID API Capabilities provides capabilities information to use for reference when calling functions.
•Appendix B, Return Values describes the return values that the C API uses when responding to function calls.
•Appendix C, Sample Application provides a sample application for finding and opening a reader, and reading and displaying
tags.
xi
Notational Conventions
The following conventions are used in this document:
•Italics are used to highlight the following:
• Chapters and sections in this and related documents
• Dialog box, window and screen names
• Drop-down list and list box names
• Check box and radio button names
• Icons on a screen.
•Bold text is used to highlight the following:
• Key names on a keypad
• Button names on a screen.
•Bullets (•) indicate:
• Action items
• Lists of alternatives
• Lists of required steps that are not necessarily sequential.
•Sequential lists (e.g., those that describe step-by-step procedures) appear as numbered lists.
XR400 Reader C API Programmer Reference Guidexii
Related Documents and Software
The following documents provide more information about the XR Series RFID readers.
•XR Series RFID Readers Integrator Guide, p/n 72E-71773-xx
•XR Series Interface Control Guide, p/n 72E-71803-xx
•TagVis User Guide, p/n 72E-71804-xx
•ReaderComm5DLL DeveloperGuide, p/n 72E-71805-xx
For the latest version of this guide and all guides, go to: http://www.symbol.com/manuals.
Service Information
For service information, warranty information or technical assistance contact or call the Symbol Support Center. Contact information
is provided on the Symbol contact web site go to:
If the problem cannot be solved over the phone, the equipment may need to be returned for servicing. If that is necessary, specific
directions will be provided.
Symbol Technologies is not responsible for any damages incurred during shipment if the approved shipping
container is not used. Shipping the units improperly can possibly void the warranty.
http://www.symbol.com/contactsupport
If the Symbol product was purchased from a Symbol Business Partner, contact that Business Partner for service.
The C API enables programmers to write applications which run either directly on an XR Series RFID reader or on a Windows XP SP2
PC host.
This API provides access to the reader features, by utilizing the byte stream protocol as defined in the XR Series Interface Control Guide, p/n 72E-71803-xx. The API exposes these features as a set of predefined capabilities, and carries out operations through
function calls.
The API does not save any configuration information. All of the capabilities are initialized to their default values when an instance is
created and any changes made by the user(s) is not persisted by the API. The users must manage and adjusting the parameters at
runtime. This is true for both the PC and the XR reader platforms.
pdwCapIdPointer to an array of DWORDs for placing the CapIDs.
pNumCapsPointer to DWORD that contains the number of CapIDs in the list.
Note
If pdwCapId or *pNumCaps is 0, the function sets *pNumCaps to the number of DWORDs required to hold the entire list. The user
can then allocate sufficient storage for retrieving the capability list on the next call to RFID_GetCapList.
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_PARAM_ERROR
RFID_INVALID_HANDLE
RFID_BUFFER_TO_SMALL
Device Capabilities Discovery 4-5
RFID_GetCapInfo
Description
This function returns information regarding the capability with ID dwCapId. Information includes unique name, data type, and
This function is similar to RFID_GetCapCurrValue except it applies to the default values. See RFID_GetCapCurrValue on page 4-7 for
a function description.
Parameters
dwCapIdID of capability to get.
pdwNumItemsPointer to DWORD indicating the maximum number of items to get.
dwValueBufSize Size in bytes pointed to by pvValueBuf.
pvValueBufBlock of memory receiving the capability value(s).
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_INVALID_HANDLE
RFID_PARAM_ERROR
RFID_CAPNOTSUPPORTED
RFID_BUFFER_TO_SMALL
Device Capabilities Discovery 4-11
RFID_SetCapCurrValue
Description
This function sets the current value of the specified capability ID.
*pTagPointer to a TYPE_TAG structure which is filled with the tag if the function returns RFID_SUCCESS.
Return Values
If successful:
RFID_SUCCESS (GetTagID returned a TAG)
Upon failure, it returns one of the following values:
RFID_ENGINE_BUSY
RFID_INVALID_HANDLE
RFID_PORT_NOT_OPEN
RFID_PARAM_ERROR
RFID_CMD_NOTAG
Notes
The API currently supports two reading modes, On Demand and Autonomous. The Autonomous reading mode is implemented in the
API software, however it may not be available using the reader capabilities.
•In On Demand mode (the default mode), this function initiates tag reading and blocks until the reading process completes.
If any tags are read, a single tag returns.
•In Autonomous mode, the RFID API is always reading tags. The API saves all tag reads in an internal queue. Calling this
function removes a single tag from the queue. If no tags are available, the function returns immediately. If desired, configure
the API to generate an event if any tags are queued. By doing so, the application can wait for the event, then use this function
to get the tag. For details, see the capability RFID_READCAP_EVENTNAME on page A-12.
To change modes, see the capability RFID_READCAP_READMODE on page A-21.
Example
HANDLE hReader;
TYPE_TAG Tag;
if(RFID_GetTagID(hReader, &Tag) == RFID_SUCCESS)
{
// Display tag ID bytes
// Tag. TagID[0] is first byte
// Tag.dataLength is number of bytes in tag
};
Reading and Writing Tags 5-5
RFID_GetTagMask
Description
This function gets the current TagMask used during RFID tag reading functions. The mask limits the list of tags to read based on the
current mask. The tag mask is limited to 64 bits; future releases will support 96-bit and higher masks.
The TagMask is reset whenever the RFID module is reset or powered off.
*pTagMaskPointer to a tag mask structure for getting the tag mask. Tag Mask contains the following:
nBitLength Number of bits to match.
nStartBit The bit on which to start matching. The first 16 bits of the tag (0-15) are reserved.
pMaskBits Array of bytes (bits) representing the bits to match.
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
TagMask.cBitLen = 8*8; // Match all 64 bits of the TAG ID
TagMask.cBitStartOffset = 16; // Start matching after the first 16 bits.
// These bits are reserved by the tag.
// set the tag mask bits
memcpy(TagMask.cTagMask, pTagBitMask, 8);
RFID_SetTagMask(hReader, &TagMask);
XR400 Reader C API Programmer Reference Guide5-6
RFID_SetTagMask
Description
The RFID_SetTagMask SetTagMask function sets the current TagMask used during RFID tag reading functions. The mask limits the
list of tags to read based on the current mask.
CTagVerifyCountNumber of times to verify the tag before locking.
CKillAttemptsNumber of times to attempt killing the tag.
CTagKillCodePass code used to kill the tag, set using RFID_LockTag. The cTagKillCode has an 8-bit value from 0 to 255.
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_ENGINE_BUSY
RFID_INVALID_HANDLE
RFID_PORT_NOT_OPEN
RFID_PARAM_ERROR
Notes
By default, this function targets Class 1 tags. Set the type of tag on which to perform this operation by setting the capability
RFID_WRITECAP_TAGTYPE on page A-23.
The cTagKillCode only supports one-byte kill codes. Class 0 tags require a three-byte code. To set a kill code with more than one byte,
set the capability RFID_TAGCAP_LOCKCODE on page A-24 to the proper kill code, and pass cTagKillCode to 0.
CTagVerifyCountNumber of times to verify the tag before locking.
CLockAttemptsNumber of times to try locking the tag.
CTagKillCodePass code used to lock the tag. Use this pass code when killing the tag.
CTagKillCode has an 8-bit value from 0 to 255.
Reading and Writing Tags 5-9
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_ENGINE_BUSY
RFID_INVALID_HANDLE
RFID_PORT_NOT_OPEN
RFID_PARAM_ERROR
RFID_CMD_NOTAG
RFID_CMD_TAGLOCK
RFID_CMD_LOCKFAIL
Notes
By default, this function targets Class 1 tags. Set the type of tag on which to perform this operation by setting the capability
RFID_WRITECAP_TAGTYPE on page A-23.
The cTagKillCode only supports one-byte kill codes. Class 0 tags require a three-byte code. To set a kill code with more than one byte,
set the capability RFID_TAGCAP_LOCKCODE on page A-24 to the proper kill code, and pass cTagKillCode to 0.
cTagVerifyCountNumber of times to verify a successful.
cEraseAttemptsNumber of times to attempt erasing the tag.
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_CMD_NOTAG
RFID_CMD_ERASEFAIL
Reading and Writing Tags 5-13
RFID_CMD_TAGLOCK
Notes
By default, this function targets Class 1 tags. Set the type of tag on which to perform this operation by setting the capability
RFID_WRITECAP_TAGTYPE on page A-23.
Gen2 does not support erase
XR400 Reader C API Programmer Reference Guide5-14
RFID_ReadTagInventory
Description
This function supports reading multiple tags. This commands attempts to read a tag for a period of time based on programmerprovided parameters. This command also maintains a list of all tags read, the number of times each was read, the last time each was
read, and its Tag ID. The caller provides a TAG_LIST structure that the API updates. To reset the tag list, set the clear inventory
parameter. If a tag mask was set using RFID_SetTagMask, the inventory does not read tags that do not fit the mask.
*pTagListTAG_LIST structure the API fills with results on the RFID_SUCCESS return value. This includes total tags read,
new tags read during this inventory request, and a list of tags. The caller can provide a valid tag list which the
API updates, or initialize the tag list by setting the bClearInventory flag. This structure is limited to 200 tags.
The nNewTags variable contains the number of new tags detected during the current API call. The first new
tag is located at index nTotalTags-nNewTags.
BClearInventory TRUE - Clear out the current list of tags read, and reset the read count.
FALSE - Continue accumulating tags and keep track of how many times each tag was read.
Return Values
If successful:
RFID_SUCCESS
Upon failure, it returns one of the following values:
RFID_ENGINE_BUSY
RFID_INVALID_HANDLE
RFID_PORT_NOT_OPEN
RFID_PARAM_ERROR
If the tag list is full of valid tag read results but tags read after the list filled were lost:
RFID_MAX_TAGS_EXCEEDED
Notes
Provide a properly initialized taglist before calling this function. In general, zero the structure the first time used (or call this function
with the bClearInventory parameter).
By default, the tag list can hold up to 200 tags. If desired, set the dwMaxTags field in the taglist. The API uses this number to override
the maximum number of tags stored in the list. Allocate a TAG_LIST structure of the appropriate size when changing dwMaxTags.
This function returns RFID_MAX_TAGS_EXCEEDED if the tag list is full, and a queued tag cannot be added to the list. Clear the list,
then call the function again.
The API currently supports two reading modes, On Demand and Autonomous. The Autonomous reading mode is implemented in the
API software, however it may not be available using the reader capabilities.
•In On Demand mode (the default mode), this function initiates tag reading and blocks until the reading process completes.
If any tags are read, they are added to the provided tag list, and returned to the caller.
Reading and Writing Tags 5-15
•In Autonomous mode, the RFID API is always reading tags. The API saves all tag reads in an internal queue. Calling this
function removes all currently queued tags from the queue, and adds these to the provided taglist. If no tags are available,
the function returns immediately. If desired, configure the API to generate an event if any tags are queued. By doing so, the
application can wait for the event, then use this function to get all queued tags. For details, see the capability
RFID_READCAP_EVENTNAME on page A-12.
To change modes, see the capability RFID_READCAP_READMODE on page A-21.
This function gets the current value for the input pins. There are 6 TTL input pins on the XR reader, which will fill in the
low 6 bits of the *pbValue variable.
The readers have 6 TTL output pins. This function can set the value of particular output pins. The GPOMask has the bit
mask for selecting pins. The low 6 bits match those output pins respectively. Value of 1 in the mask means that pin is
selected. The Value variable tells the desired pin value for the specified pins.
The readers support general purpose input detection and event notification. This function lets user enable this detection
and set up the notification event.
The user needs to create a system event for notification, and pass the handle of this event in through the hNotifyEvent
parameter. The parameter bMask provides a bit mask specifying which bit the user is interested in and would like the
detection to listen to its change. This bit mask has the similar definition as in the previous function. The parameter
bInterval specifies the detection interval the reader will use. This value is in terms of 100ms. 0 means the default value
as 500ms.
XR400 Reader C API Programmer Reference Guide5-16
Extended Version of Data Structures and Functions
This version of the XR Series C-API also provides a set of enhanced version of the API function and data structures to
provide richer information and functionalities. It is recommended that new applications should use this new extended
version of structures and functions.
As a convention, these new structures and functions all have the similar names as their original counter parts with the
"EX" extension.
Structures
Following table shows the new extended data structures and their respective original parts:
Table 5-1. Structures
New structureOriginal structure
TYPE_TAG_EXTYPE_TAG
TAG_LIST_EXTAG_LIST
TAG_MASK_EXTAG_MASK
For the structure of TAG_LIST_EX, it should be initialized by the macro of:
The MaxTags parameter tells the maximum number of tags this structure should hold. 0 means the default value of 200
tags. The TagListStructureFormat parameter should always use the predefined constant value of
TAG_LIST_STRUCTURE_FORMAT_EX1.
For example:
TAG_LIST_EX NewTagList;
TAG_LIST_STRUCTURE_INIT(
NewTagList, // The new tag list structure
0, // 0 means default value of 200.
TAG_LIST_STRUCTURE_FORMAT_EX1);
// Then the NewTagList variable is ready to be used in other function calls
Reading and Writing Tags 5-17
Functions
Following shows the pairs of the original functions and their extended counter parts. The only difference is that all
extended version of functions use the extended version of data structures. Other than that, their usage is the same.
When it is reading with the functions of RFID_GetTagIDEX ()/RFID_GetTagIDEX(), RFID_ReadTagInventory()/
RFID_ReadTagInventoryEX(), the returned TAG_TYPE or TAG_TYPE_EX structure may contain errors that have occurred in the
background reading.
If the value of the status field of the structure is RFID_SUCCESS, then this structure holds valid tag information in the respective
fields. Otherwise, the status field tells the main error state; the wStatusDetail field holds device specific error information; and the
antennaNum field holds the antenna index where this error occurred; and all other fields are reserved and should not be used.
Code sample:
/// Processes the error from reader tag reads
/// @param[in] hReaderThe handle of the reader
/// @param[in] TagThe tag structure which holds the status information
/// @returns true if the tag structure is an error and is processed, otherwise false
This chapter includes commands for retrieving API status codes and module statistics.
General Helper Functions 6-3
XR400 Reader C API Programmer Reference Guide6-4
RFID_GetCommandStatusText
Description
This function returns RFID API status codes as English text strings. The hRFIDReader handle is not required, but used for consistency
with the rest of this API.
This function fills the RFID_STATS structure with RFID module statistics. Statistics include Total Characters Transmitted, Total
Characters Received, and Total Tags Read.
This is the IP address to use when calling RFID_FindFirst.
Description
This capability represents the IP address of the reader (Unicode string)
Capability Type
CAPUINT16: Each item is a 16-bit value, 2 bytes.
Maximum Number of Item
This capability can hold 14 items
Container Type
CONT_ARRAY: This capability's container contains an array.
Container Size
The size is 28 bytes
RFID API Capabilities A-5
Default Value
"127.0.0.1"
XR400 Reader C API Programmer Reference GuideA-6
RFID_DEVCAP_IP_PORT
This is the IP port number to use when calling RFID_FindFirst.
Description
This capability represents the TCP port of the reader
Capability Type
CAPUINT32: Each item is a 32-bit value, 4 bytes.
Maximum Number of Item
This capability can hold 1 item
Container Type
CONT_ONEVALUE: This capability's container contains one value.
Container Size
The size is 4 bytes
Default Value
0x0BB8 (3000)
Example
By setting RFID_DEVCAP_IP_NAME and RFID_DEVCAP_IP_PORT, the API searches for an RFID device on the provided TCP
information when RFID_FindFirst or RFID_FindNext are called. If a device is not found at the supplied address:port, the API searches
local com ports for a valid RFID device.
Use this to set the antenna sequence when reading tags. The ReadTag functions issue one set of read commands for each antenna
specified in the sequence.
Description
Use this to set the antenna sequence when reading tags. The ReadTag functions issue one set of read commands for each antenna
specified in the sequence.
Capability Type
CAPUINT8: Each item is a 8-bit value, 1 byte.
Maximum Number of Item
This capability can hold 16 items
Container Type
CONT_ARRAY: This capability's container contains an array.
// Create a small list of antennas to use when reading.
// Read functions will cycle through the antenna sequence
BOOL ConfigureAntennas(void)
{
BOOL bSuccess = FALSE;
DWORD dwNumItems;
char cAntennaSequence[2];
cAntennaSequence[0] = 1;// First antenna
cAntennaSequence[1] = 0;// Second antenna
dwNumItems = 2; // antenna sequence has only 2 entries
// Now tell the API to use this list of antennas
if(RFID_SetCapCurrValue(hReader, RFID_DEVCAP_ANTENNA_SEQUENCE,
// Attenuation of 0 is full power, 255 is no power...
cReadAttenuation = 25;
dwNumItems = 1;
// Now tell API to set read attenuation
RFID_SetCapCurrValue(hReader, RFID_READCAP_RF_ATTENUATION, &dwNumItems, sizeof(cReadAttenuation),
&cReadAttenuation);
// set to low power for tag writes...
cWriteAttenuation = 220;
dwNumItems = 1;
// Now tell API to set read attenuation
RFID_SetCapCurrValue(hReader, RFID_WRITECAP_RF_ATTENUATION, &dwNumItems, sizeof(cWriteAttenuation),
&cWriteAttenuation);
};
RFID API Capabilities A-11
RFID_READCAP_EVENTTAGPTR
Description
This capability contains the address of a TYPE_TAG structure owned by the application. To use this feature, also set the
RFID_READCAP_EVENTNAME capability.
This capability operates as follows:
In On Demand mode, when a tag is read, the API checks to see if the RFID_READCAP_EVENTNAME event is reset. If so, the API places
tag data into the user supplied TYPE_TAG structure, and sets the event RFID_READCAP_EVENTNAME. If the event is already set, the
API queues the tag for later.
When the application receives the event, it processes the tag data and resets the event. The API then re-starts this process. (The API
takes the next queued tag in the TYPE_TAG structure, and resets the event.)
XR400 Reader C API Programmer Reference GuideA-12
RFID_READCAP_EVENTNAME
Description
The name of the windows event object user provided for signaling tag read
Capability Type
CAPUINT16: Each item is a 16-bit value, 2 byte (Unicode string).
Maximum Number of Items
This capability can hold 1 item
Container Type
CONT_ARRAY: This capability contains an array of Unicode characters
Container Size
The size is 64 Unicode characters, 128 bytes
Default Value
NULL string
Notes
The eventname is stored as a Unicode null terminated string. Include the terminating 16-bit NULL character. By implementing this
capability, an application can efficiently wait for tags using a window event.
The API currently supports two reading modes, On Demand and Autonomous. The Autonomous reading mode is implemented in the
API software, however it may not be available using the reader capabilities.
In On Demand mode, by default, this event is signaled when a new tag is added to the supplied taglist.
In Autonomous mode, this event is signaled for all tags.
In On Demand mode, calls to RFID_ReadTagInventory() and RFID_GetTagID() block until the read process completes. Since the
application thread is blocked, the application cannot see tags until the call completes. However, the developer can process read
events while blocked by listening to events on another thread as follows:
Set this to generate events (RFID_READCAP_EVENTNAME) on all tag reads while in On Demand mode. By default, the API signals
only new tags (i.e., it does not signal duplicates).
RFID_READCAP_METHOD
Description
This function represents the tag reading method to use when performing the RFID_ReadTagInventory call.
Capability Type
CAPUINT8: Each item is a 8-bit value, 1 byte.
Maximum Number of Item
This capability can hold 1 item
Container Type
CONT_ONEVALUE: This capability's container contains one value.
Container Size
The size is 1 byte
Default Value
0
RFID API Capabilities A-17
Note
The API supports two read methods for the Class 1 Reader only:
o Method 0 performs RFID tag reading using a binary tree method.
o Method 1 performs RFID tag reading using a masked scroll technique.
XR400 Reader C API Programmer Reference GuideA-18
RFID_READCAP_OUTLOOP
Description
This function represents the outer loop value used when performing the RFID_ReadTagInventory call.
Capability Type
CAPUINT8: Each item is a 8-bit value, 1 byte.
Maximum Number of Item
This capability can hold 1 item
Container Type
CONT_ONEVALUE: This capability's container contains one value.
Container Size
The size is 1 byte
Default Value
5
Note
Calling RFID_ReadTagInventory() performs a tag inventory, which consists of one or more actual read attempts. The number of read
attempts depends on a number of capabilities, including:
•RFID_READCAP_OUTLOOP
•RFID_READCAP_INLOOP
•RFID_TAGCAP_ENABLED_TYPES
•RFID_DEVCAP_ANTENNA_SEQUENCE
The following pseudo code illustrates the tag reading sequence for each read attempt: