Solved

how to read GemClub Memo?

Posted on 2004-09-15
8
1,037 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

919 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

14 Experts available now in Live!

Get 1:1 Help Now