cancel
Showing results for 
Search instead for 
Did you mean: 

Simple C# interface for read/write - what to use?

DDve.1
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

iso14443 does not specify anything about reading and writing memory. NFC Forum defines standard card types on the basis of pre-existing proprietary cards, e.g. T2T interface for MifareUltralight and others. T4T for cards basing on a smartcard interface implementing T=CL/ISODEP/Layer4.

The tab I mentioned previously is called "Nfc Type 2" in the 3911 GUI.

I think you have two options: Become a member of NFC Forum, download the specs - especially NFC Forum T4T, and use it to implement your own procedures to read/write T2Tag, T4Tag, ....

Or base on other software, either the ST25 SDK or the embedded ST25 NFC Lib which are implementing these procedures. The aim of our "Disco" deliveries is to discover the reader chip, not to provide stacks and all the high-level procedures to read all possible tags in the world.

Regards, Ulysses

View solution in original post

21 REPLIES 21
Ulysses HERNIOSUS
ST Employee

Hi,

one possibility would be the ST25 SDK but then you are in the Java world. I am not aware of C# code to achieve exactly what you are wishing for.

Also what exactly to do you want to achieve on which tags? There are a plethora of different tags (T4T and T2T are NFC Forum definitions of standards for ISO14443-A tags) around and it depends how you want to write the data:

  • Do you want to write NDEF data? (To be readable by mobiles?)
  • Your own proprietary write scheme? For which tags exactly?

If it comes to NDEF then inside the ST25 Embedded NFC lib are examples how to read/write NFC Forum tags (T2T, T3T, T4T, T5T).

BR, Ulysses

Fortunately you have "ST25R3911_Interface.cs" - it has all functions exported from ST25R3911DISCOComm.dll. I hope they are enough for my task.

I'm noob in NFC world, I cannot say what tags I have - some noname cards, which give output:

14443-A UID (size = 4)  NOT compliant with ISO/IEC 14443-4

What I 100% sure I do not need any NDEF or any bank standards. Like I already said, I need just ability to write my custom data on the tag. Type of tag is known - 14443-A.

Have you any sample to write info on such card? I cannot deep in Java-world, sorry 🙂 Solution should be C# only.

Previously I had experience w ACR122(reader). To write data they have quite handy API:

PCSCReader reader
reader.SaveKeyToReader(0, Fmt.Hex2Bin("FFFFFFFFFFFF"));
reader.AuthBlockAccess(7, NFCKey.A, 0);
reader.WriteCardBlock(7, "123");

I guess ST has no such API, but I'm ready to work on lower level. As you see I need almost nothing - just write my "123" in 7th block. 🙂 Please show some sample using "ST25R3911_Interface.cs" - I cannot realise at all what to do with all those functions.

Hi,

the shown code snippet refers to a Mifare Classic card with its proprietary crypto. The chip supports all the framing but the crypto is up to you.

There is no one way recipe of writing tags. For T2T you will find convenience functions t2tRead4Pages(), etc. which you can execute after having discovered the tag. For T4T you can use the isodep example and send T4T commands on top.

BR, Ulysses

Ulysses, sorry, I sent 3 messages, but still got not a single line how to write simplistic data on the NFC tag. Is it possible to do it from C#?? You have "ST25R3911_Interface.cs" which is "bridge" to real functions. My question is simple: WHAT AND HOW to call to write data on NFC tag? Please don't spread into variants, just ST25R3911-DISCO reader and 14443-A. That's it. Does ST has solution for .NET??

Brian TIDAL
ST Employee

Hi,

As explained by Ulysses, ISO 14443-A does not define a tag type but a communication protocol: the tag memory layout and the way to read/write from/to a tag memory depends on the tag type. The sample code you have provided in your post does not work for every ISO 14443-A tags but only for a Mifare Classic tag which has a proprietary memory layout and a proprietary crypto. If your question is 'Does ST has an API to read/write Mifare classic tag on ST25R3911B_DISCO?" , I am sorry to say "No" because this would violate legal rules. As mentioned by Ulysses, I would suggest to use a T2T tag such as ST25TN if your application does not require crypto.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi, Brian! Thanks for explanation. My code sample was just demo of real C# API (and how convenient it should be). You narrow my question, while it was more generic: I need C# sample on how I can write data on NFC card. Let's assume I have mentioned T2T tag. How I can read and write data on such card? Short C# sample could be fine, please. Currently ST provides VERY limited sample "how to read card UID". Unfortunately list of functions in ST25R3911DISCOComm.dll doesn't give me anything.

Brian TIDAL
ST Employee

Hi,

There is no ready to use demo fitting your needs, but as explained by Ulysses, for a T2T tag, you can use t2tRead4Pages for a 4 blocks read (and t2tWritePage for a single block write).

You can also use rfalTransceiveBlockingTxRx to send arbitrary command to the tag.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Brian, I'm not sure you're aware what is contained in C# demo. It has "ST25R3911_Interface.cs" - wrapper for ST25R3911DISCOComm.dll; But this wrapper has not a single function you mentioned. All I found related writing is:

iso14443bWriteAttrb iso15693WriteBlock topazWriteByte

While all my tags are 14443-A. Can you please clarify, what is completion status of "ST25R3911DISCOComm.dll"? I need to write 14443-A tag with ST25R3911DISCO reader, but this simplistic task has too much problems. There is no even the "C" code for that. Guessing algorithm from function names also pointless. That's why I need professional support with this task. Can anybody provide it? I need just short samples reading/writing tags, it is primary functions of NFC - pity they still not reflected in a demo.