hi ho :-)
i want to use the eco5000 reader, to use memory cards, but i have a
difficult problem. if im using the following function i get back the
errorcode 273. what does it mean ? and the pcsc server wrote :
winscard_rpc_server.c 514: SCardCollectZombies: Collecting Zombies
winscard_rpc_server.c 61: scardestablishcontext_1_svc: Current Channel:
0
winscard.c 80: SCardConnect: Attempting Connect to ORGA RGA ECO 5000
winscard.c 129: SCardConnect: hCard Identity: f0000000
ECO 5000 initialized, Firmware Version V2.01
winscard.c 228: SCardConnect: Active Protocol: 0
dyn_unix.c 70: DYN_GetAddress: dlerror() reports
/usr/local/lib/libeco_5000.so: undefined symbol: IFD_Read_Memory
winscard.c 266: SCardDisconnect: Active Contexts: 1
winscard_rpc_server.c 84: scardreleasecontext_1_svc: Release Channel:
-653983742
and now the code :
ret = SCardReadMemory (hCard, SCARD_TYPE_2WIRE, 1, 0, pbBuffer, 1);
its the code from the documentation. the ic is a SLE4432 with 256byte
eeprom. maybe i don't have the right CardSize, but which number does i
have to insert in the function ?
i'm sorry about my terrible english and about my terrible c, but im
learning both at the moment.
bye bye
Patrick Plattes
and here is the complete code :
#include <stdio.h>
#include <string.h>
#include <winscard.h>
#include <pcsclite.h>
#include <time.h>
int waits(int time_s) /*waiting time (seconds) is
there anyone white a better idea?*/
{
int hold;
clock_t begin;
hold = time_s*CLOCKS_PER_SEC;
begin = clock();
while(clock() < begin+hold);
return 0;
}
int return_text(int ret, char *errormsg) /*make the returncode
readable*/
{
switch (ret)
{
case 1:
strcpy(errormsg,"SUCCESS");
break;
case 2:
strcpy(errormsg,"CANCELLED");
break;
case 4:
strcpy(errormsg,"CANT_DISPOSE");
break;
case 8:
strcpy(errormsg,"INSUFFICIENT_BUFFER");
break;
case 10:
strcpy(errormsg,"INVALID_ATR");
break;
case 11:
strcpy(errormsg,"INVALID_HANDLE");
break;
case 12:
strcpy(errormsg,"INVALID_PARAMETER");
break;
case 14:
strcpy(errormsg,"INVALID_TARGET");
break;
case 18:
strcpy(errormsg,"INVALID_VALUE");
break;
case 20:
strcpy(errormsg,"NO_MEMORY");
break;
case 21:
strcpy(errormsg,"COMM_ERROR");
break;
case 22:
strcpy(errormsg,"INTERNAL_ERROR");
break;
case 24:
strcpy(errormsg,"UNKNOWN_ERROR");
break;
case 28:
strcpy(errormsg,"WAITED_TOO_LONG");
break;
case 100:
strcpy(errormsg,"UNKNOWN_READER");
break;
case 101:
strcpy(errormsg,"TIMEOUT");
break;
case 102:
strcpy(errormsg,"SHARING_VIOLATION");
break;
case 104:
strcpy(errormsg,"NO_SMARTCARD");
break;
case 108:
strcpy(errormsg,"UNKNOWN_CARD");
break;
case 110:
strcpy(errormsg,"PROTO_MISMATCH");
break;
case 111:
strcpy(errormsg,"NOT_READY");
break;
case 112:
strcpy(errormsg,"SYSTEM_CANCELLED");
break;
case 114:
strcpy(errormsg,"NOT_TRTANSACTED");
break;
case 118:
strcpy(errormsg,"READER_UNAVAILABLE");
break;
default:
strcpy(errormsg,"UNKNOW_RETURNCODE");
break;
}
return 0;
}
int main()
{
char errormsg[100]; /*returncode as text*/
int wait=0; /*waitingtime (seconds)*/
int ret; /*returncode as number*/
SCARDCONTEXT hContext; /*have a look to the pcsc-muscle-doc*/
SCARDHANDLE hCard;
DWORD dwActiveProtocol;
BYTE pbBuffer[100];
ret = SCardEstablishContext (SCARD_SCOPE_SYSTEM, NULL, NULL,
&hContext);
return_text(ret, errormsg);
printf("\nSCardEstablishContext = %s\n",errormsg);
waits(wait);
ret = SCardConnect (hContext, "ORGA RGA ECO 5000", SCARD_SHARE_SHARED,
SCARD_PROTOCOL_RAW, &hCard, &dwActiveProtocol);
return_text(ret, errormsg);
printf("\nSCardConnect = %s\n",errormsg);
waits(wait);
ret = SCardReadMemory (hCard, SCARD_TYPE_2WIRE, 1, 0, pbBuffer, 1);
return_text (ret, errormsg);
printf("\nSCardReadMemory = %s %d\n",errormsg, ret);
waits(wait);
ret = SCardDisconnect (hCard, SCARD_UNPOWER_CARD);
return_text(ret, errormsg);
printf("\nSCardDisconnect = %s\n",errormsg);
waits(wait);
ret = SCardReleaseContext (hContext);
return_text(ret, errormsg);
printf("\nSCardReleaseContext = %s\n",errormsg);
waits(wait);
return 0;
}
***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************