第二篇 4G模块-USB串口驱动测试
来源:互联网 发布:java最简单的登录界面 编辑:程序博客网 时间:2024/05/16 07:33
一、编译内核
在linux内核里边修改了对华为ME909S-821的支持,使用make uImage编译,然后下载到开发板上:上电开机,在系统启动过程会打印相关usb串口驱动的信息,但是,我们也可以使用dmesg随时查看,相关信息如下:
usb 1-1: new full-speed USB device number 2 using s3c2410-ohcicdc_ether 1-1:2.0: usb0: register 'cdc_ether' at usb-s3c24xx-1, CDC Ethernet Device, 02:1e:10:1f:00:00option 1-1:2.2: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB0option 1-1:2.3: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB1option 1-1:2.4: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB2option 1-1:2.5: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB3option 1-1:2.6: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB4option: option_instat_callback: error -2最后出现错误: option_instat_callback error -2,尽管这个错误,目前还无法判断具体原因,开始测试在嵌入式开发板上打电话的功能(也就这个功能尤为吸引我)。
在这里我们要使用一个软件在ubuntu上,查看这个4G模块的信息,比如配置描述符、接口描述符、还有端点描述符等等,拥有这种功能的USB软件肯定有,幸运的是在内核大牛的网站看到这个usbview软件,下载网址:点击打开链接(感谢Greg K-H大牛)
下载代码,解压,可参考INSTALL文件编译安装usbview软件。
最后查看这个4G模块的信息如下:
Config Number: 1Number of Interfaces: 6Attributes: a0MaxPower Needed: 2mAInterface Number: 0Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 1Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 84Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 1Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 3Name: Alternate Number: 1Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 3Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msEndpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 2 //实际使用的配置Number of Interfaces: 7Attributes: a0MaxPower Needed: 2mAInterface Number: 0Name:cdc_etherAlternate Number: 0Class: 02(comm.) Sub Class: 06Protocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1
Name: cdc_ether
Alternate Number: 0Class: 0a(data ) Sub Class: 06Protocol: 00Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 84Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 86Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 6Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 3Number of Interfaces: 2Attributes: a0MaxPower Needed: 2mAInterface Number: 0Name: Alternate Number: 0Class: 02(comm.) Sub Class: 0eProtocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1Name: Alternate Number: 0Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 0Interface Number: 1Name: Alternate Number: 1Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0ms
以上就是使用usbview软件查看的USB设备信息,这里对应这个ttyUSB0-ttyUSB4理解:cdc_ether 1-1:2.0: usb0: register 'cdc_ether' at usb-s3c24xx-1, CDC Ethernet Device, 02:1e:10:1f:00:00option 1-1:2.2: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB0option 1-1:2.3: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB1option 1-1:2.4: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB2option 1-1:2.5: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB3option 1-1:2.6: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB4目前还没有拿到证据,但在观看这里的1-1.2.0到最后的1-1.2.6,估计2代表使用的配置2,就是上面的Config Number为2的配置描述符,后边的数字从0、2、3、4、5、6代表了上边的接口描述符,可以从接口描述符名字观察到,其中配置描述符2的接口描述符1没有使用上。
二、关于option_instat_callback error -2的原因
【1】函数内容:
static void option_instat_callback(struct urb *urb){int err;int status = urb->status;struct usb_serial_port *port = urb->context;struct option_port_private *portdata = usb_get_serial_port_data(port);dbg("%s", __func__);dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata);if (status == 0) {struct usb_ctrlrequest *req_pkt =(struct usb_ctrlrequest *)urb->transfer_buffer;if (!req_pkt) {dbg("%s: NULL req_pkt", __func__);return;}if ((req_pkt->bRequestType == 0xA1) &&(req_pkt->bRequest == 0x20)) {int old_dcd_state;unsigned char signals = *((unsigned char *)urb->transfer_buffer +sizeof(struct usb_ctrlrequest));dbg("%s: signal x%x", __func__, signals);old_dcd_state = portdata->dcd_state;portdata->cts_state = 1;portdata->dcd_state = ((signals & 0x01) ? 1 : 0);portdata->dsr_state = ((signals & 0x02) ? 1 : 0);portdata->ri_state = ((signals & 0x08) ? 1 : 0);if (old_dcd_state && !portdata->dcd_state) {struct tty_struct *tty =tty_port_tty_get(&port->port);if (tty && !C_CLOCAL(tty))tty_hangup(tty);tty_kref_put(tty);}} else {dbg("%s: type %x req %x", __func__,req_pkt->bRequestType, req_pkt->bRequest);}++++++}else if(status ==-ENOENT || status == -ESHUTDOWN) {++++++ dbg("%s: urb stopped: %d\n", __func__, status); }else err("%s: error %d", __func__, status);/* Resubmit urb so we continue receiving IRQ data */if (status != -ESHUTDOWN && status != -ENOENT) {err = usb_submit_urb(urb, GFP_ATOMIC);if (err)dbg("%s: resubmit intr urb failed. (%d)",__func__, err);}}
找了好久,在linux-usb的邮件里边找到了一个人提交的patch,里边描述的问题正好就是option: option_instat_callback: error -2,综合了他的修改,同时在option.c文件前边加上dbg函数:
#ifdef CONFIG_USB_DEBUGstatic int mydebug = 5;#elsestatic int mydebug = 1;#endif/* Use our own dbg macro */#undef dbg#define dbg(format, arg...) \do { \ if(mydebug > 3)\printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg);\} while (0)
1 0
- 第二篇 4G模块-USB串口驱动测试
- 移远EC20 4G模块Linux驱动移植和测试
- 文章标题 : [分享]CH340/CH341,USB转串口驱动模块
- 基于RK3399的USB转串口驱动模块的编译
- TX2 USB串口驱动ttyACM模块 通过编译内核设置
- 测试方法三:电脑+USB转TTL串口模块+HC06
- 4G模块 串口编程流程
- 4G模块 串口编程流程
- USB-serial 串口测试
- 串口驱动模块
- I.MX6UL评估板4G模块的驱动集成与测试
- USB口 2.4G 无线串口 兼容NRF24L01P 通讯 模块使用说明
- 25.3.1 USB串口驱动
- USB转虚拟串口驱动
- USB转虚拟串口驱动
- stm32 usb 虚拟串口驱动
- USB-serial驱动分析(usb转串口)
- 4G模块-ME909S-821测试程序
- final关键字
- <37>python学习笔记——paramiko模块
- java——从零开始
- 详解Tomcat配置JVM参数步骤
- 1.01 eclipse上运行一个简单的html文件(Tomcat已安装)
- 第二篇 4G模块-USB串口驱动测试
- 一个n位的数,去掉其中的k位,问怎样去使得留下来的(n-k)位数按原来的前后顺序组成的数最小
- java 简单网络爬虫实现
- 第一篇博客
- Java设计模式——状态模式(STATE PATTERN)
- 【LeetCode】496. Next Greater Element I
- 块匹配模型的还原
- bzoj 3238 ahoi2013差异 后缀数组
- Qt 绘制仪表盘