controlvault2-nfc-enable
controlvault2-nfc-enable copied to clipboard
Dell Precision 7540 support
I've a 7540, and I get the following message:
$ ./nfc.py on
INFO:__main__:Looking for supported device...
INFO:__main__:Found 0A5C:5843
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 ControlVault3 (Broadcom ControlVault 3)
INFO:__main__:Turning NFC on...
DEBUG:cvcomm:Control: (65, 1, 0, 3) {}
Traceback (most recent call last):
File "/tmp/controlvault2-nfc-enable/./nfc.py", line 66, in <module>
handler.turn_on()
File "/tmp/controlvault2-nfc-enable/cv3.py", line 29, in turn_on
self.communicator.ctrl_transfer(0x41, 1, 0, 3)
File "/tmp/controlvault2-nfc-enable/cvcomm.py", line 22, in ctrl_transfer
return self.device.ctrl_transfer(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/usb/core.py", line 1082, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File "/usr/lib/python3.10/site-packages/usb/backend/libusb1.py", line 893, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File "/usr/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
I've got an icon on the right of the touchpad which should be the symbol of NFC.
lsusb reports device 0a5c:5843.
From pkcs11-tool -L I see:
$ pkcs11-tool -L
Available slots:
Slot 0 (0x0): Virtual PCD 00 00
(empty)
Slot 1 (0x4): Virtual PCD 00 01
(empty)
Slot 2 (0x8): Broadcom Corp 58200 [Contacted SmartCard] (0123456789ABCD) 00 00
(empty)
Slot 3 (0xc): Broadcom Corp 58200 [Contactless SmartCard] (0123456789ABCD) ...
(empty)
However, pcsc_scan does not detect any NFC card.
Hope this helps. Let me know if you need further information to better diagnose the problem.
Try to do:
./nfc.py reset
first. Also try running this with sudo:
sudo ./nfc.py on
If that doesn't help, please attach the output of lsmod command.
BTW, it looks pretty similar to https://github.com/jacekkow/controlvault2-nfc-enable/issues/18 (only that here timeout occurs after the first control command rather than the first data transfer).
I now loaded all the modules in /lib/modules/*/kernel/drivers/nfc.
Not sure if related or I just didn't notice before loading the NFC modules, but there's some progress, I get at least a response:
$ ./nfc.py on
INFO:__main__:Looking for supported device...
INFO:__main__:Found 0A5C:5843
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 ControlVault3 (Broadcom ControlVault 3)
INFO:__main__:Turning NFC on...
DEBUG:cvcomm:Control: (65, 1, 0, 3) {}
DEBUG:cvcomm:Put: 01 00 00 04 20 00 01 00
DEBUG:cvcomm:Got: 00 00 00 06 40 00 03 00 11 00
DEBUG:cvcomm:Control: (65, 1, 1, 3) {}
DEBUG:cvcomm:Control: (65, 0, 0, 3) {}
DEBUG:cvcomm:Control: (65, 0, 1, 3) {}
Traceback (most recent call last):
File "/tmp/controlvault2-nfc-enable/./nfc.py", line 66, in <module>
handler.turn_on()
File "/tmp/controlvault2-nfc-enable/cv3.py", line 33, in turn_on
self.communicator.ctrl_transfer(0x41, 0, 1, 3)
File "/tmp/controlvault2-nfc-enable/cvcomm.py", line 22, in ctrl_transfer
return self.device.ctrl_transfer(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/usb/core.py", line 1082, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File "/usr/lib/python3.10/site-packages/usb/backend/libusb1.py", line 893, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File "/usr/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
This is right after resuming from suspension.
Weirdly enought, if I run once sudo ./nfc.py on, I don't get DEBUG:cvcomm:Got: 00 00 00 06 40 00 03 00 11 00 and from then on even without sudo I get the same result until the next suspend + resume.
./nfc.py reset does not change the situation above.
However, the following patch makes it work!
diff --git a/cv3.py b/cv3.py
index e010616..e7d22ff 100644
--- a/cv3.py
+++ b/cv3.py
@@ -30,7 +30,7 @@ class ControlVault3:
self.communicator.talk(self.turn_on_seq1)
self.communicator.ctrl_transfer(0x41, 1, 1, 3)
self.communicator.ctrl_transfer(0x41, 0, 0, 3)
- self.communicator.ctrl_transfer(0x41, 0, 1, 3)
+ self.communicator.ctrl_transfer(0x41, 0, 1, 3, timeout=10000)
self.communicator.ctrl_transfer(0x41, 1, 0, 3)
self.communicator.talk(self.turn_on_seq2)
self.communicator.ctrl_transfer(0x41, 1, 1, 3)
I can see the NFC card from pcsc_scan!
If this gives you some insight such as "oh we should have a timeout everywhere" and you'd like me to make a PR, let me know. I'm so happy! We have like 5-6 Precision 7540 and know everyone can benefit from this!
If possible, I'd go with setting device object's default_timeout (as documented here: https://github.com/pyusb/pyusb/blob/master/docs/tutorial.rst) few lines up (in __init__), rather than having a stray argument to one command. Go ahead with making a pull request with such change.