Re: GemPC Express Reader

Joachim Breitner <[email protected]> Wed, 18 Feb 2009 00:53:32 +0100
Newsgroups gmane.comp.lib.libchipcard.devel
Message-ID <1234914812.4413.52.camel@localhost>
Hi,

Am Mittwoch, den 18.02.2009, 00:43 +0100 schrieb Joachim Breitner:
> I have attached a patch for libchipcard that makes it work for me. If it
> is ok to always set protocol to T=1 (at least until there is someone for
> whom it breaks), maybe it can be applied?

just amended the patch to include an driver entry for my reader.

Greetings,
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-with-usbid.patch (text/plain, 4 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";
   };
@@ -603,49 +606,35 @@
 
 
 uint32_t DriverIFD_ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
-  int i;
+  int protocol;
   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) {
+  if (retval) {
     DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
-	     "CCID: Result is not POWER_ACTION (%d)",
+	     "CCID: Could not connect to slot (%d)",
 	     (int)retval);
     return retval;
   }
 
-  if (dct->setProtoFn==NULL)
+  // Here the protocol should be read from the usb field dwProtocol
+  DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	   "CCID: Setting Protocol 1");
+  protocol = 2; // T1
+  retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl),
+			 protocol, 0, 0, 0, 0);
+  if (retval) {
+    DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	     "CCID: Error setting protocol %d (%d)",
+	     protocol, (int)retval);
     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;
 }
 
@@ -689,6 +678,7 @@
 uint32_t DriverIFD_ResetSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
   long retval;
   unsigned char atrBuffer[300];
+  int protocol;
   DWORD atrLen;
   DRIVER_IFD *dct;
 
@@ -724,6 +714,19 @@
     LCD_Slot_SubStatus(sl, LCD_SLOT_STATUS_CARD_INSERTED);
   }
 
+  // Here the protocol should be read from the usb field dwProtocol
+  DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	   "CCID: Setting Protocol 1");
+  protocol = 2; // T1
+  retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl),
+			 protocol, 0, 0, 0, 0);
+  if (retval) {
+    DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	     "CCID: Error setting protocol %d (%d)",
+	     protocol, (int)retval);
+    return retval;
+  }
+
   return 0;
 }
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkmbTfwACgkQ9ijrk0dDIGyjogCePMor1xFeSO+7+fEXOfzzvXWP
r2AAn2rqQr45yVv4Qbfk9PkHT6QDs7jF
=/lVF
-----END PGP SIGNATURE-----