y296144646q 发表于 2010-6-12 12:41:41

usb_modeswitch转换模式 出错

我最近在做华为ET128的3G驱动,网上说第一次插进开发板时是被认作CD-ROM所以就要转换成MODEOM模式 所以我移植了usblib usb_modeswitch工具,信息如下:(板子是2440开发板,内核版本是Linux2.6.30.4)
# 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这 一步之后再没反映啦 想请问下是啥原因啊
好像也没报错啊有这方面经验的好人 说说话啊

y296144646q 发表于 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)
页: [1]
查看完整版本: usb_modeswitch转换模式 出错