python - 通过 USB 与 python 通信
问题描述
所以,我有一根 USB 转串口线。它的串行部分连接到 Raspberry Pi 4,我希望它的 USB 部分连接到我的 Windows 笔记本电脑,以便它们可以使用 python 相互通信。Windows 可以检测到端口上的设备,但它无法读取任何通过的数据。
我目前正在尝试将 libusb1 与 python 一起使用:
vendorId = 0x25A7
prodctId = 0xFA67
import usb1
with usb1.USBContext() as context:
handle = context.openByVendorIDAndProductID(
vendorId,
prodctId,
skip_on_error=True,
)
if handle is None:
print("Device not present, or user is not allowed to access device.")
with handle.claimInterface(INTERFACE):
# Do stuff
pass
但是使用此代码,它会给出 libusb 无法识别设备的错误。
usb1.USBErrorNotSupported: LIBUSB_ERROR_NOT_SUPPORTED [-12]
有没有办法让它与 libusb 兼容?还是有其他更好的方法来解决这个问题?
解决方案
推荐阅读
- javascript - 无法输入
场地 - c++ - 检查二叉树是否为 bst
- transactions - 以太坊交易因为“还原”而“失败”。“警告!合约执行过程中遇到错误[已恢复]”
- npm - 终端上的 Gulp 安装错误
- python - 尝试运行 manage.py migrate 时出错
- compression - 如何找到两个 s 表达式之间的编辑距离?
- python - 如何使滚动条在 Tkinter 框架中工作?
- mongodb - MongoDB 在子文档上聚合 $unwind
- email - 在 Opencart-3 中未收到来自同一地址的电子邮件(从管理员到管理员电子邮件)
- mysql - #Error while RDLC Summing with Empty Values