Solved

how to read GemClub Memo?

Posted on 2004-09-15
8
1,031 Views
Last Modified: 2008-02-07
how to read GemClub Memo card using GemPC433-SL usb reader with winscard.dll? i keep on getting error "SCARD_W_UNSUPPORTED_CARD" when i use the command

lngResult = SCardConnectA(lngContext, strCurrentReader, SCARD_SHARE_SHARED, _
                    SCARD_PROTOCOL_Tx, lngCard, lngActiveProtocol)
0
Comment
Question by:harsher
  • 4
  • 4
8 Comments
 
LVL 8

Expert Comment

by:BdLm
ID: 12063381
did you check if this card is sending an ATR.

controller cards (eg. Infineon SLE 66 series ) are sending an ATR after power on
like  3B 0B .....;
memory cards with Chips like 4442 oder 4428 or telephone cards do not send this response.

current release of pc/sc spec does not yet support memory cards, You have to wait for rev. 2 of this standard.  
0
 

Author Comment

by:harsher
ID: 12071825
ahahahah i found out i fogot to install the driver for the GemPC433-SL  reader... ehehhe

but now, my problem is how to insert/extract the data  from the card... ?
i know to write into the card is using

ApduComm.bCla = &H0
  ApduComm.bIns = &HDE
  ApduComm.bP1 = &H0
  ApduComm.bP2 = "&H" & lAddr
  ApduComm.Le = &H4

aand to read from card is using

ApduComm.bCla = &H0
  ApduComm.bIns = &HBE
  ApduComm.bP1 = &H0
  ApduComm.bP2 = "&H" & lAddr
  ApduComm.Le = &H4

but where do i put the data?

i will give more points if anyone can help me.
0
 
LVL 8

Expert Comment

by:BdLm
ID: 12073073


using pc/sc winscard.dll, follow these 3 steps, code is c++, but as I'm, just calling the dll functions there want be to many difference between basic and c.
(i must have somewhere some old vb 5 stuff, i 'll keep on searching my HD) to exchange data between reader and pc.
At the end release scard context.


1)  
//
//      Open a context which communication to the Resource Manager, get the reader names ...
//             and select a reader
  ....
  ret = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &ContextHandle);
  ShowSCardInfo(ret, ContextHandle, "Function SCardEstablishContext");

2)
//
//
//

   //  connect to the reader
  //   T=1, T=0  via RadioBox .... ?
  switch (MyselectedProtocolType)
  {
  case 0:
        ProtocolType = SCARD_PROTOCOL_T0;
        break;
  case 1:
        ProtocolType = SCARD_PROTOCOL_T1 ;
        break;
  case 2:
        ProtocolType = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
        break;
  case 3:
        ProtocolType = SCARD_PROTOCOL_RAW;
        break;

   case 4:
        ProtocolType = SCARD_PROTOCOL_UNDEFINED;
        break;

  default:
        ProtocolType = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
  }

  //  Shared or Exclusive .... ?
  switch (MyselectedAccessType)
  {
  case 0:
        AccessType = SCARD_SHARE_EXCLUSIVE;

        break;
  case 1:
        AccessType = SCARD_SHARE_SHARED ;

        break;
  case 2:
        AccessType = SCARD_SHARE_DIRECT;
        break;
  default:
        AccessType = SCARD_SHARE_EXCLUSIVE;

  }



  ret = SCardConnect(ContextHandle, ReaderName[act_Name], AccessType,
                     ProtocolType, &CardHandle, &ActiveProtocol);

  ShowSCardInfo(ret,ContextHandle, "Funktion SCardConnect");

3
//
//
// now send the data

IO_Request.dwProtocol = ProtocolType;

  switch (ProtocolType)
  {
  case SCARD_PROTOCOL_RAW:
         IO_Request.cbPciLength  = (DWORD) sizeof(SCARD_PCI_RAW);
         break;
  default:
         IO_Request.cbPciLength  = (DWORD) sizeof(SCARD_IO_REQUEST);
         break;
  }


  ResponseLength = MAX_RESPONSE;

  ftime(&t_start);      // option, i want to  measure execution time

  if (DirectAccessmode == false)
     {
      ret = SCardTransmit(CardHandle, &IO_Request, pInBuffer, InBufferLength, 0, pResponseBuffer, &ResponseLength);
      ShowSCardInfo(ret,CardHandle,"Function SCardTransmit(...)");  // my debugging window
     }
     else
     {
     ret = SCardControl( CardHandle,
                         SCARD_CTL_CODE(2048),      //NULL   oder SCARD_CTL_CODE(2052),
                         pInBuffer, InBufferLength,
                         pResponseBuffer, ResponseLength,
                         &BytesReturned);
     ShowSCardInfo(ret,CardHandle,"Function SCardControl(...)");
     }

// calc delta Time as a option ...
  ftime(&t_stop);
  long time_ms = (t_stop.time - t_start.time)*1000 + (t_stop.millitm - t_start.millitm);
 
0
 
LVL 8

Expert Comment

by:BdLm
ID: 12073813
regarding VB code i found this link with a demo

http://www.txsystems.com/pcscindex.html
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:harsher
ID: 12083071
thanx for the link... i will have a look at it.... btw i manage to write in the data into the card... but i cannt retrieve it back using the read command... i was hinted that i miss a step... can u tell me what r the steps i must follow to read the data in the card....

example:

i write "AAAA" into the card.... when i take out the card n put it back.... i get "" when i try to read it. i was told by a colleague that i miss out 1 step.... but she dun wan to tell me which step.... so i have to find out myself... can u tell me the steps to read the data in the card..
0
 
LVL 8

Accepted Solution

by:
BdLm earned 100 total points
ID: 12083643
As I don't have the manuals for the GEM+ card, i can't help in detail,
I just assume from other application, first you must authenticate
yourselft with the card (present a PIN oder some other secret). If you pass you may start to write.
Does the card responde with #90 #00 to your writing  command?
On the GEM Website have been some tools with perfect reader communication, so send the APDUs manually with such a tool and confirm the correct command sequence. Later on use your own software.

0
 

Author Comment

by:harsher
ID: 12095359
oh ic..... the "write to card" part is not done by me, done by my colleague, now she wants me to do the "read from card" part....

so.... now i cant read from the card... eheheh :D
0
 

Author Comment

by:harsher
ID: 12108126
hmmm.... i will give u the points 1st... then if there is any other question i will ask again...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now