Menu

Arduino whit APDU CODES

2018-06-17
2022-01-30
1 2 > >> (Page 1 of 2)
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    i need read card data whit arduino ...

    i am using aptu_t0_communication.ino. my lib SCl0.0.7rc4.

    everythink is ok.. but only i can take ATR code..(but today not working.)
    i am using pin 8 manual true and false)

    i want to chose File 3f10-3f20-2f11 . i didnt .


    i read data whit c# . for example my apdu codes for c# and working...

    byte[] cmdApdu = { 0X00, 0Xa4, 0X08, 0X00, 0X06, 0x3D, 0x10, 0x3D, 0x20, 0x2f, 0x10,00 };
    // select file
    scard.Transmit(cmdApdu, cmdApdu.Length, respApdu, ref respLength);

    byte[] cmdApdu3 = { 0X00, 0XB0, 0X00, 0X04, 0x0A};
    // read file
    scard.Transmit(cmdApdu3, cmdApdu3.Length, respApdu3, ref respLength3);
    //My data
    tc = Encoding.UTF8.GetString( respApdu3);

    ////

    i want to make same read operation ..

    ...

    i am using Uno. and i dont know my chart chip....

     

    Last edit: Fatih GÜNGÖR 2018-06-17
    • Darren

      Darren - 2022-01-30

      Hi Fatih, I wish you could send me or post the pinout of your project, in 2004, i got this card read from an ex girlfriend, she got it from her farher working on the phone company in my country and it seems to be just straight to the pine output, without any chip, something similar to your project, i just found out that has two 103 capacitors attached seeks like in parallel to VCC, will be great if you could help me, I saw that you followed Angus great project and library, but im kinda lost, because seems like need 3 100khom resistors, Thanks im a advance and best regards.!

       
      • Darren

        Darren - 2022-01-30

         
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    I've delete the images just for "not" showing them to all ... ;-) ... I've had a look on them, so we can discuss them later on ...

    Can you share the connection to the Arduino (Card "pad" to Arduino pin) and the used frequency selected in the header file of the Arduino?

    Regards

     

    Last edit: angus71 2018-06-17
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    finnaly i added my fotos :D

    115200 my arduino boud.

    define SC_C2_RST 7

    define SC_C1_VCC 11

    define SC_C7_IO 10

    define SC_C2_CLK 9

    connections

    pin 8 manuel true and false

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    my ATR

    Received ATR ...
    00|3B 9F 97 81 31 FE 45 80 65 54 43 D2 21 08 31 C0 ';...1.E.eTC.!.1.'
    10|73 F6 21 80 81 05 5B 's.!...[.........'
    SELECT FILE Command ...
    Received ... 0
    this is true because i read whit c# appliatins..

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    my header file

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    and my last serial status.

    my arduino select file codes

    // We just use the T=0 byte transfer
    command.cla       = 0x00;
    command.ins       = 0xA4;
    command.p1        = 0x08;
    command.p2        = 0x00;
    command.data_buf  = data;
    command.data_size = 7;
    command.resp_size = 0x100;
    
    data[0] = 0x06;
    data[1] = 0x3D;
    data[2] = 0x10;
    data[3] = 0x3D;
    data[4] = 0x20;
    data[5] = 0x2F;
    data[6] = 0x10;
    
     

    Last edit: Fatih GÜNGÖR 2018-06-17
    • angus71

      angus71 - 2018-06-17

      Hi Fatih,

      Are you sure you need

      command.resp_size = 0x100;
      

      as this will "trigger" a wait for 256 bytes, which are normally not provided by a "SELECT FILE" command, they will be send by a "GET RESPONSE" ... So as in the example I would recommend a resp_size of "0".

      Regards

      Angus71

       
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    my ATR analys

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17
    command.cla       = 0x00;
    command.ins       = 0xA4;
    command.p1        = 0x08;
    command.p2        = 0x00;
    command.data_buf  = data;
    command.data_size = 7;
    command.resp_size = 0;
    
    data[0] = 0x06;
    data[1] = 0x3D;
    data[2] = 0x10;
    data[3] = 0x3D;
    data[4] = 0x20;
    data[5] = 0x2F;
    data[6] = 0x10;
    
    i changed..  but result is same ..
    
     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    Can you go one step back and use the code-sniplet provided (Based on the original T0 example), this should select a "default" file, just to see if the "Select File" command works and there might just be a "problem" with the file name/command you use ... :-)

        // We just use the T=0 byte transfer
        command.cla       = 0x00;
        command.ins       = 0xA4;
        command.p1        = 0x04;
        command.p2        = 0x00;
        command.data_buf  = data;
        command.data_size = 2;
        command.resp_size = 0x00;
    
        data[0] = 0x3F;
        data[1] = 0x00;
    
        Serial.println("SELECT FILE Command ...");
        uint16_t result = sc.sendAPDU(&command);
    
        Serial.print("Received ... ");
        Serial.println(result, HEX);
    

    Regards

    Angus71

     
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    Based on your C# code I expect the command you use should be

    command.cla       = 0x00;
    command.ins       = 0xA4;
    command.p1        = 0x08;
    command.p2        = 0x00;
    command.data_buf  = data;
    command.data_size = 6;
    command.resp_size = 0;
    
    data[0] = 0x3D;
    data[1] = 0x10;
    data[2] = 0x3D;
    data[3] = 0x20;
    data[4] = 0x2F;
    data[5] = 0x10;
    

    As it looked like you put the command size as the first entry into the data

    Regards

    Angus71

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    i tryed 2 sample.. but result is same..

    :(

    Waiting for Smartcard
    Smartcard found
    Received ATR ...
    00|3B 9F 97 81 31 FE 45 80 65 54 43 D2 21 08 31 C0 ';...1.E.eTC.!.1.'
    10|73 F6 21 80 81 05 5B 's.!...[.........'
    SELECT FILE Command ...
    Received ... 0

    what is wrong. :(
    maybe this is t=1 protokol must be.

    but i used same apdu codes but protokol t=1 whit c#..
    what change code for t1 protokol

    and pin 8 always true... ok

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    This should quite simple, just try the t1 example?

    examples/apdu_t1_communication/apdu_t1_communication.ino and fill in your command from c# into the "data", just as you give it there ...

    Regards

    Angus71

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    where is t1 example ????
    opss
    i found trunk exapless.

    i will try ......

    thanksssssssssssssssssssssss angus
    thank you very much
    ......
    and thanks for patience....

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    YES...
    step step contiouning angus...

    i tryed t1 ..and my result...

    Waiting for Smartcard
    Smartcard found
    Received ATR ...
    00|3B 9F 97 81 31 FE 45 80 65 54 43 D2 21 08 31 C0 ';...1.E.eTC.!.1.'
    10|73 F6 21 80 81 05 5B 's.!...[.........'
    Checking for T1 - Protocol ... Supported
    Try to change IFS ... OKAY (Set to 0x20)
    Selecting AID D2 76 00 01 24 01 (OpenPGP) ...
    00|00 C1 01 FE 3E '....>...........'

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    my card
    3D0-3D20-2F10 my data adres.. and my data 34 33 33 33 33 38 37 35 35 35 - 90 00

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    where are you
    god's of the arduniooooooooo

     
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    you are able to read the data ? That's sounds good..

    Regards

    Angus71

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    hi dear angus

    yes i read somethink but. i dont know what i read ..

    firstly..
    i must be select file
    later i read this file..

    here is only one procedure working here..

    for example.
    first i need select

    3D-10-3D-20-2F-10 file

    later i read

    00 0B 00 04 0A

    read command for abdu..

    i tyred a lot of variation but nope.. what is wrong..

    i changed bound ..

    i changed file adres

    i changed wrong codes . always same return same result.

    :(

    litte bit more help angus. i know you are busy.
    thanks for help..

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • angus71

    angus71 - 2018-06-17

    Hi Fatih,

    When I'm not mistaken, the "answer" you have seen is actually a "requet" of the card to set the "IFS" to 254, so that a "lot" of data can be transmitted via one command ...

    You can check if you get better results, when you change the IFS request in the example to the following ... So the card does not need to "request" an IFS change form it's side

    ~~~
    Serial.print("Try to change IFS ... ");

      // Offer the card to send a maximum of 0x20 bytes per block 
      // Node Adress 0 (Value 0xFE)
      if (sc.changeIFS(0, 0xFE)) {
        Serial.print("OKAY (Set to 0x");
        Serial.print(sc.getCurrentIFS(), HEX);
        Serial.println(")");
      } else {
        Serial.println("FAILED");
      }
    
      delay(100);
    

    ~~~

    Regards

    Angus71

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-17

    hi angus ..

    same result.. :( i am trying diffrent thinks.

    response wrong.
    for example. i am changeing worng apdu codes .. giving error message .. correct
    but i am chanceing true apdu codes . giving diffrent data ...

    :(
    i will not sleep to night...i must be fix this..
    thanks

     

    Last edit: Fatih GÜNGÖR 2018-06-17
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-18

    Hİ ANGUS

    tryed alot of think apdu codes...

    delay(100);
    
           // Fill command into user data
      b = 0;
      data[b++] = 0x00;
      data[b++] = 0xA4;
      data[b++] = 0x08;
      data[b++] = 0x00;
      data[b++] = 0x06;
      data[b++] = 0x3d;
      data[b++] = 0x10;
      data[b++] = 0x3d;
      data[b++] = 0x20;
      data[b++] = 0x2f;
      data[b++] = 0x10;
      data[b++] = 0x00;
      Serial.print("Select File  :  (OpenPGP) ... ");
      sc.send_IBlock(0x00, data, b);
    
      bytes_received = sc.receiveBytes(data2, 255);
      Serial.print("Response  : ");
      Serial.println(bytes_received);
    
        sc.dumpHEX(data2, 56);
    

    delay(1000);

    b = 0;
      data[b++] = 0x00;
      data[b++] = 0xb0;
      data[b++] = 0x00;
      data[b++] = 0x00;
      data[b++] = 0x00;
    
      Serial.print("Select File  :  (OpenPGP) ... ");
      sc.send_IBlock(0x00, data, b);
    
        bytes_received = sc.receiveBytes(data2, 255);
      Serial.print("Response  : ");
      Serial.println(bytes_received);
    
        sc.dumpHEX(data2, 56);
    

    delay(1000);

    ////////////////// but result is sameeeeeeeee

    i changed frequance
    i changes codes
    i changed parameters..

    what is wrong.. what is worng..

    same car working on c# .. damm.. same abdu command..

    :(

     
  • Fatih GÜNGÖR

    Fatih GÜNGÖR - 2018-06-18

    i will be crazy

    what is this respond dammmm
    00| 00 C1 01 FE 3E EF

    this respond must be 90 00 but i am takeing this message...
    rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.