Introduction
The goal of this article is to illustrate the use of Psion Teklogix provided libraries to read/write RFID Tags using 753x hand-held devices. The provided sample is intended to be easy to use, and hopefully a proper kick-start to use the device. It also includes a library (PDAFarsiLib) to make Farsi (Persian) language texts appear properly on the device. You can find more information about the language library from Mohamed Abdel-Monem's article. You can also find a very comprehensive support from the manufacturer company as you will.
Prerequisites
In order to use the Psion Tecklogix provided SDKs to work with the device, you should have at least the following prerequisites in place:
ActiveSync must be installed
Connect the device to the PC while installing the ActiveSync setup.
Setup the PsionTeklogixCE420\RfidDeviceManager CAB file on the device
Installing RfidDeviceManager.cab would place the required libraries on the device to let your .NET application use the provided SDKs.
Using the Code
Use the .NET PtxRfidNet.dll SDK library to program the device. (Note: As stated in the Prerequisites step above, RfidDeviceManager.cab should be installed on the device and the PtxRfid.dll library should exist on the device.) To read or write Tags using the Psion Teklogix 753x device, an instance of DeviceInterface
must be constructed and the proper readers selected.
On the Smart Device project, create an instance of the DeviceInterface
class and use it to find the readers on the device:
DeviceInterface DevInt = new DeviceInterface();
Find the proper reader (or all the readers) in the list:
ReaderId[] _readers = DevInt.CreateReader(readerId);
Used the above readers (_readers
) to read/write and work with the device.
Write the RFID Tag
Tag IDs are in Hex format, and they should be 24 characters in length. In order to write a hex number like “absdefg0123456789”, it should be written to an array of 12 bytes length and each byte holding a four bits hex number. So, byte[0]
holds “ab” which is 171. To construct the proper byte array from the UID string:
byte[] bUID = new byte[12];
for (int i = 0, j = 0; i < UID.Length; i = i + 2, j++)
{
bUID[j] = byte.Parse(UID.Substring(i, 2),
System.Globalization.NumberStyles.HexNumber);
}
Construct an EpcClass1Gen2 Tag and set its UID to the byte array constructed above:
Tag rfidTag = new Tag(TagType.EpcClass1Gen2);
rfidTag.Uid = new TagUid(bUID, 96);
Use the WriteUid
API from the selected reader to write the UID on the Tag:
WriteTagUidParams param = new WriteTagUidParams();
_reader.WriteUid(param, rfidTag);
Asynchronous RFID Tag Read
Handle the AsynchronousDataDelegate
event to read the RFID tags placed in front of the device.
ReadTagParams t = new ReadTagParams(ReadModes.Triggered, 2000);
_reader.StartAsynchronousRead(t);
_reader.AsynchronousDataEvent +=
new AsynchronousDataDelegate(reader_AsynchronousDataEvent);
When the RFID read triggers on the device, the following event would raise, and you can add the read UIDs to a ListBox
as follows:
void reader_AsynchronousDataEvent(object source, AsynchronousDataEventArgs e)
{
if (e.tagData.Format == TagDataFormats.UnparsedRaw)
{
foreach (Tag id in e.tagData.TagList)
{
string tagUidStr = "";
foreach (byte tagUid in id.Uid.Data)
{
tagUidStr += string.Format("{0:x2}", tagUid);
}
if (getListBoxItem(lstFoundTags, tagUidStr) < 0)
{
setListBoxItem(lstFoundTags, tagUidStr);
_readCount++;
}
}
}
}
Points of Interest
Hopefully, it wasn't too painful to read, and can be useful for someone. I found a very welcoming support from the company as well. Thanks to the Psion Teklogix support team.