shaohaigod
驱动牛犊
驱动牛犊
  • 注册日期2007-06-13
  • 最后登录2009-03-04
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望21点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
阅读:5607回复:5

linux 虚拟串口的问题,高手请进

楼主#
更多 发布于:2008-06-13 14:50
设备跑的是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然后又配置,请问下这个过程一般多少遍?



shaohaigod
驱动牛犊
驱动牛犊
  • 注册日期2007-06-13
  • 最后登录2009-03-04
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望21点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2008-06-16 15:39
为什么pc机上老是无法打开虚拟的串口啊
shaohaigod
驱动牛犊
驱动牛犊
  • 注册日期2007-06-13
  • 最后登录2009-03-04
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望21点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2008-06-16 20:05
请问下用超级终端打开虚拟串口后,关闭再打开就显示找不到虚拟串口 ?
急急急
akcw007
驱动牛犊
驱动牛犊
  • 注册日期2005-09-02
  • 最后登录2009-02-13
  • 粉丝0
  • 关注0
  • 积分59分
  • 威望15点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
地板#
发布于:2008-06-16 23:49
没沙发有板凳也成啊!

windows 端应该有一个驱动,类似于USB转串口的驱动吧,把USB设备虚拟成串口吧
linux端也是把USB虚拟成串口,两边都虚拟成串口,而且linux端还要有一个USB从机的驱动。

牛犊的一点建议。
shaohaigod
驱动牛犊
驱动牛犊
  • 注册日期2007-06-13
  • 最后登录2009-03-04
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望21点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2008-06-17 16:05
windows下是采用微软的usbser.sys不用自己写,linux下采用gadget serial.c
xrm1979
驱动牛犊
驱动牛犊
  • 注册日期2006-04-05
  • 最后登录2008-12-27
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望13点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2008-11-29 16:51
我也遇到了和你相同的问题,不知道你解决了没有,如果解决了是否能告诉我是什么原因,如果没有我们是不是可以讨论一下调试心得
联系方式:
xrmeng1979@yahoo.com.cn
游客

返回顶部