On 12/31/08, Chaskiel Grundman <c...@andrew.cmu.edu> wrote: > It appears that ccid_card_status always fails if it has to probe the device > and no card is present. That's because the response to the GetSlotStatus > message when no card is present has the 'command failed' bit set and the > error code set to ICC_MUTE (spec implies this is the desired behavior). The > reset you did somehow causes the device to post an event notifying us that > the card was removed. Once that event comes in, ccid_card_status never sends > another GetSlotStatus message. The attached patch catches this specific > error and interprets it correctly. (Actually, there are two patches. One > takes the IFD_ERROR_NO_CARD error from ccid_command and asserts that means > the card is absent. The other ignores the IFD_ERROR_NO_CARD error and parses > the result as if no error had been reported. Either should work)
Thank you. I've committed something similar. But it still does not work. Please notice that the reset is before any other command... Here is a normal sequence, you can notice that I get a responce from the GetSlotStatus message. --- Debug: ifd_open: trying to open c...@usb:/dev/bus/usb/002/033 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0100 ind=x0000 len=18 Debug: ifd_usb_control: recv 12 01 10 01 00 00 00 08 c3 0d 04 10 05 05 01 02 00 01 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0200 ind=x0000 len=8 Debug: ifd_usb_control: recv 09 02 5d 00 01 01 06 a0 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0200 ind=x0000 len=93 Debug: ifd_usb_control: recv 09 02 5d 00 01 01 06 a0 32 09 04 00 00 03 0b 00 00 04 36 21 10 01 00 07 03 00 00 00 a0 0f 00 00 a0 0f 00 00 00 00 2a 00 00 15 16 05 00 00 fc 00 00 00 00 00 00 00 00 00 00 00 30 03 01 00 0f 01 00 00 00 00 00 00 00 01 07 05 81 03 08 00 ff 07 05 02 02 40 00 00 07 05 82 02 40 00 00 Debug: skipped 1 class/vendor specific interface descriptors Debug: usb_set_params: called. config xffffffff ifc x00 eps x02/x82 Debug: ccid_open_usb: USB reset workaround Debug: ccid_open_usb: Accepted 0dc3:1004 with features 0x10330 and protocols 0x3 events=1 Debug: ccid_activate: called. Debug: ccid_get_eventfd: called. Debug: ifdhandler_run: events active for reader CCID Compatible Debug: ccid_before_command: called. Debug: ifd_usb_begin_capture: usb capture type=1 ep=x81 maxpacket=8 Debug: usb_submit_urb: submit urb 0x8dd7a38 Debug: ifd_usb_capture: called, timeout=100 ms. Debug: ifd_usb_capture: usb capture: Command timed out Debug: ifd_usb_end_capture: called. Debug: ccid_command: sending: 65 00 00 00 00 00 00 00 00 00 Debug: usb_send: usb send to=x02 Debug: usb_send: send 65 00 00 00 00 00 00 00 00 00 Debug: usb_recv: usb recv from=x82 Debug: usb_recv: recv 81 00 00 00 00 00 00 01 00 01 Debug: ccid_command: received: 81 00 00 00 00 00 00 01 00 01 Debug: ccid_card_status: probed result: 3 Debug: ifd_slot_status_update: card status change slot 0: 0 -> 1 Debug: ccid_after_command: called. Debug: ifd_usb_begin_capture: usb capture type=1 ep=x81 maxpacket=8 Debug: usb_submit_urb: submit urb 0x8dd7a38 --- Here is the same without the reset, notice that the GetSlotStatus message timed out. --- Debug: ifd_open: trying to open c...@usb:/dev/bus/usb/002/033 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0100 ind=x0000 len=18 Debug: ifd_usb_control: recv 12 01 10 01 00 00 00 08 c3 0d 04 10 05 05 01 02 00 01 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0200 ind=x0000 len=8 Debug: ifd_usb_control: recv 09 02 5d 00 01 01 06 a0 Debug: ifd_usb_control: usb req type=x80 req=x06 val=x0200 ind=x0000 len=93 Debug: ifd_usb_control: recv 09 02 5d 00 01 01 06 a0 32 09 04 00 00 03 0b 00 00 04 36 21 10 01 00 07 03 00 00 00 a0 0f 00 00 a0 0f 00 00 00 00 2a 00 00 15 16 05 00 00 fc 00 00 00 00 00 00 00 00 00 00 00 30 03 01 00 0f 01 00 00 00 00 00 00 00 01 07 05 81 03 08 00 ff 07 05 02 02 40 00 00 07 05 82 02 40 00 00 Debug: skipped 1 class/vendor specific interface descriptors Debug: usb_set_params: called. config xffffffff ifc x00 eps x02/x82 Debug: ccid_open_usb: Accepted 0dc3:1004 with features 0x10330 and protocols 0x3 events=1 Debug: ccid_activate: called. Debug: ccid_get_eventfd: called. Debug: ifdhandler_run: events active for reader CCID Compatible Debug: ccid_before_command: called. Debug: ifd_usb_begin_capture: usb capture type=1 ep=x81 maxpacket=8 Debug: usb_submit_urb: submit urb 0x8196a38 Debug: ifd_usb_capture: called, timeout=100 ms. Debug: ifd_usb_capture: usb capture: Command timed out Debug: ifd_usb_end_capture: called. Debug: ccid_command: sending: 65 00 00 00 00 00 00 00 00 00 Debug: usb_send: usb send to=x02 Debug: usb_send: send 65 00 00 00 00 00 00 00 00 00 Error: usb_bulk failed: Connection timed out Debug: ccid_after_command: called. Debug: ifd_usb_begin_capture: usb capture type=1 ep=x81 maxpacket=8 Debug: usb_submit_urb: submit urb 0x8196a38 Debug: ccid_event: called. Debug: ifd_usb_capture_event: called. Debug: ifd_sysdep_usb_capture_event: usb reapurb: len=2 Debug: usb_submit_urb: submit urb 0x8196a38 Debug: ifd_usb_capture_event: usb event capture: recv 50 03 Debug: ccid_event: status received: 50 03 Debug: ccid_event: slot 0 event result: b7edb48b Debug: ifd_slot_status_update: card status change slot 0: 0 -> 1 --- This not always happening... I need to run ifdhandler several times in order to reproduce this. But somehow magically the usb reset makes the device communicate correctly. Isn't there any CCID something to reset the device at application level? Thanks! _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel