私のマウスのライトをオンまたはオフにできるスクリプトを(Linux上で)作成しようとしています。pyusb:設定を設定できません
これは私がこれまで持っているコードです:
import usb.core
import usb.util
import sys
interface = 0
dev = usb.core.find(idVendor=0x1532, idProduct=0x0017)
def main():
if dev is None:
print "device not found"
else:
print "device found"
if dev.is_kernel_driver_active(interface) is True:
print "but we need to detach kernel driver"
dev.detach_kernel_driver(interface)
print "claiming device"
usb.util.claim_interface(dev, interface)
print "release claimed interface"
usb.util.release_interface(dev, interface)
print "now attaching the kernel driver again"
dev.attach_kernel_driver(interface)
print "all done"
return 0
if __name__ == '__main__':
main()
これは正常に動作しますが、私が何をしようとした場合:claim_interface(DEV、インタフェース後dev.set_configuration()
を)
スクリプトがエラーを返します:usb.core.USBError:
リソース忙しいですなぜ私はカーネルドライバを外した後にまだビジーですか?
これをルートとして実行し、ルールを追加しても、私はまだ "usb.core.USBError:Resource busy"を取得します。しかし、あなたの答えは、私は普通のユーザーとしてスクリプトを実行することができます:) – IronMonkey
@アイロンモンキー - はい。それはルールの考え方です:あなたにデバイスの制御を割り当てる! :)この答えが役に立つ場合は、upvoteを忘れずに最終的にそれを受け入れてください。 – mac