Author Message

<  Everything Coding  ~  usb_control_msg called in modeswitch.c

PostPosted: Thu Dec 02, 2010 5:44 am Reply with quote
Posts: 4 Joined: Thu Dec 02, 2010 5:28 am
function in linux system is defined as follows:
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
__u8 requesttype, __u16 value, __u16 index, void *data,
__u16 size, int timeout)

but in the modeswitch.c,the function is called in get_current_configuration() as follows:

ret = usb_control_msg(devh, USB_DIR_IN + USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_GET_CONFIGURATION, 0, 0, buffer, 1, 1000);

they even take different numbers of parameters........
it puzzled me....


Offline
PostPosted: Thu Dec 02, 2010 3:48 pm Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
You are probably referring to the kernel / system method of the same name.
Note that I'm using the command from the libusb header - since there is only one possible command pipe, this parameter is obviously skipped for convenience. The other params are matching.

See
http://libusb.sourceforge.net/doc/funct ... olmsg.html



Offline
PostPosted: Fri Dec 03, 2010 3:37 pm Reply with quote
Posts: 4 Joined: Thu Dec 02, 2010 5:28 am
thanks very much
now I came across a new problem.
while I install the data package,command "which udevadm " in the makefile does not work because udevadm is not installed.
When I try to install it ,a lot of dependency makes me in trouble.I think my OS,centos5,should be responsible for it.
Could anyone recommend good OS?


Offline
PostPosted: Fri Dec 03, 2010 7:50 pm Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
There is a crude test sequence in the Makefile which should result in using the older udev tools if the (new) udevadm is not found on the system.

In that case it will call "udevcontrol" which does basically the same as "udevadm control". If you have that program, you should not have to worry about anything.

Even if you don't have any of those tools, this is not a problem; the worst that can happen is that you have to reboot your system once for udev to read the newly installed "rules" file.



Offline
PostPosted: Sun Dec 05, 2010 3:28 am Reply with quote
Posts: 4 Joined: Thu Dec 02, 2010 5:28 am
thanks a lot,I got it.
yesterday,I saw a method about how to use 3g usb mode in terminals.
Only the follow steps:

1 :plug in the usb,then "lsusb" you will see the device id such as:ID 15eb:7153
2:"eject" the cdrom,and then you will see the device missing and another device id coming:such as:ID 15eb:7152,
you can use command "cat /proc/bus/usb/devices" to see four undrived device just like this:
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=15eb ProdID=7152 Rev= 0.00
S: Manufacturer=DATANG MOBILE 2008
S: Product=CBP7.0
S: SerialNumber="YYYYYYYYYYYYY"
C:* #Ifs= 4 Cfg#= 1 Atr=c0 MxPwr=0mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E: Ad=03(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=83(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(stor.) Sub=ff Prot=ff Driver=(usb-storage)
E: Ad=04(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=84(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms

3:at last,you just need to use the command to drive them"# modprobe usbserial vendor=0x15eb product=0x7152 "

after this several "serials-port"will come out,you can wvdial.


could you tell me if the USB_ModeSwitch works like this?or other steps ?
The more detailed,the better.
BEST WISHES.


Offline
PostPosted: Sun Dec 05, 2010 4:20 pm Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
luoj05 wrote:
could you tell me if the USB_ModeSwitch works like this?or other steps ?
The more detailed,the better.
I'd be delighted to - but first be so kind and tell me something about the device, since it is not in the usb_modeswitch database yet.

We know the target ID already (15eb:7153), but what is the ID when it is unswitched?



Offline
PostPosted: Mon Dec 06, 2010 3:23 am Reply with quote
Posts: 4 Joined: Thu Dec 02, 2010 5:28 am
thanks for your reply
the 3g usb card was produced by a small company.
The default ID is 15eb:7153 .
the target ID is 15eb:7152.

I just want to know the whole process of the usb-card but my card doesn't go to the end of the program successfully.
BEST WISHES.


Offline
PostPosted: Mon Dec 06, 2010 9:23 am Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
Ah, yes, you posted the initial ID already. Fine.

It is correct that some modems use the "eject" mass storage command for switching. It can be issued in several ways: by using the desktop symbol (if the dekstop environment does automounting), running the command line "eject" tool - and sending the mass storage comand directly on the USB level.

For the first two methods you have to wait until the storage device is fully prepared by the kernel which usually takes annother five seconds. This may be fine for manual switching but is not suitable for an automatic procedure.

Note that there are many other switching commands apart from "eject"; there is no limit for the manufacturers what they can build into their drivers and their firmware. See the device reference for all the variants (messages containing "061b" are "eject" commands):

http://www.draisberghof.de/usb_modeswit ... nce.txt.gz

After switching you usually have a new device with some serial ports, visible only as interfaces with class 255 (which means "vendor-specific"). You need to bind a serial driver to these interfaces; if there is no driver that knows the new device ID, you have to tell it to the driver you want.

The cleanest way is to add the new device ID to the driver source code so that the modem is immediately bound to it once it shows up. The recommended driver is "option" which is optimized for 3G devices. "usbserial" should be avoided if possible, according to the kernel USB developers.

Not everyone wants to recompile the kernel for a new 3G stick. Fortunately, from kernel version 2.6.27 the "option" driver has the ability to add new device IDs on the fly after the module was loaded. This is what usb_modeswitch is doing once the switching was successfull and no driver will bind automatically to the switched device.



Offline

Display posts from previous:  Sort by:

All times are UTC+02:00
Page 1 of 1
8 posts
Users browsing this forum: No registered users and 1 guest
Search for:
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum