Gemalto is now part of the Thales Group, find out more.

You are here

Send APDU command and get a correct response with Gemalto smartcard IAS-ECC | Thales IoT Developer Community


July 16, 2014 - 12:46pm, 7278 views

Hi, I'm a newbie on smart card development. Currently, I try desperately to communicate with a smartcard Gemalto by using a serial port. The reader is placed on a Gen2Wave RP1300 and I developp in C# with Dotnet 3.5 (Compatct Framework). I have succedded to get atr programmatically, but when I've sent a command to the smart card (for example to check if pin is correct), I obtain always the same answer: the smart card send to me the answer! Here my code: SerialPort serialPort1 = null; serialPort1 = new SerialPort("COM3"); serialPort1.BaudRate = 9600; serialPort1.DataBits = 8; serialPort1.DtrEnable = true; serialPort1.RtsEnable = true; serialPort1.ReadBufferSize = 4096; serialPort1.Parity = Parity.None; serialPort1.Handshake = Handshake.None; serialPort1.StopBits = StopBits.One; serialPort1.Encoding = Encoding.ASCII; serialPort1.ReceivedBytesThreshold = 1; serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); serialPort1.ReadTimeout = 500; serialPort1.WriteTimeout = 500; if (!serialPort1.IsOpen) serialPort1.Open(); // Check if PIN is correct serialPort1.Write(new byte[] { 0x03, 0x20, 0x00, 0x02, 0x08, 0x31, 0x30, 0x35, 0x34, 0xFF, 0xFF, 0xFF, 0xEE }, 0, 13); .... private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { this.Invoke(new EventHandler(verifyChv)); } ... public void verifyChv(object s, EventArgs e) { byte[] buffer = new byte[serialPort1.ReadBufferSize]; int bytesRead = serialPort1.Read(buffer, 0, buffer.Length); foreach (int bf in buffer) { System.Diagnostics.Debug.WriteLine(bf.ToString("X");); } } When I launch my code, the only response that I have is the ATR! I've tried to send other APDU commands but result is the same. Can you explain me what is wrong? Thank you by advance for your answers. Best regards, Remi