我正在尝试使用Altera De0 Nano SoC中的USB-OTG端口进行读取/写入。我已经在SD卡中安装了Atlas SoC,以使用Arm Linux https://rocketboards.org/foswiki/view/Documentation/AtlasSoCDevelopmentPlatform。
CONFIGURATION 1: 2 mA ====================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0xa4 (164 bytes)
bNumInterfaces : 0x5
bConfigurationValue : 0x1
iConfiguration : 0x6 Multifunction with RNDIS
bmAttributes : 0xc0 Self Powered
bMaxPower : 0x1 (2 mA)
INTERFACE 0: CDC Communication =========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x2 CDC Communication
bInterfaceSubClass : 0x2
bInterfaceProtocol : 0xff
iInterface : 0x8 RNDIS Communications Control
ENDPOINT 0x82: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x9
INTERFACE 1: CDC Data ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xa CDC Data
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x9 RNDIS Ethernet Data
ENDPOINT 0x81: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
ENDPOINT 0x1: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
INTERFACE 2: CDC Communication =========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x2
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x2 CDC Communication
bInterfaceSubClass : 0x2
bInterfaceProtocol : 0x1
iInterface : 0xc CDC Abstract Control Model (ACM)
ENDPOINT 0x84: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x84 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0xa (10 bytes)
bInterval : 0x9
INTERFACE 3: CDC Data ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x3
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xa CDC Data
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0xd CDC ACM Data
ENDPOINT 0x83: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x83 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
ENDPOINT 0x2: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
INTERFACE 4: Mass Storage ==============================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x4
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x8 Mass Storage
bInterfaceSubClass : 0x6
bInterfaceProtocol : 0x50
iInterface : 0x1 Mass Storage
ENDPOINT 0x85: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x85 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
ENDPOINT 0x3: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x3 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x1
我已经删除了使用sudo rmmod命令由设备加载的默认驱动程序。我删除的驱动程序是:cdc_acm,rndis_wlan,rndis_host。这样做是为了使默认驱动程序不会干扰使用pysub代码的通信。我正在将该设备用作批量传输的USB海量存储(接口4)。 我正在运行以下python代码:
import sys, usb.core, time
#For USB OTG Hexadecimal VendorID=0x1d6b & ProductID=0x104
dev = usb.core.find(idVendor=0x1d6b, idProduct=0x104)
interface=4
if dev is None:
sys.exit("No Panic button found in the system");
try:
if dev.is_kernel_driver_active(4) is True:
dev.detach_kernel_driver(4)
except usb.core.USBError as e:
sys.exit("Kernel driver won't give up control over device: %s" % str(e))
try:
dev.set_configuration()
dev.reset()
except usb.core.USBError as e:
sys.exit("Cannot set configuration the device: %s" % str(e))
print dev
endpoint_in = dev[0][(interface,0)][0]
endpoint_out = dev[0][(interface,0)][1]
print endpoint_in
print endpoint_out
msg = 'test123'
data1 = dev.write(endpoint_out, msg,100)
print data1
data = dev.read(endpoint_in, len(msg),100)
sret = ''.join([chr(x) for x in data])
print sret
print repr(data.tostring())
usb.util.dispose_resources(dev)
我能够使用“ data1 = dev.write(endpoint_out,msg,100)”写入设备,但是当我尝试从设备读取“ data = dev.read(endpoint_in,len(msg),100)”时, ”,出现以下错误:
usb.core.USBError: [Errno 32] Pipe error
我试图搜索此问题,但找不到太多。 在http://christopherpeplin.com/2012/02/bulk-usb-throughput中,提到了以下内容:
针对OpenXC用例的完整解决方案将是确保将每封邮件填充为64字节,并请求大容量传输大小,该大小应足以获得良好的吞吐量,但又应足够小而不会太延迟。我尚未确认,但是我的理解是,如果我们请求读取4KB数据,并且不使用长度小于最大长度的数据包标记传输结束,则主机设备将阻止等待其余的请求数据
我尝试使用以下字符串发送64字节数据: abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd。
write命令显示已写入64个字节,但是当我尝试从设备读取时会出现相同的错误32。我是USB编程的新手,并且一直呆在这里。有人可以帮忙吗?