2022-03-07 05:05 PM
Hi! I develop access system using NFC(14443-A) tags on Windows(.NET) platform + USB ST25R3911B-DISCO. I need simple API to read/write my data to the tag (like person name or ID, nothing secure). What API(and library) I have to use? I'm lost in all possible libs. :( I successfully run (and understood) demo 'Demo_dll_main.cs', but I need write sample too (no any secure things, just plain data). Thanks!
Solved! Go to Solution.
2022-03-14 02:39 PM
Hi,
t2tRead4Pages and t2tWritePage are exported in the ST25R391x_Interface.cs used for ST25R3916-DISCO whereas you are using the ST25R3911B-DISCO with ST25R3911_Interface.cs. Sorry for having mixed up the 2 different Discovery boards and the 2 DLL interfaces.
ST does provide a lot of examples of reading and writing tags of various technologies for embedded applications (i.e. C code and libraries for MCUs connected to ST25R3911B expansion board). On PC side, the ST25 SDK based on ST25R3911DISCOComm.dll provides a Java API to communicate with tags of various technologies (T2T, T4T, etc.) over the ST25R3911B-DISCO. Unfortunately, for C#, the demo code only provides tag inventory and entry points to the DLL. As previously said, you can use rfalTransceiveBlockingTxRx from the DLL to send arbitrary commands to the tag but this supposes to know the commands set of the tag and to encode/decode the various commands and responses.
I would suggest to contact your local ST sales and marketing to have a local support for your application.
Rgds
BT
2022-03-15 02:04 AM
Hi,
for completeness:
the t2t* functions are exported by the DLL but not used inside the C# code. Feel free to add them to C# (C headers are available).
BR, Ulysses
2022-03-17 02:05 AM
Brian, I carefully checked both SDK (for ST25R3911 and ST25R391x), but substring "t2tRead4Pages" mentioned only in these files:
ST25R3916DiscoComm.h
ST25R391x_Interface.cs
CSharp_Dll391x_Demo.exe
ST25R3916DISCOComm.dll
ST25R3916DISCOComm.lib
DLL_Interface.py
ST25R3911DiscoComm.h
ST25R3911_Interface.cs
ST25R3911DISCOComm.dll
ST25R3911DISCOComm.lib
ST25R3911DISCOComm.h
ST25R3911DISCOComm.dll
ST25R3911DiscoComm.h
ST25R3911DISCOComm.lib
ST25R3916DiscoComm.dll
ST25R3916DiscoComm.h
ST25R3916DiscoComm.lib
Not a single of 'em corresponds to... what you say "ST does provide a lot of examples of reading and writing tags". There is no any sample for reading/writing raw data.
Can ST take care of own SDK and provide useful sample of working with NFC? Just reading card UID is ridiculously small, more advanced example is needed. Can you provide any sample?
I wouldn't bother you if I could google code, but... funny, but eben google don't have even single line with "t2tRead4Pages"! So in a whole world there is not even single line of reading NFC??
2022-03-17 02:26 AM
Yep, that's what I did! But my own usage of the function produces only error "NoMessage" :( This is my code:
uint data_len = 32;
var card_data = new sbyte[data_len];
ErrorCode = ST25R3911_Dll.t2tRead4Pages(Handle, 0, card_data, ref data_len);
if (ErrorCode == ST25R3911ComError.NoError) {
Console.WriteLine("I read: " + card_data.Take((int)data_len).Select(b => ((byte)b).ToX()).Join(" "));
} else {
Console.WriteLine("Error reading data: " + ErrorCode);
}
2022-03-17 02:32 AM
I modified your existing example and just insert code for reading. This is more descriptive code: https://pastebin.com/DFjH6GKW
2022-03-17 02:43 AM
Hi,
cannot access this pastebin.
Calling the t2t* functions is only possible after having found the card. Looking at our demo code you should be able to insert this code before the ST25R391x_Dll.iso14443aHalt() call (after ST25R391x_Dll.iso14443aSelect()).
BR, Ulysses
2022-03-17 02:56 AM
Pastebin is public, why you cannot access? I opened it w/o issues. But OK, I paste it here (it will be long):
if ((UsedProtocols & (uint)NfcProtocols.eProtocol_14443A) != 0)
{// Scanning ISO 14443 Type A
byte[] uid = new byte[16];
byte[] atqa = new byte[2];
byte[] sak = new byte[3];
LocalFound = 0;
ErrorCode = ST25R3911_Dll.iso14443aInit(Handle);
while (ErrorCode == ST25R3911ComError.NoError)
{
bufflen = (uint)uid.Length;
ErrorCode = ST25R3911_Dll.iso14443aSelect(Handle, (byte)NfcCmd.eREQA, true /*Anticolision*/, uid, ref bufflen, atqa, sak);
if (ErrorCode != ST25R3911ComError.NoError)
break;
// Card found display UID
Demo_dll.DumpBuffer(uid, bufflen, 0, ref StrOut, false);
if ((sak[0] & 0x24) == 0x20)
{
Console.WriteLine("14443-A UID={0} (size = {1})", StrOut, bufflen);
}
else
{
Console.WriteLine("14443-A UID={0} (size = {1}) NOT compliant with ISO/IEC 14443-4", StrOut, bufflen);
}
// Igor code
uint data_len = 32;
var card_data = new sbyte[data_len];
ErrorCode = ST25R3911_Dll.t2tRead4Pages(Handle, 0, card_data, ref data_len);
if (ErrorCode == ST25R3911ComError.NoError) {
Console.WriteLine("I read: " + card_data.Take((int)data_len).Select(b => ((byte)b).ToX()).Join(" "));
} else {
Console.WriteLine("Error reading data: " + ErrorCode);
}
bufflen = (uint)buffer.Length;
ErrorCode = ST25R3911_Dll.iso14443aHalt(Handle, buffer, ref bufflen);
++LocalFound;
}
ErrorCode = ST25R3911_Dll.iso14443aDeinit(Handle, KeepRFOn);
TotalCard += LocalFound;
}// end Scanning ISO 14443 Type A
As you see, code was exactly as you recommend - read before "iso14443aHalt".
2022-03-17 03:00 AM
At line "uint data_len = 32;" I tried another buffer lengths: 64, 128, 256 - no luck.
2022-03-17 03:09 AM
Hi,
did you verify the card is a T2T - readable from T2T tab of ST25R3911B-DISCO GUI?
Br, Ulysses
2022-03-17 04:05 AM
On the card I read "Type 4 tag, 14443-A". I guess T2T is "Type 2 Tag"? Then I have T4T card. But even at "ISO 14443-A" tab I cannot read anything - I press "Configure" and get nothing. GUI shows too much info and I cannot work with it - I do not understand items.
Anyway... if I have "Type 4" card how I suppose to write info?