Re: GemPC Express Reader
Joachim Breitner <[email protected]> Wed, 18 Feb 2009 11:18:11 +0100
| Newsgroups | gmane.comp.lib.libchipcard.devel |
|---|---|
| Message-ID | <1234952291.3892.10.camel@localhost> |
Hi Ludovic, Hi Martin, Am Mittwoch, den 18.02.2009, 10:33 +0100 schrieb Joachim Breitner: > Thanks for the clarification, I’ll try to improve my libchipcard patch > then. with Ludovic’s help I actually found the ATR parsing code in libchipcard that figures out the protocol. (I guess I need to improve my reading-others-code-skills). The attached patch sets the protocol as specified from the ATR. I also took the liberty to rename DriverIFD__ConnectSlot to DriverIFD_ConnectSlot, as the repeated trial-and-error-calling of DriverIFD__ConnectSlot seems to be no longer necessary. From my POV the patch can probably be applied. Of course I could not test it against any readers other than my own. Thanks, Joachim -- Joachim "nomeata" Breitner mail: [email protected] | ICQ# 74513189 | GPG-Key: 4743206C JID: [email protected] | http://www.joachim-breitner.de/ Debian Developer: [email protected] ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Libchipcard-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libchipcard-devel
libchipcard-ccid-proto-from-ATR.patch
(text/plain, 5 KB)
diff -u libchipcard-4.2.4/debian/changelog libchipcard-4.2.4/debian/changelog --- libchipcard-4.2.4/debian/changelog +++ libchipcard-4.2.4/debian/changelog @@ -1,3 +1,9 @@ +libchipcard (4.2.4-1.nomeata1) UNRELEASED; urgency=low + + * Testing GemPC Express + + -- Joachim Breitner <[email protected]> Wed, 18 Feb 2009 00:22:52 +0100 + libchipcard (4.2.4-1) experimental; urgency=low * New upstream release only in patch2: unchanged: --- libchipcard-4.2.4.orig/data/drivers/posix/ccid_ifd/ccid_ifd.xml +++ libchipcard-4.2.4/data/drivers/posix/ccid_ifd/ccid_ifd.xml @@ -47,6 +47,13 @@ <readers> + <reader name="ccid_gempc_express" busType="UsbRaw" + addressType="devicePath" + devicePathTmpl="usb:$(vendorId:04x)/$(productId:04x):libusb:$(busName):$(deviceName)" + vendor="0x08e6" product="0x34ec" > + <short>GemPC Express</short> + </reader> + <reader name="ccid_gempc_key" busType="UsbRaw" addressType="devicePath" devicePathTmpl="usb:$(vendorId:04x)/$(productId:04x):libusb:$(busName):$(deviceName)" only in patch2: unchanged: --- libchipcard-4.2.4.orig/src/drivers/ifd/driverifd.c +++ libchipcard-4.2.4/src/drivers/ifd/driverifd.c @@ -285,6 +285,9 @@ case CCID_ICC_NOT_PRESENT: s="Card not present"; break; + case CCID_COMMUNICATION_ERROR: + s="Communication error"; + break; default: s="Unknow error code"; }; @@ -511,7 +514,7 @@ -long DriverIFD__ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) { +uint32_t DriverIFD_ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) { long retval; unsigned char atrBuffer[300]; DWORD atrLen; @@ -584,6 +587,27 @@ LCD_Slot_AddFlags(sl, LCD_SLOT_FLAGS_PROCESSORCARD); } LCD_Slot_SetProtocolInfo(sl, proto); + + int ccid_proto; + switch (proto) { + case 0: ccid_proto = 1; break; + case 1: ccid_proto = 2; break; + default: + DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Unkown Protocol in ATR: T=%d", proto); + break; + } + DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Setting Protocol T=%d", proto); + retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl), + ccid_proto, 0, 0, 0, 0); + if (retval) { + DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Error setting protocol T=%d (%d)", + proto, (int)retval); + return retval; + } + } else if (retval==CCID_ICC_NOT_PRESENT) { DBG_NOTICE(LCD_Reader_GetLogger(r), "No card inserted"); @@ -600,57 +624,6 @@ return 0; } - - -uint32_t DriverIFD_ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) { - int i; - DRIVER_IFD *dct; - long retval; - - assert(d); - dct=GWEN_INHERIT_GETDATA(LCD_DRIVER, DRIVER_IFD, d); - assert(dct); - - retval=DriverIFD__ConnectSlot(d, sl); - if (retval!=CCID_ERROR_POWER_ACTION) { - DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), - "CCID: Result is not POWER_ACTION (%d)", - (int)retval); - return retval; - } - - if (dct->setProtoFn==NULL) - return retval; - - /* try protocols 0 through 15 */ - for (i=0; i<16; i++) { - /* set protocol bt don't change PTS */ - retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl), - i, 0, 0, 0, 0); - if (retval) { - DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), - "CCID: Error setting protocol %d (%d)", - i, (int)retval); - } - else { - retval=DriverIFD__ConnectSlot(d, sl); - if (retval!=CCID_ERROR_POWER_ACTION) { - DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), - "CCID: Result is not POWER_ACTION (%d, proto=%d)", - (int)retval, i); - return retval; - } - } - } - - /* assuming no card inserted */ - DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), - "Assuming no card is inserted"); - return 0; -} - - - uint32_t DriverIFD_DisconnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) { long retval; unsigned char atrBuffer[300]; @@ -716,6 +689,29 @@ else if (retval==0) { LCD_Slot_AddStatus(sl, LCD_SLOT_STATUS_CARD_INSERTED); LCD_Slot_AddStatus(sl, LCD_SLOT_STATUS_CARD_CONNECTED); + + int proto; + proto=DriverIFD_ExtractProtocolInfo(atrBuffer, atrLen); + // Or should it be read from LCD_Slot_GetProtocolInfo? + int ccid_proto; + switch (proto) { + case 0: ccid_proto = 1; break; + case 1: ccid_proto = 2; break; + default: + DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Unkown Protocol in ATR: T=%d", proto); + break; + } + DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Setting Protocol T=%d", proto); + retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl), + ccid_proto, 0, 0, 0, 0); + if (retval) { + DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)), + "CCID: Error setting protocol T=%d (%d)", + proto, (int)retval); + return retval; + } } else { DBG_NOTICE(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkmb4GMACgkQ9ijrk0dDIGy/xACbBg0ryldSt3HhdJA0g5+uFlbb qeIAn3kUnmElcJwan0+zBAIRvluPLhJn =y8VQ -----END PGP SIGNATURE-----