我使用更簡單的StormLauncher版本(https://github.com/nmilford/stormLauncher)從Raspberry Pi調用Thunder USB Missile Launcher。一旦我將它連接到有源USB集線器上,它就可以工作。當從PyUSB調用set_configuration時發生「未知錯誤」
兩次。
現在,當我調用它,我得到:
Traceback (most recent call last):File "launcherFire.py", line 15, in <module>
turret.set_configuration()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 559, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 92, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 741, in set_configuration
_check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 571, in _check
raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno None] Unknown error
我試着拔出並再次插入它,它似乎工作here,但它並沒有改變任何東西。
這裏是我的代碼:
import usb.core
turret = usb.core.find(idVendor=0x2123, idProduct=0x1010)
if turret is None:
raise ValueError('Launcher not found.')
try:
turret.detach_kernel_driver(0)
except Exception, e:
pass # already unregistered
turret.set_configuration()
turret.ctrl_transfer(0x21, 0x09, 0, 0, [0x02, 0x10, 0x00,0x00,0x00,0x00,0x00,0x00])
什麼嘗試任何提示,無論是軟件還是硬件明智的,將是巨大的。
更新:它似乎是USB啓動器本身的硬件故障。我更換了它,並且完全相同的代碼運行正常(雖然幽默地,這個發射器也有一個破損的電機,但至少空氣觸發器仍然運行)。