jacekkow / controlvault2-nfc-enable

Enable NFC on Linux for pcscd on Dell E7470 (and others) with ControlVault2
BSD 3-Clause "New" or "Revised" License
75 stars 21 forks source link

usb.core.USBTimeoutError: [Errno 110] Operation timed out #18

Open kalpo opened 2 years ago

kalpo commented 2 years ago

I have tested the script on my latitude e7270

./nfc.py off: works great every single time ./nfc.py on: works great when coming from an off state. But if the feature is already on it gives some grief:

> ./nfc.py on
INFO:__main__:Looking for supported device...
INFO:__main__:Found 0A5C:5834
DEBUG:cvcomm:Enumerating interfaces...
DEBUG:cvcomm:Interface found: INTERFACE 3: Vendor Specific
DEBUG:cvcomm:Enumerating endpoints...
DEBUG:cvcomm:BULK IN found: ENDPOINT 0x84: Bulk IN
DEBUG:cvcomm:BULK OUT found: ENDPOINT 0x4: Bulk OUT
DEBUG:cvcomm:Endpoint discovery successful.
INFO:__main__:Handler ControlVault2 (Broadcom ControlVault 2)
INFO:__main__:Turning NFC on...
DEBUG:cvcomm:Control: (65, 0, 1, 3) {}
DEBUG:cvcomm:Put: 01 00 00 04 10 2f 04 00
Traceback (most recent call last):
  File "/home/gon/repos/controlvault2-nfc-enable/./nfc.py", line 66, in <module>
    handler.turn_on()
  File "/home/gon/repos/controlvault2-nfc-enable/cv2.py", line 36, in turn_on
    self.communicator.talk(self.turn_on_seq1)
  File "/home/gon/repos/controlvault2-nfc-enable/cvcomm.py", line 53, in talk
    data = self.recv_packet()
  File "/home/gon/repos/controlvault2-nfc-enable/cvcomm.py", line 37, in recv_packet
    packet = self.read(64, timeout=5000).tobytes()
  File "/home/gon/repos/controlvault2-nfc-enable/cvcomm.py", line 28, in read
    return self.bulk_in.read(*args, **kwargs)
  File "/home/gon/.local/lib/python3.10/site-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "/home/gon/.local/lib/python3.10/site-packages/usb/core.py", line 1029, in read
    ret = fn(
  File "/home/gon/.local/lib/python3.10/site-packages/usb/backend/libusb1.py", line 846, in bulk_read
    return self.__read(self.lib.libusb_bulk_transfer,
  File "/home/gon/.local/lib/python3.10/site-packages/usb/backend/libusb1.py", line 954, in __read
    _check(retval)
  File "/home/gon/.local/lib/python3.10/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

./nfc.py reset: Also fails if it is already on in the same way. So I guess it seems to do what it is supposed to do?

Anyway, hope this is of any help. I would suggest adding an exception or a check to contain the tracebacks.

jacekkow commented 2 years ago

./nfc.py on: (...) if the feature is already on it gives some grief:

I don't know whether we'd be able to distinguish "device on" and "device communication problem" cases.

I highly encourage any volunteer to poke around this device as the traffic dumps do not show any kind of checking being done by the Windows driver.

Unfortunately I don't have time to analyze this now, but I'll leave it as an open item.

./nfc.py reset: Also fails if it is already on in the same way. So I guess it seems to do what it is supposed to do?

It definitely does not fail in the same way - there is no communication with the device in the reset method. Could you provide the logs for failed reset? It is a low-level reset that works for me every time - whether the NFC is on or off.

kalpo commented 2 years ago

You are right. It seems like a hassle that is not worth the trouble.

Regarding the reset thing. You are also right, I must have mistyped something because it now works perfectly.

Thanks again!