PyUSB 如何指定端点的类型和缓冲区大小
PyUSB how to specify the type and the buffer size of the endpoint
通过 USB 发送数据有四种不同的方式:控制、中断、批量和同步。 book ref 1
摘自本书 book ref 1 第 330 页:
... Bulk endpoints transfer large amounts of data. These endpoints are usually much larger (they can hold more characters at once) that interrupt endpoints. ...
当我获得端点输入时,我使用以下命令。
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
if dev is None:
raise ValueError('Device not found')
dev.reset()
dev.set_configuration()
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
epi = usb.util.find_descriptor(
intf,
# match the first IN endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) ==\
usb.util.ENDPOINT_IN)
我尝试添加,但它给出了我不完全理解的语法错误:
usb.util.endpoint_type()== \
usb.util.ENDPOINT_TYPE_BULK
这是关于如何使用 USB 的另一个非常好的来源 link 1
似乎usb端点有参数可以在python
中指定
其中 bEndpointAddress 指示此描述符描述的端点。
bmAttributes 指定传输类型。这可以是控制、中断、同步或批量传输。如果指定了等时端点,则可以选择其他属性,例如同步和使用类型。
wMaxPacketSize 指示此端点的最大负载大小。
bInterval用于指定某些传输的轮询间隔。单位以帧表示,因此对于 low/full 速度设备等于 1ms,对于高速设备等于 125us。
我试过:
epi.wMaxPacketSize = 72000000 #to make the buffer large
epi.bmAttributes = 3 # 3 = 10 in binary. to change the mode to bulk
我的问题是:
我在哪里指定我为 Windows 和(或)Linux 使用的端点类型以及如何指定?以及如何更改每个端点的缓冲区大小?
试试这个:
epi = usb.util.find_descriptor(intf,
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_IN \
and \
usb.util.endpoint_type(e.bmAttributes) == \
usb.util.ENDPOINT_TYPE_BULK )
但是你误解了关于参数的部分。 bmAttributes 和 wMaxPacketSize 由 USB 硬件指定,不会被 Python 更改。
通过 USB 发送数据有四种不同的方式:控制、中断、批量和同步。 book ref 1 摘自本书 book ref 1 第 330 页:
... Bulk endpoints transfer large amounts of data. These endpoints are usually much larger (they can hold more characters at once) that interrupt endpoints. ...
当我获得端点输入时,我使用以下命令。
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
if dev is None:
raise ValueError('Device not found')
dev.reset()
dev.set_configuration()
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
epi = usb.util.find_descriptor(
intf,
# match the first IN endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) ==\
usb.util.ENDPOINT_IN)
我尝试添加,但它给出了我不完全理解的语法错误:
usb.util.endpoint_type()== \
usb.util.ENDPOINT_TYPE_BULK
这是关于如何使用 USB 的另一个非常好的来源 link 1
似乎usb端点有参数可以在python
中指定其中 bEndpointAddress 指示此描述符描述的端点。
bmAttributes 指定传输类型。这可以是控制、中断、同步或批量传输。如果指定了等时端点,则可以选择其他属性,例如同步和使用类型。
wMaxPacketSize 指示此端点的最大负载大小。
bInterval用于指定某些传输的轮询间隔。单位以帧表示,因此对于 low/full 速度设备等于 1ms,对于高速设备等于 125us。
我试过:
epi.wMaxPacketSize = 72000000 #to make the buffer large
epi.bmAttributes = 3 # 3 = 10 in binary. to change the mode to bulk
我的问题是:
我在哪里指定我为 Windows 和(或)Linux 使用的端点类型以及如何指定?以及如何更改每个端点的缓冲区大小?
试试这个:
epi = usb.util.find_descriptor(intf,
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_IN \
and \
usb.util.endpoint_type(e.bmAttributes) == \
usb.util.ENDPOINT_TYPE_BULK )
但是你误解了关于参数的部分。 bmAttributes 和 wMaxPacketSize 由 USB 硬件指定,不会被 Python 更改。