搜索
bottom↓
回复: 2

usb_modeswitch转换模式 出错

[复制链接]

出0入0汤圆

发表于 2010-6-12 12:41:41 | 显示全部楼层 |阅读模式
我最近在做华为ET128的3G驱动,网上说第一次插进开发板时是被认作CD-ROM  所以就要转换成MODEOM模式 所以我移植了usblib usb_modeswitch工具,信息如下:(板子是2440开发板,内核版本是Linux2.6.30.4)
[root@296144646 /]# usb_modeswitch -W
Reading config file: /etc/usb_modeswitch.setup

* usb-modeswitch: handle USB devices with multiple modes
* Version 1.1.2alpha (C) Josua Dietze 2010
* Based on libusb0 (0.1.12 and above)

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1da1
TargetVendor=   0x12d1
TargetProduct=  not set
TargetClass=    not set

DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
GCTMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00

InquireDevice enabled (default)
Success check disabled
System integration mode disabled

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 001
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_devices: Found 002 on 001
usb_os_find_devices: Found 001 on 001
error obtaining child information: Inappropriate ioctl for device

Looking for target devices ...
  searching devices, found USB ID 12d1:1da1
   found matching vendor ID
  searching devices, found USB ID 1d6b:0001
No devices in target mode or class found
Looking for default devices ...
  searching devices, found USB ID 12d1:1da1
   found matching vendor ID
   found matching product ID
   adding device
  searching devices, found USB ID 1d6b:0001
Found devices in default mode or classzhe shi na a
(1)
Accessing device 002 on bus 001 ...
Ambiguous Class/InterfaceClass: 0x02/0x08Using endpoints 0x05 (out) and 0x85 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
到这一步就停啦  我也不知道咋回事。。。。。。按照网上说的完整信息应如下:
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached

SCSI inquiry data (for identification)
-------------------------
Vendor String: HUAWEI
Model String: Mass Storage
Revision String: 2.31
-------------------------

USB description usb 1-1: usbfs: process 1172 (usb_modeswitch) did not claim interface 0 before use
data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
usb 1-1: usb_modeswitch timed out on ep0out
usb 1-1: USB disconnect, address 2
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.
但我到OK, driver "usb-storage" detached这 一步之后再没反映啦 想请问下是啥原因啊
好像也没报错啊  有这方面经验的好人 说说话啊

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

 楼主| 发表于 2010-6-13 12:05:45 | 显示全部楼层
我通过打印信息测试得知是如下过程出错:
在usb_modeswitch.c中的ret = usb_bulk_write(devh, MessageEndpoint, (char *)command, 31, 0);和ret = usb_bulk_read(devh, ResponseEndpoint, data, 36, 0);我的程序走过了usb_bulk_write,却在usb_bulk_read中进入了死循环。。。。。然后我在移植的libusb库中找到了(linux.c中附件提供)int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout)
{
  /* Ensure the endpoint address is correct */
  return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
                timeout);
}

int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout)
{
  /* Ensure the endpoint address is correct */
  ep |= USB_ENDPOINT_IN;
  return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
                timeout);
}

/*然后通过打印信息知道是在usb_urb_transfer中的    while (!urb.usercontext && ((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
      tv.tv_sec = 0;
      tv.tv_usec = 1000; // 1 msec
      select(dev->fd + 1, NULL, &writefds, NULL, &tv); //sub second wait
  }   usb_bulk_write执行一次就退出来拉  而usb_bulk_read确实无限循环  网上有 人说是卡里没钱啦 但这段代码和卡里有没有钱好像没关系啊
[ 此帖被296144646在2010-06-13 12:03重新编辑 ]
描述:用到的两个文件
附件:  个人自愿.zip (17 K) 下载次数:0 [删除]
usb_modeswitch.c 和linux.courdev_561619.zip(文件大小:16K) (原文件名:个人自愿.zip)
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-29 20:01

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表