SmartCardMBS - NFC Reader

Having moved on from NFC on iOS I now need to be able to read NFC tags on desktop (cross platform but worst case Windows is a must).

I came across a few threads, particularly this one where @Edwin_van_den_Akker gave an example project (thanks btw) that appears to work with MBS plugins. I say appears because the ACS reader beeps (good start!) and indeed writes an ‘id’ to the screen (see image below) but it is always the same id:

Anyone used MBS plugins successfully to then also read the data off them ? I tried the one example on the MBS site but it is not clear which instruction is being sent so I am flying blind on this tbh:

Any and all assistance gratefully appreciated:-)


1 Like

Also worth pointing out for anyone else looking into this and using SmartCardMBS, the example Transmit code is erroneous as-is. @Christian_Schmitz could you please update ?

This code gives the error: 80100019 which I believe equates to ‘The PCI Receive buffer was too small.’

If you and your team tested this code then maybe it’s the reader (but I have a feeling it’s fundamental and not reader specific error).


well hopefully you will get it fixed, we run similar problems where we ended having 70% of our customers complaining that cannot use the smart cards anymore, unfortunately no fix , no reply, no solutions, so we had to find other way around and dismiss the plugins in our case.

Best luck for you .

Ok well I am very conscious that @Christian_Schmitz has not responded to this thread and it’s good to know more than me have faced this issue.

The best I got to was forming the payload properly ( it is not in MBS docs above) so that error number is 0 which is no error but never any response codes or data back.

.Net is the best option for this for me for this I think.

Well, I have not much fun with Smartcards so far.

It’s always confusing. Our examples are written for the smart card we used for testing. The plugin seems to work fine for some users, but not others.

There is a general protocol defined for smart card, but we have seen several cards work differently and for the ID cards we patched function several times.

Anyway, if you know the protocol for your card, you can use SmartcardMBS or TKSmartCardMBS to do transfers. But it’s up to you to define the buffers.

@Christian_Schmitz Is there a list of cards you tested with?
That might be useful for the (potential) users, also helps users to order the right kind of cards.

1 Like

I tested several cards with my ACS ACR122 reader.
I noticed that the CardID provided by the status method of the SmartCardMBS class actually returned the ATR value.
After some digging around I found a “Transmit” way of getting the UID of the RFID card.

Public Function getID(card as SmartCardMBS, IncludeColon as Boolean = True) As String
  If card = Nil Then Return ""
  Var blockSize As UInteger = 8
  Var header As New MemoryBlock( 8)
  header.Int32Value(0) = 2 // T1
  header.Int32Value(4) = 8 // size of this block
  Var command As New MemoryBlock(5)
  command.Int8Value(0) = &hFF // Request data
  command.Int8Value(1) = &hCA // Request the UID
  command.Int8Value(2) = 0
  command.Int8Value(3) = 0
  command.Int8Value(4) = 0
  Var buffer As New MemoryBlock(1024)
  Var ReceiveHeader As New MemoryBlock(8)
  Var RecvLength As UInt32 = buffer.Size
  card.Transmit(header, command, command.Size, ReceiveHeader, buffer, RecvLength)
  If RecvLength = 0 Then Return ""
  // no length returned. So, no CardID passed back.

  Var id As String
  id = buffer.StringValue(0, RecvLength, Encodings.UTF8)
  Var info As String
  info = toHexString(id, IncludeColon, 2) // last parameter trims the 2 result / status bytes.
  Var code As Integer = card.Lasterror
  Var hCode As String = Hex(code)
   //  The hCode is for convenience only, it makes it easier to lookup the errorcode in the documentation I found online. 
  Return info
End Function

Private Function toHexString(mb as MemoryBlock, IncludeColon as Boolean = False, trimTail as Integer = 0) As String
  If mb = Nil Then Return "" 
   Var ss() As String
  Var h As String
  Var i As Integer
  For i = 0 To mb.Size-1 - trimTail
    h = "00" + mb.UInt8Value(i).ToHex.Uppercase
    ss.Add h.Right(2)
  Var sep As String = If(IncludeColon, ":", "")
  h = String.FromArray(ss, sep)
  Return h
End Function

So, when I need to get the actual cardID I use this:

Var CardID As String
CardID = GetID(myCard, True) // Returns: 04:23:91:DA:99:3D:80, in my case. Your ID will be different.
CardID = GetID(myCard, False) // Returns: 042391DA993D80

Some links I used to get the info I needed:

I used this tool to verify my UID

Wow! Thanks so much for this. I was having no luck getting my NFC reader to return anything. Your code works perfectly. Thanks!!!

1 Like