Hi,

This patch fixes a problem with the pertosmart1038 driver not being able
to receive data from reader.

Best regards,

Carlos Henrique Bauer
--- ifd-pertosmart1038.c.orig   2006-02-27 15:00:44.000000000 -0300
+++ ifd-pertosmart1038.c        2006-02-27 15:00:50.000000000 -0300
@@ -160,8 +160,8 @@
 #define PS_RESPONSE_HEADER_SIZE  4
 #define PS_RESPONSE_DATA_IDX     PS_RESPONSE_HEADER_SIZE
 
-#define INTERRUPT_URB_DATA_SIZE 0x08
-#define PS_ENDPOINT             0x81
+#define PS_INTERRUPT_URB_DATA_SIZE 0x08
+#define PS_ENDPOINT                0x81
 
 #define PS_BULK_SEND_PACKET_SIZE    64
 #define PS_BULK_RECEIVE_PACKET_SIZE 64
@@ -175,7 +175,7 @@
 /* read timeout
  * we must wait enough so that the card can finish its calculation */
 static const long PS_BULK_TIMEOUT = 30000;
-static const long PS_INTERRUPT_TIMEOUT = 200;
+static const long PS_INTERRUPT_TIMEOUT = 100;
 
 /* reader names */
 static const char PS_USB_READER_NAME[] = "PertoSmart EMV (AC1038, USB)";
@@ -390,8 +390,6 @@
 
        device_data = (ps_device_data_t *) dev->user_data;
 
-       return IFD_SUCCESS;
-
        do {
                rc = ifd_device_recv(dev, buffer, buffer_len, timeout);
        } while (rc > 0);
@@ -526,6 +524,9 @@
 
 /*
  * Receive a response from reader
+ *
+ * (rbuf == NULL && rlen == 0) means caller wants no data,
+ * just the reader status 
  */
 static int
 ps_receive_from_ifd(ifd_reader_t * reader, unsigned char *rbuf, size_t rlen)
@@ -547,18 +548,12 @@
        dev = reader->device;
        device_data = (ps_device_data_t *) dev->user_data;
 
-       if (rbuf == NULL) {
+       if (rbuf == NULL && rlen > 0) {
                ct_error("ps_receive_from_ifd: rbuf == NULL");
                rc = IFD_ERROR_GENERIC;
                goto out;
        }
 
-       if (rlen > 0) {
-               ct_error("ps_receive_from_ifd: rlen > 0");
-               rc = IFD_ERROR_GENERIC;
-               goto out;
-       }
-
        /* receive the response header */
        rc = ps_if_transmission_receive(dev, buffer, buffer_len);
 
@@ -674,9 +669,6 @@
 
        dev = reader->device;
 
-       /* flush the output buffer from the reader */
-       rc = ps_if_transmission_flush_reader_output_buffer(dev);
-
        if (rc == IFD_SUCCESS) {
                /* start the transmission */
                rc = ps_if_transmission_start(dev, dev->timeout);
@@ -805,7 +797,7 @@
                        }
                }
        } else {
-               unsigned char packet_buf[INTERRUPT_URB_DATA_SIZE];
+               unsigned char packet_buf[PS_INTERRUPT_URB_DATA_SIZE];
                const size_t packet_buf_len = sizeof(packet_buf);
 
                /* read notifications received from the reader */
@@ -1273,7 +1265,7 @@
        rc = ifd_usb_begin_capture(dev,
                                   IFD_USB_URB_TYPE_INTERRUPT,
                                   params.usb.ep_intr,
-                                  INTERRUPT_URB_DATA_SIZE,
+                                  PS_INTERRUPT_URB_DATA_SIZE,
                                   &(device_data->capture));
 
       out:
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to