The USB Tag Reader can be implemented using a DLL file specifically written for working with RACE RESULT transponders. If you plan to implement the USB Tag Reader please contact us via support@raceresult.com to request access to the DLL file
NewTagReader
The NewTagReader function is being used to register a TagReader device to the system.
Syntax
int NewTagReader(int vid, int pid)
Params
|
<vid> |
The devices vendor ID |
|
<pid> |
The devices product ID |
The latest version of the TagReader is using 0xe6a as vid and 0x350 as pid.
Return
It will return a unique ID in form of an Integer, which is required to control the device.
TRConnect
The TRConnect function is used to establish a connection to the TagReader with the given ID.
Syntax
int TRConnect(int tagReaderID)
Params
|
<tagReaderID> |
The ID of the device to be connected to |
Return
|
0 |
Connection was successfully established |
| -4 | Connection could not be established |
| -90 | The TagReader with the given ID was not found |
TRDisconnect
The TRDisconnect function is used to disconnect from the TagReader with the given ID.
Syntax
int TRDisconnect(int tagReaderID)
Params
|
<tagReaderID> |
The ID of the device to be disconnected from |
Return
|
0 |
Connection was successfully closed |
| -5 | Connection could not be closed |
| -90 | The TagReader with the given ID was not found |
TRDoReaderAction
The TRDoReaderAction function is used to perform a given action on the given TagReader device.
Syntax
int TRDoReaderAction(int tagReaderID, int action)
Params
|
<tagReaderID> |
The ID of the device to perform the action |
| <action> | Code of the desired action (ref: Available reader actions) |
Return
|
0 |
Action was successfully executed |
| -5 | Error while performing the action |
| -90 | The TagReader with the given ID was not found |
TRSendCommand
The TRSendCommand function is used to execute any command on the given TagReader device.
Syntax
char* TRSendCommand(int tagReaderID, int cmd, char* data)
Params
|
<tagReaderID> |
The ID of the device to perform the action |
| <cmd> | Code of the desired command (ref: Available commands) |
| <data> |
Depending on the chosen command. See documentation: |
Return
|
Success: |
Response of the device for the executed command |
| Error: | The error message received while executing the given command |
TRSetReaderPower
The TRSetReaderPower function is used to set the power level of the given TagReader device.
Syntax
int TRSetReaderPower(int tagReaderID, int powerLevel)
Params
|
<tagReaderID> |
The ID of the device to perform the action |
| <powerLevel> | The desired power level (Min.: 2, Max.: 18) |
Return
|
0 |
Power level successfully changed |
| -7 | Error while setting up the power level |
| -90 | The TagReader with the given ID was not found |
TRGetSerialNumber
The TRGetSerialNumber function is used to read the serial number of the given TagReader device.
Syntax
*char TRGetSerialNumber(int tagReaderID)
Params
|
<tagReaderID> |
The ID of the device to perform receive the serial number from |
Return
|
Success: |
The serial number of the device |
| Error: | The error message received while reading the serial number |
TRGetChipID
The TRGetChipID function is used to read the chip ID of the given TagReader device.
Syntax
*char TRGetSerialNumber(int tagReaderID)
Params
|
<tagReaderID> |
The ID of the device to get the chip ID from |
Return
|
Success: |
The chip ID of the device |
|
Error: |
The error message received while reading the chip ID |
Available commands
| ReadCardData | 0x01 |
| ReaderActionCommand | 0x02 |
| SetReaderParameters | 0x03 |
| ReadWriteEEPROM | 0X0C |
| GetSerialNumber | 0x0D |
| GetModelFirmwareVersion | 0x0E |
| SystemCommand | 0x0F |
| ReadUID | 0x11 |
| WriteKeyToEEPROM | 0X12 |
| ReadDataUltralightNTAG | 0x13 |
| WriteDataUltralightNTAG | 0x14 |
| ReadData | 0x15 |
| WriteData | 0x16 |
| ISO15693Inventory | 0x21 |
| ISO15693ReadBlock | 0x22 |
| ISO15693WriteBlock | 0x23 |
| ISO15693Information | 0x24 |
| ISO15693CComannd | 0x00 |
| MultiTagRead | 0xF0 |
Available reader actions
| RestoreDefaultActionSetting | 0x01 |
| BeepGreenLightOnShort | 0x02 |
| BeepLightOffShort | 0x03 |
| BeepGreenLightOnLong | 0x04 |
| BeepLightOffLong | 0x05 |
| BeepShort | 0x06 |
| BeepLong | 0x07 |
| GreenLightOnLong | 0x08 |
| LightOffLong | 0x09 |
| StopSenseCard | 0x11 |
| StartSenseCard |
0x12 |
| Reset | 0x13 |
Example in C++
This is an example how to use the tagReader.dll with C++
Loading the DLL:
First you need to load the library, using the LoadLibrary function provided by the <windows.h>. This then looks something like:
HMODULE handle = LoadLibrary(TEXT("C:\\Users\\example\\Documents\\tagReaderDLL\\tagReader.dll"));
If the handle holds a value other than NULL, the library was succesfully loaded.
Loading a function:
To use a function provided by the DLL you first need to define it. Therefore you need the return value and the parameters of the function.
An example to call the function "NewTagReader", which returns an integer and uses two integer parameters, looks like:
typedef int(NEWTAGREADERFUNC)(int, int);
To load the function, GetProcAddress is used. It requires the handle and the name of the function you want to load (Note: the function name is case sensitive). this may looks like:
NEWTAGREADERFUNC *pNEWTAGREADERFUNC = (NEWTAGREADERFUNC *)::GetProcAddress(handle, "NewTagReader");
If the value of pNEWTAGREADERFUNC is other than NULL, the function was loaded successfully.
Calling a function:
After loading a function, the function is ready to be called. This may looks like:
tagReaderID = (*pNEWTAGREADERFUNC)(0xe6a,0x350);
A full example to connect to the TagReader and make it beep:
#include <windows.h>
#include <iostream>
using namespace std;
typedef int(NEWTAGREADERFUNC)(int, int);
typedef int(CONNECTFUNC)(int);
typedef int(DOREADERACTIONFUNC)(int, int);
typedef int(GETCHIPIDFUNC)(int);
int main(int argc, char **argv)
{
HMODULE handle = LoadLibrary(TEXT("C:\\Users\\example\\Documents\\project\\tagReader.dll"));
if (NULL == handle)
{
cout << "Could not load library" << endl;
return -1;
}
NEWTAGREADERFUNC *pNEWTAGREADERFUNC = (NEWTAGREADERFUNC *)::GetProcAddress(handle, "NewTagReader");
int tagReaderID;
if (pNEWTAGREADERFUNC)
{
tagReaderID = (*pNEWTAGREADERFUNC)(0xe6a, 0x350);
cout << tagReaderID << endl;
}
else
{
return -1;
}
CONNECTFUNC *pCONNECTFUNC = (CONNECTFUNC *)::GetProcAddress(handle, "TRConnect");
int connect;
if (pCONNECTFUNC)
{
connect = (*pCONNECTFUNC)(tagReaderID);
cout << "successfully connected: " << connect << endl;
}
DOREADERACTIONFUNC *pDOREADERACTIONFUNC = (DOREADERACTIONFUNC *)::GetProcAddress(handle, "TRDoReaderAction");
int actionResult;
if (pDOREADERACTIONFUNC) {
actionResult = (*pDOREADERACTIONFUNC)(tagReaderID, 7);
cout << "actionResult is: " << actionResult << endl;
}
GETCHIPIDFUNC *pGETCHIPIDFUNC = (GETCHIPIDFUNC *)::GetProcAddress(handle, "TRGetChipID");
if (pGETCHIPIDFUNC) {
char *chipID = (*pSENDCOMMANDFUNC)(tagReaderID);
cout << "chipID is: " << chipID << endl;
}
return 0;
}