Automatic Activation, Hotplug and UDEV, Configuration
Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 26 Sep 2011, 17:32

O.K., udev is obviously active on your system.

You might want to check if any other "rules" file is involved with the Huawei ID.
Do a "grep 1446" in the directory "/etc/udev/rules.d". Only usb_modeswitch's rules file should come up.

Annother possible issue is the udev version. Old releases might have a problem with the use of ATTRS in the rules file. That should show up somewhere in the /var/log/syslog file though.

If that is the case, edit "40-usb_modeswitch.rules" and replace all ATTRS with SYSFS.


mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 26 Sep 2011, 19:21

[root@localhost rules.d]# grep 1446 *
40-usb_modeswitch.rules:SUBSYSTEM=="usb", SYSFS{idProduct}=="1446", SYSFS{idVendor}=="12d1", RUN+="/usr/sbin/usb_modeswitch"

So 40-usb_modeswitch.conf is the only file with 1446 in it.

/var/log/syslog not on my system.

in /etc/udev/rules.d/40-usb_modeswitch.conf:
SUBSYSTEM=="usb", SYSFS{idProduct}=="1446", SYSFS{idVendor}=="12d1", RUN+="/usr/sbin/usb_modeswitch"

So there is already SYSFS.

Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 26 Sep 2011, 20:00

That is strange ... Is it possible that there was an old version of usb_modeswitch installed before ?
It's been quite a while since I changed from SYSFS to ATTRS. And the RUN command is different from the current one. It should be:

Code: Select all

RUN+="usb_modeswitch '%b/%k'"
You want the little script in /lib/udev running, not the actual binary program in /usr/sbin.

Maybe you just replace the RUN command for the Huawei line (copy and paste the call from above) and see what happens ...


mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 26 Sep 2011, 21:53

I changed the RUN command in 40-usb_modeswitch.rules and put the stick in the computer.
After that the switch was made automatically (WOW!)
I started wvdialconf and teh modem was found and the configuration was saved in wvdial.conf.
Then I started wvdial but it kept saying: no carrier found.
I checked the stick in my Apple computer but in this computer the stick connected to the internet.
I restarted the computer and put the stick again in the port. The switch was OK but the nodes /dev/ttyUSB* were not made so wvdial could not do it's work.

Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 27 Sep 2011, 00:04

Don't trust the automatic port selection of wvdial.

There should be a file named "/dev/gsmmodem" which usb_modeswitch creates after switching. This symbolic link points to the usable port of the modem.
You can give this file name as port in "wvdial.conf" (edit manually).




mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 27 Sep 2011, 13:50

I have no /dev/gsmmodem after plugging in the stick.
I have turned on logging so I have now logging in /var/log

usb_modeswitch_1-1 last lines:
Found target device, now opening

Found target device 006 on bus 001

Target device description data
-------------------------
Manufacturer: Huawei Technologies
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Found correct target device

Mode switch succeeded. Bye.

ok:12d1:14ac

usb_modeswitch_1-1:1-0
USB_ModeSwitch log from Tue Sep 27 09:47:06 CEST 2011

Raw args from udev: 1-1:1.0/1-1:1.0 {}

Using global config file: /etc/usb_modeswitch.conf
Warning: USB attribute "serial" not found.
----------------
USB values from sysfs:
manufacturer Huawei Technologies
product HUAWEI Mobile
serial
----------------
bNumConfigurations is 1 - don't check for active configuration
SCSI attributes not needed, moving on
checking config: /usr/share/usb_modeswitch/12d1:1446
! matched, now switching
(running command: /usr/sbin/usb_modeswitch -I -W -c /usr/share/usb_modeswitch/12d1:1446)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are expected in the process)
--------------------------------
usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 005
usb_os_find_busses: Found 004
usb_os_find_busses: Found 003
usb_os_find_busses: Found 002
usb_os_find_busses: Found 001
usb_os_find_devices: Found 001 on 005
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 001 on 003
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 002 on 001
skipping descriptor 0xB
skipped 1 class/vendor specific endpoint descriptors
skipped 6 class/vendor specific interface descriptors
skipping descriptor 0x25
skipped 1 class/vendor specific endpoint descriptors
skipped 7 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 001
error obtaining child information: Inappropriate ioctl for device

Reading config file: /usr/share/usb_modeswitch/12d1:1446

* usb_modeswitch: handle USB devices with multiple modes
* Version 1.1.9 (C) Josua Dietze 2011
* Based on libusb0 (0.1.12 and above)

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x1446
TargetVendor= 0x12d1
TargetProduct= not set
TargetClass= not set
TargetProductList="1001,1406,140b,140c,1412,141b,1433,14ac,1506"

DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
GCTMode=0
KobilMode=0
SequansMode=0
MobileActionMode=0
CiscoMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00

InquireDevice disabled
Success check enabled, max. wait time 20 seconds
System integration mode enabled


Looking for target devices ...
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 064e:d101
searching devices, found USB ID 0000:0000
No devices in target mode or class found
Looking for default devices ...
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 064e:d101
searching devices, found USB ID 0000:0000
No devices in default mode found. Nothing to do. Bye.

--------------------------------
(end of usb_modeswitch output)

Device directory in sysfs is gone! Something went wrong, aborting

usb_modeswitch_1-1:1-1

USB_ModeSwitch log from Tue Sep 27 09:47:06 CEST 2011

Raw args from udev: 1-1:1.1/1-1:1.1 {}

Using global config file: /etc/usb_modeswitch.conf

Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 27 Sep 2011, 14:46

We know that you have an old version of "40-usb_modeswitch.rules" in "/etc/udev/rules.d". Best to replace it with the one in the current data package (where you ran "make install" from).
This should prevent usb_modeswitch from running several times at once - which it does now obviously, confusing itself. There should be only one big log, and probably several small ones for the ttyUSB ports.

If you stop getting any log after the replacement, you might have to do the ATTRS/SYSFS replacement discussed earlier.


mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 27 Sep 2011, 17:45

I have replaced the 40-usb_modeswitch.rules in /etc/udev/rules.d
Put the stick in and /dev/gsmmodem was ceated.
started wvdial and it connected.
After that I could browse the internet (wooow!!!)
First I want to thank you very much for your patient help!
But is it possible to start wvdial automatically after the modeswitch?

Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 27 Sep 2011, 19:43

Well, you can add a new udev rule which starts wvdial as soon as the device has switched.

Or you edit the file /usr/sbin/usb_modeswitch_dispatcher; you can start any program from there with the "exec" command.

I would insert two lines at line no. 637, right befor the "exit" command:

Code: Select all

...
after 3000
exec /usr/bin/wvdial &
...
The first line waits for three seconds, just to make sure the modem is ready. You can try to minimize that wait. The count is in milliseconds, of course.
In the second line, you might have to change the path of wvdial according to your setup ("which wvdial" should tell).


mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 27 Sep 2011, 23:50

This is a part of the usb_modeswitch_dispatcher file from line 625 to line 656:
As you can see line 637 or 638 has no exit command.
The first exit command is in line 653. So I put the lines right before this exit command. But no succes.

625 proc {Log} {msg} {
626
627 global wc logging device
628 if {$logging == 0} {return}
629 if {![info exists wc]} {
630 if [catch {set wc [open /var/log/usb_modeswitch_$device w]} err] {
631 set wc "error"
632 return
633 }
634 puts $wc "\n\nUSB_ModeSwitch log from [clock format [clock seconds]]\n"
635 }
636 if {$wc == "error"} {return}
637 puts $wc $msg
638
639 }
640 # end of proc {Log}
641
642 # Closing the log file if open and exit
643 proc {SafeExit} {} {
644
645 global wc
645 global wc
646 if [info exists wc] {
647 catch {close $wc}
648 }
649
650 after 3000
651 exec /usr/bin/wvdial &
652
653 exit
654
655 }
656 # end of proc {SafeExit}

mclinux
Posts: 15
Joined: 21 Sep 2011, 14:25

Post by mclinux » 27 Sep 2011, 23:59

I have set the time to 10000 and it worked.

Josh
Site Admin
Posts: 6593
Joined: 03 Nov 2007, 00:30

Post by Josh » 28 Sep 2011, 08:13

My reference file was not up to date, so I gave you a wrong line number. You found the right spot though.

The delay depends on your system, of course. Good to hear you made it work.


Post Reply