- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我希望我的程序在设备被拔掉时退出。我的代码:
device = usb.core.find(idVendor, idProduct)
device.detach_kernel_driver(0)
usb.util.claim_interface(device, 0)
usb_cfg = device.get_active_configuration()
usb_interface = usb_cfg[(0,0)]
port_in = usb_interface[0]
port_out = usb_interface[1]
while True:
# do read ....
如何检测设备的拔出。
最佳答案
嗯,当我查看 github 上的代码时,我建议从这个问题中获取代码(我假设你知道回调是什么:))
在此代码中,您使用 register_callback 传递事件 LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT
EDIT 5.12.2018 :
在 pyusb 的分支存储库中有一个指向 hotplug 分支的链接:
关于python - PyUSB:检测设备拔出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40785371/
如何使用Delphi检查麦克风是否插入/拔出? 最佳答案 function WaveInDevicePresent: boolean; begin result := waveInGetNumDe
DirectShow 是否有一种简单的方法来检测网络摄像头是否已插入 (USB),或者是否有人拔掉了它(然后轮询或搜索它)? 我看过 Microsoft Media Foundation 的代码,但它
我有一个与我的 linux 盒子配对的蓝牙 Remote ,当激活时,这个 Remote 在 /dev/input/event13 可见。 我有一个小的 C 程序,可以打开这个设备并直接从中读取,运行
我正在使用官方 Kinect SDK 1.5 示例之一,我正在尝试了解如何添加检查以检测 Kinect 何时断开连接。目前,该应用程序只会卡住,因此必须有一种方法来防止这种情况发生。 这是来自 SDK
我需要检测嵌入式系统上的 USB 串行设备何时插入或拔出,并知道 tty 是什么与之相关。 我的系统运行在 2.6 Linux 内核上。 因为我没有 udev 的写入权限规则,现在我试图从文件系统
我是安卓新手。如果插入或拔出充电器,我想更改 Activity 中 TextView 的文本。为此,我已经在 list 中注册了一个带有 Intent 的接收器 android.intent.acti
我正在开发一个在线乐谱阅读训练器,a prototype is available here .我能够实现对以前连接的 MIDI 键盘的访问,但是,我正在努力实现热插拔方案。 我最后一次拍摄是这样的:
我的最终目标是创建一个在启动时运行的脚本,该脚本在插入以太网电缆时关闭 wifi,反之亦然。这是我到目前为止创建的脚本: #!/bin/bash File=/sys/class/net/eth0/ca
我是一名优秀的程序员,十分优秀!