阅读:5606回复:5
linux 虚拟串口的问题,高手请进
设备跑的是linux操作系统,isp1362,arm9
采用linux的gadget/serial.c,把设备注册成一个虚拟串口,接到pc(windows)机上显示为一串口,设备枚举能成功,收发数据有问题,偶尔能成功 下面是我的描述符: static struct usb_config_descriptor gs_acm_config_desc = { .bLength = 9, .bDescriptorType = 2, /* .wTotalLength computed dynamically */ wTotalLength = 0x0043, .bNumInterfaces = 2, .bConfigurationValue = 2, .iConfiguration = 5, .bmAttributes = (1<<7|1<<6), .bMaxPower = 1, }; static const struct usb_interface_descriptor gs_bulk_interface_desc = { .bLength = 9, .bDescriptorType = 4, .bInterfaceNumber = 0, .bNumEndpoints = 2, .bInterfaceClass = 0x0a, .bInterfaceSubClass = 0, .bInterfaceProtocol = 0, .iInterface = 7, }; static const struct usb_interface_descriptor gs_control_interface_desc = { .bLength = 9, .bDescriptorType = 4, .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = 2, .bInterfaceSubClass = 02, .bInterfaceProtocol = 1, .iInterface = 6 }; static const struct usb_interface_descriptor gs_data_interface_desc = { .bLength = 9, .bDescriptorType = 4, .bInterfaceNumber = 1, .bNumEndpoints = 2, .bInterfaceClass = 0a , .bInterfaceSubClass = 0, .bInterfaceProtocol = 0, .iInterface = 7, }; static const struct usb_cdc_header_desc gs_header_desc = { .bLength = sizeof(gs_header_desc), .bDescriptorType = 0x24, .bDescriptorSubType = 00, .bcdCDC = __constant_cpu_to_le16(0x0110), }; static const struct usb_cdc_call_mgmt_descriptor gs_call_mgmt_descriptor = { .bLength = sizeof(gs_call_mgmt_descriptor), .bDescriptorType = 0x24, .bDescriptorSubType = 0x01, .bmCapabilities = 0, .bDataInterface = 1, /* index of data interface */ }; static struct usb_cdc_acm_descriptor gs_acm_descriptor = { .bLength = sizeof(gs_acm_descriptor), .bDescriptorType = 0x24, .bDescriptorSubType = 0x01, .bmCapabilities = 0, }; static const struct usb_cdc_union_desc gs_union_desc = { .bLength = sizeof(gs_union_desc), .bDescriptorType = 0x24, .bDescriptorSubType = 0x06, .bMasterInterface0 = 0, /* index of control interface */ .bSlaveInterface0 = 1, /* index of data interface */ }; static struct usb_endpoint_descriptor gs_fullspeed_notify_desc = { .bLength = 7, .bDescriptorType = 5, .bEndpointAddress = 0x83, .bmAttributes = 3 USB_ENDPOINT_XFER_INT, .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET), .bInterval = 32, }; static struct usb_endpoint_descriptor gs_fullspeed_in_desc = { .bLength = 7, .bDescriptorType = 5, .bEndpointAddress = 0x82, .bmAttributes = 2, }; static struct usb_endpoint_descriptor gs_fullspeed_out_desc = { .bLength = 7, .bDescriptorType = 5, .bEndpointAddress = 0x01, .bmAttributes = 2 USB_ENDPOINT_XFER_BULK, }; static const struct usb_descriptor_header *gs_acm_fullspeed_function[] = { (struct usb_descriptor_header *) &gs_otg_descriptor, (struct usb_descriptor_header *) &gs_control_interface_desc, (struct usb_descriptor_header *) &gs_header_desc, (struct usb_descriptor_header *) &gs_call_mgmt_descriptor, (struct usb_descriptor_header *) &gs_acm_descriptor, (struct usb_descriptor_header *) &gs_union_desc, (struct usb_descriptor_header *) &gs_fullspeed_notify_desc, (struct usb_descriptor_header *) &gs_data_interface_desc, (struct usb_descriptor_header *) &gs_fullspeed_in_desc, (struct usb_descriptor_header *) &gs_fullspeed_out_desc, NULL, }; 从设备往pc机发送数据,我用bushound和虚拟串口都不能抓到数据,从pc往设备发,用bushound 能看到数据,而且调试信息也显示收到了数据,请问是什么原因呢? 另外我感觉到设备好像被枚举了很多遍,不停的reset然后又配置,请问下这个过程一般多少遍? |
|
沙发#
发布于:2008-11-29 16:51
|
|
板凳#
发布于:2008-06-17 16:05
windows下是采用微软的usbser.sys不用自己写,linux下采用gadget serial.c
|
|
地板#
发布于:2008-06-16 23:49
没沙发有板凳也成啊!
windows 端应该有一个驱动,类似于USB转串口的驱动吧,把USB设备虚拟成串口吧 linux端也是把USB虚拟成串口,两边都虚拟成串口,而且linux端还要有一个USB从机的驱动。 牛犊的一点建议。 |
|
地下室#
发布于:2008-06-16 20:05
请问下用超级终端打开虚拟串口后,关闭再打开就显示找不到虚拟串口 ?
急急急 |
|
5楼#
发布于:2008-06-16 15:39
为什么pc机上老是无法打开虚拟的串口啊
|
|