pyusb中是否有自动波特率?

问题描述

我正在尝试使用 pyusb、libusb 与 mcu 通信。 但是,没有办法为pyusb设置波特率。我想知道波特率是不是自动设置的,如果不是,我想知道如何自己设置。 谢谢。

这是我的代码

import usb.core
import usb.util

# find our device
dev = usb.core.find(idvendor=0x0440,idProduct=0x6001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments,the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]

ep = usb.util.find_descriptor(
    intf,# match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_OUT)

assert ep is not None

dev.write(2,'\x12')
dev.write(2,'\x34')
dev.write(2,'\x56')
#receiving response from 
ret = dev.read(0x81,16,1000)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)