Menu

One problem

H. Duboff
2012-10-31
2014-06-11
  • H. Duboff

    H. Duboff - 2012-10-31

    Hello.

    I was successfully able to read the ATR (Answer to Reset) from an Atmel AT88SC0104C, with one problem. The ATR should start with 3B (I read it using other readers) but this routine displays the ATR with "0B" as the start of the ATR. Can you give any suggestions?

     
  • Jose Juan Calvo

    Jose Juan Calvo - 2012-11-02

    Hello,

    I have the same problem. I have a Gemalto Gemclub card with ATR 3B 02 53 01 and I recover only 02 53 01, so the problem is the same.

    Best Regards

     
  • angus71

    angus71 - 2012-11-02

    Hi ..

    It's nice to hear that somebody is actually using my code ;-.)

    I will have a look into the issue and hopefully I will come up with a solution for your problems in the near future (tomorrow).

    Best Regards

     
  • angus71

    angus71 - 2012-11-03

    Hello,

    as promised I checked the code and found the problem you are facing.

    I didn't include the TS byte (0x3B for normal signal and 0x3F for inverted signal) in the ATR response from the smart card. The code was updated to 0.0.5 to include the missing TS byte in the ATR response given to the application. This can be changed back to the old behaviour, if includeTSinATR(false) is called on the smartcard object.

    Also the return value of the activate(..) function was changed to uint16_t to give the number of received bytes.

    I hope the mentioned problems are solved if you update to 0.0.5, if any other problems occur just let me know.

    Best Regards

     
  • Jose Juan Calvo

    Jose Juan Calvo - 2012-11-03

    Hello Angus,

    That's great. It works fine. Now the activate function returns the ATR 3B 02 53 01.

    Only one more problem. You change in the sample loop this code:

    void loop() {
    uint16_t atr_received = 0;
    digitalWrite(DEFAULT_DEBUG_PIN, HIGH);

    If I insert the card incorrectly (the chip backwards), the dumpHEX function begins to write characters to the console constantly. This is because in normal mode the function

    atr_received = sc.activate(data, MAX_ATR_BYTES);

    returns 4 bytes, but if I insert the card backwards, the function returns 65535.

    And finally, how can I send APDU commands to the card? Some sample can be interesting.

    Thank you and best regards!

     
    • angus71

      angus71 - 2012-11-04

      Hello Jose Juan,

      With the update to 0.0.6 your problem should be fixed. I only updated the async. cards activation in 0.0.5 to uint16_t and forgot about the sync. cards activation.

      Also a new example (SCTest2) was added, which includes a little APDU code, but no communication protocol implementation.

      Hope that helps you with your project.

      Best regards

       
  • Jose Juan Calvo

    Jose Juan Calvo - 2012-11-04

    Hello Angus.

    Good Job!!!!! It works like a charm.

    I want to read a GemAlto GemClub card. When I finish it, I send you a complete sample.

    Thank's and best regards

     
    • angus71

      angus71 - 2012-11-10

      Hello Jose Juan,

      If you still work on your project you might want to check out the new 0.0.7rc1 release, which includes basic T=0 communication support (See SCTest2 for a small example).

      Currently no full featured error handling, but it's working with all the T=0 cards I could get my hands on.

      Best regards

       
  • tavovalencia

    tavovalencia - 2013-01-23

    Hello Angus,
    I'm sorry I wrote so many things on the wiki and not here... I tried sending you a message via sourceforge.net system (failed) and via angus71@users.sourceforge.net (also failed)

    I don't mind writing some stuff here:

    1- I'm using Arduino Leonardo (very similar to UNO), and SLE4428 (these are similar to SLE4442 but with more EEPROM (1024 vs 256 bytes)

    2- The cards are "synchronous" so by what you wrote I should assume that everything is working as it is supposed to... SCTest2 (discarded - only for asynchronous).

    The thing is that I need to Read/Write the rest of the info from the cards. I've seen some methods and functions on the keywords.txt but I don't know how to implement. Any ideas? All the help is much appreciated!

    I have attached a flowchart of what I'd like to be able to do with the SmartCards. For my script "TIME" is sort of a currency (I need to limit the usage on a time stamp basis).

     
  • Pulkit Prajapati

    Hello Angus

    whenever i used example code there is so many error so could not do further.please help me.

     

    Last edit: Pulkit Prajapati 2013-06-22
    • Stellaras

      Stellaras - 2013-12-30

      Dear Pulkit Prajapati,
      I just want to pinpoint the mistakes I made as a newcomer to Arduino. Please read this link so that you see the correct structure that the library files require in order to be compiled correctly.

      http://arduino.cc/en/Guide/Libraries).

      Thank you.

      Stellaras

       
  • Stellaras

    Stellaras - 2013-12-26

    Greetings to everyone. I just want to say that I am new to Arduino. I have experience though with microcontrollers. I have a few questions and I would appreciate any help I can get.

    1. For the code is there a difference if I am using IDE 1.0.5 or 1.5.5?
    2. I am using Arduino Mega 2560.
    3. I keep receiving the following error message
      "Arduino: 1.5.5 (Windows 7), Board: "Arduino Uno"

    C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=155 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\STELIO~1\AppData\Local\Temp\build3867136129851584027.tmp\apdu_t0_communication.cpp -o C:\Users\STELIO~1\AppData\Local\Temp\build3867136129851584027.tmp\apdu_t0_communication.cpp.o

    apdu_t0_communication.ino:23:2: error: #error This example only works if ASYNC_CARDS and APDU_SUPPORT is enabled in SCLib.h
    apdu_t0_communication.ino:27: error: 'SmartCardReader' does not name a type
    apdu_t0_communication.ino: In function 'void loop()':
    apdu_t0_communication.ino:38: error: 'APDU_t' was not declared in this scope
    apdu_t0_communication.ino:38: error: expected `;' before 'command'
    apdu_t0_communication.ino:49: error: 'sc' was not declared in this scope
    apdu_t0_communication.ino:59: error: 'sc' was not declared in this scope
    apdu_t0_communication.ino:59: error: 'MAX_ATR_BYTES' was not declared in this scope
    apdu_t0_communication.ino:71: error: 'command' was not declared in this scope

    Thank you in advance for your time and help.

     
    • angus71

      angus71 - 2013-12-30

      Hi Stellaras,

      I just installed the above mentioned Arduino 1.5.5 version imported the sclib 0.0.7rc3 lib and compiled the apdu_t0_communication example and compiling worked out okay ... (I just had to rename the 0.0.7rc3 folder to sclib ;-.) )

      But looking on your error message this is quite strange, as there is a typo in the apdu_t0_communication example. The preprocessor commands in the lines 22ff should be

      #if !defined(ASYNCHRON_CARDS) && !defined(APDU_SUPPORT)
      #error This example only works if ASYNCHRON_CARDS and APDU_SUPPORT is enabled in SCLib.h
      #endif
      

      but based on the rest of the error message the APDU_SUPPORT define is missing (Did you modify the SCLib.h and removed the ASYNCHRON_CARDS define in SCLib.h:38 or the APDU_SUPPORT define in SCLib.h:44?

      Just let me know, if this fixed it for you

      Angus

       
  • angus71

    angus71 - 2013-12-30

    Hi Stellaras,

    Can you try to use the current trunk version, as the 0.0.7rc3 problems should be fixed in this version?

    Angus

     
  • Stellaras

    Stellaras - 2013-12-30

    Dear Angus, I would like to thank you very much for your prompt response. Also, I appreciate your patience and help despite the fact that I am new to Arduino.
    Since, I posted the message I have done a lot of reading as well and resolved a couple of issues. This link (http://arduino.cc/en/Guide/Libraries) would also be useful for "Pulkit Prajapati".

    I will try the code and I will report my findings right away.

    Once, again thank you.

    Stellaras

     
    • Stellaras

      Stellaras - 2013-12-30

      Dear Angus, I am in the happy place to report that the code compiles ok. I guess maybe when I was reading the code I accidentally change something :(

      I have re-downloaded the latest version as you suggested and it works fine.

      Thank you very much.

      Stellaras

       
  • José Rodrigues

    José Rodrigues - 2014-05-28

    HI angus71, great job,
    I'm trying to develop a similar project to read smart cards, I'm working with EvolutionPad LM4f120XL-EK of Texas Instruments, which has similar Arduino IDE, called 'Energia'. It is possible to use Arduino libraries, but I am having problems using 'SCLib.h'. The errors I'm getting are attached, you think you know what the problem is?

    Thank you very much,

    José Rodrigues

     
  • angus71

    angus71 - 2014-05-28

    Hi José,

    I think the problem might be, that the Smart Card Lib. is using some of the internal features of the Arduino (Or better it's processor) to meet the timing requirements, so it might be hard to use it in an "not" Atmel Environment as you are doing ...
    The compile errors you are facing are based on missing defines for "internal" processor registers. This might be hard to fix in your environment, but not impossible ;-.)
    The main reason I used some internal registers directly and not "predefined" functions is "speed" as this was needed to get to "higher" clock rates ...

    If you want to port the code to your environment I can't support that much as I don't have any access to the mentioned development environment, but the main function you have to convert is the clock generation ...

    Please let me know if you need more information, regarding the porting of the code, if so please open a new discussion, so that not all information is in the "one problem" discussion ;-.)

    With kind regards

    angus71

     
  • José Rodrigues

    José Rodrigues - 2014-05-29

    Hello angus71,
    thanks for the reply, I will use an Arduino.
    thank you

     

    Last edit: José Rodrigues 2014-06-03
  • José Rodrigues

    José Rodrigues - 2014-06-11

    Hi angus71,

    I have a problem accessing the card.
    I get this:

    Waiting for Smartcard
    smartcard found
    ATR received ...
    00 | 3B 7D 95 00 00 80 31 80 65 B0 83 11 00 C8 83 00 ';} .... 1.e. ......'
    10 | 90 00 '................'
    SELECT FILE Command ...
    Received 6A86 ...

    the "6A86" means Incorrect P1 P2, but I'm sending this:

    / / We just use the T = 0 byte transfer
         command.cla = 0x00;
         command.ins = 0xa4;
         command.p1 = 0x00;
         command.p2 = 0x00;
         command.data_buf = date;
         command.data_size = 0x02;
         / / command.resp_size = 0x100;

         data [0] = 0x3F;
         data [1] = 0x00;
    If an attempt to send this command with a usb reader it answers the following:

    a("00a40000023F00")
    6F 3F 12 83 02 00 8C 03 06 00 00 84 07 60 46 32 FF 00 00 02

    I get the same problem with the USB reader, if connect the card twice consecutively. Do not know why!

    Do you have any idea what can be? I've tried changing the frequency to 4Mhz, but if I see in the oscilloscope does not change of 1 MHz. :(

     
    • angus71

      angus71 - 2014-06-11

      Hi José,

      Basically I would say that the communication itself looks good, as the ATR was correct received. Also decoding the ATR showed that the card should support up to 5MHz, so the used 1MHz looks okay too. ( I would recommend to stay with 1MHz until it works and than maybe change to a higher frequency ).

      I need some more informations regarding the card and the setup to help you ...

      Are you sure the card supports T=0 communication?

      Is any PPS needed to setup a the protocol parameters?

      What type of card you are talking to? (I've heard from people using JavaOS based cards, having trouble communicationing with them ... If you don't want to share the exact type of card it's okay with me, but some basic card type info would help).

      What type of Arduino are you using and how is the smart card connected to it (Pin assignment)?

      With kind regards

      Angus71

      PS: Please open a new discussion for this topic, so that the information is in one place ;-.)

       

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.