Hello,
my name is Frederic. For two weeks I've been working on the task to read the tag, and a stored link, of an active NFV TI Chip. I also have a problem reading the ATR.
My reader is a Springcard H663.
I use the winScard.dll and managed to use SCardEstablishContext() and SCardConnect() sucessfully to get to work, including them as an wrapper.
Now I have issues for a week and nothing is moving forward.
I do not know how to access the tag or the stored Information or which values to give to the function.
[StructLayout(LayoutKind.Sequential)]
public struct SCARD_IO_REQUEST { public int dwProtocol; public int cbPciLength; } and
[DllImport("WinScard.dll")] public static extern int SCardTransmit( IntPtr hCard, ref SCARD_IO_REQUEST pioSendPci, ref byte[] pbSendBuffer, int cbSendLength, ref SCARD_IO_REQUEST pioRecvPci, ref byte[] pbRecvBuffer, ref int pcbRecvLength); are the implementation of the io structure and the wrapper.
This is the way I tried to access the information:
internal static void _readtag(string readername) {
IntPtr phCard = IntPtr.Zero; IntPtr activeProtocoll = IntPtr.Zero; try { get_readerconnection(readername, (uint)PROTOCOL_T1 ,phCard, activeProtocoll);// SCardEstablishContext and SCardConnection int Rueckgabewert; SCARD_IO_REQUEST ioRequest = new SCARD_IO_REQUEST(); ioRequest.dwProtocol = (int)wrapper.PROTOCOL_T0; ioRequest.cbPciLength = 8; byte[] commandBytes = new byte[] { 0xFF, 0xCA, 0x00, 0x00, 0x00 }; byte[] reciveBytes = new byte[10]; int rcvLenght = 0; Rueckgabewert = SCardTransmit(phCard,ref ioRequest, ref commandBytes,commandBytes.Length, ref ioRequest, ref reciveBytes, ref rcvLenght); if (Rueckgabewert != 0) Console.WriteLine("Failed querying tag UID: " + Error_in_String((uint)Rueckgabewert)); Console.WriteLine(Methoden.ByteToString(reciveBytes)); wrapper.SCardDisconnect(phCard, 0); } finally { wrapper.SCardReleaseContext(phCard); } return; To be complete I show you my ByteToString function:
public static string ByteToString(byte[] ByteArray) { ASCIIEncoding ascii = new ASCIIEncoding(); string multi_string = ascii.GetString(ByteArray); return multi_string; } also my get_readerconnection(...) function:
internal static void get_readerconnection(string readername, uint Reader_Protocol ,IntPtr phCard, IntPtr ActiveProtocol ) { try { phCard = IntPtr.Zero; ActiveProtocol = IntPtr.Zero; IntPtr hContext = get_hContext(); // using mode =2 // readerprotocol =3 int result = SCardConnect(hContext, readername, 2, Reader_Protocol, ref phCard, ref ActiveProtocol); Error_in_String((uint)result); } catch { } } My problem is how do I adress the _readertag(..) function for getting the tag, the link or the ATR.And how can I display the result?
I searched the web, but most of the codes are to far advanced for me to understand and msdn does not help me, also the code on code-project is to complicated for me.
I would be very thankful for your help!
Frederic