Closed dend closed 4 years ago
I'm investigating this, it's possibly a bug in how I'm calling ~hidapi.write
~ nope looks like hid_open
(fingers crossed).
How did you install hidapi
on your Mac? MacPorts, brew or something else?
I couldn't recreate the bug on my machine with my lights, but I'm hoping I found the problem and pushed a revision to PyPI (~0.6.4~ 0.7.1). If you could install that and give me some feedback that would be awesome.
I installed hidapi
via brew install hidapi
. Checking the new version!
Just installed the latest version from the GitHub repo (via pip install .
) - not sure if the PyPI release would be different, but seems like the error is the same. I wouldn't exclude the fact that something is wrong with hidapi
.
Well crap. I was hoping that would fix the problem obviously.
What's happening in the stack trace you provided is pretty straightforward:
handle
property isn't initialized until it's first use (as designed)handle
propertyhidapi.hid_open(vender_id, product_id, None)
I was accidentally passing the 'path' attribute as the third argument to hid_open
when it was expecting None or the device's serial number. That was a bug for sure on my part, but not the problem you are encountering. So hid_open is failing for some other reason. The duh is implied I guess.
One thing that stuck out to me and I can't explain is the empty 'path' attribute in your blync -a
output. I had just removed that attribute from the output of the report since it can be annoyingly long under MacOS and it didn't seem very helpful. I just added it back into the output for version 0.7.2 (which I just pushed to PyPI).
On my Mac 10.10.5 installation with hidapi 0.9.0 I get the following output:
BlyncLights :2
ID:KEY :VALUE
00:path :IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/TRP0@7/IOPP/PXSX@0/IOPP/pci-bridge@0/IOPP/pci1b73,1100@0/AppleUSBXHCIFL1100@01000000/AppleUSB20XHCIPort@01100000/Blynclight Plus@01100000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice
00:vendor_id :0x2c0d
00:product_id :0x10
00:release_number :0x100
00:product_string :Blynclight Plus
00:usage_page :0xff00
00:usage :0x1
00:interface_number:0x0
ID:KEY :VALUE
01:path :IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/TRP0@7/IOPP/PXSX@0/IOPP/pci-bridge@2/IOPP/pci1b21,1242@0/AppleUSBXHCIPCI@00000000/AppleUSB20XHCIPort@00300000/Blynclight@00300000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice
01:vendor_id :0x2c0d
01:product_id :0x1
01:release_number :0x100
01:product_string :Blynclight
01:usage_page :0xff00
01:usage :0x1
01:interface_number:0x0
If I wrote some C tools for debugging this problem, would you be able to compile and run them? If not I'll figure something else out. It would be great if you could install the new version and respond back with the blync -a
output too!
Ok, I think I've been able to recreate this problem. I suspect that you have another application running that has an open file descriptor for the light; Teams or Skype or something else maybe? The lights can only be opened by one application at a time.
Hmm... interesting. Definitely do not see another application that would be using the light. I will need to dig into this a bit to see if I can identify how to get a list of applications using a USB device. Updated to the latest version and ran blync -a
, and getting this output:
BlyncLights :1
ID:KEY :VALUE
00:path :
00:vendor_id :0xe53
00:product_id :0x2517
00:release_number :0x100
00:product_string :Blynclight
00:usage_page :0xff00
00:usage :0x1
00:interface_number:0x0
Empty path here. The weird thing about the light is that it works fine with blync
on another machine, that is on the same macOS version, using the same hidapi
release.
If I wrote some C tools for debugging this problem, would you be able to compile and run them? If not I'll figure something else out. It would be great if you could install the new version and respond back with the blync -a output too!
Sure, I can test with C tools - new to HID APIs, but can figure things out.
I wonder if this has something to do with macOS restrictions. Will have to dig into this a bit later, but I would not exclude that there is something here natively in the OS blocking HID path access.
Thanks for the pointer, following the rabbit hole led to this commit which indicates a known limitation: https://github.com/claui/python-fido2/commit/79173f8d2ce55d26543b8b1af03bc2eda6f8a413
I'm curious how your blynclight is connected ( hub connected to a hub connected to a hub to the Mac )? If it's a long chain can you shorten the chain to consequently shorten the generated path length ?
I get this sort of error if I have the Embrava software open or if I have been controlling the device in an active Python interpreter. Once I closed ptpython
(in one Terminal tab), I'm able to use the CLI tool in another tab.
@JnyJny @Jaharmi I did connect it through a hub, but on another Mac it's connected through the same hub and it works with no issues. The interesting part is that I do not see any other application that obviously is using the light. I need to see if there is an alternative way to get the path to the device outside the blync
CLI. If you folks have any suggestions, I am happy to try them!
I read about some sort of "IOExplorer" tool in the Apple Developer Tools bundle, but haven't pursed it yet.
Just for grins, I just published 0.8.0 to PyPI. I removed my ctypes interface to hidapi (blynclight.hid) and replaced it with hidapi which has two virtues: somebody else is (actively) maintaining it and they are tracking hidapi. Give it a shot, if the error was somewhere in my hid implementation this change may fix the problem. Fingers crossed.
Bingo - pulling the latest version from PyPI did it, and it now works properly 🙏 Thank you @JnyJny! Excited to see the source code that you publish for 0.8.0.
That is great news!
I have an Embrava Blynclight that I am trying to control on macOS Catalina (10.15.5). If I run
system_profiler SPUSBDataType
, I can see the device:However, when I run
blync
, I get an error:This seems odd, since it does seem like the device vendor ID and the product code are correctly detected, it's just that the writing fails with the specified handle.
Running
blync -l
actually detects the light as well: