Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
evdras
Posts: 4
Joined: 24 Jan 2013, 14:42

SLES 10. autorun USB_ModeSwitch

Post by evdras » 24 Jan 2013, 15:25

Hi.

Sorry if the question has already been.

I have SUSE Linux Enterprise Server 10 sp3
I download src usb-modeswitch-1.2.5.tar.bz2 and usb-modeswitch-data, then i do untar and make install
Compile and install Ok.

Then copy 12d1:1446 from /usr/share/usb_modeswitch/ to /etc/usb_modeswitch.d/12d1:1446

Code: Select all

lll:~ # more /etc/usb_modeswitch.d/12d1\:1446
# Huawei, newer modems

DefaultVendor=  0x12d1
DefaultProduct= 0x1446

TargetVendor=  0x12d1
TargetProductList="1001,1406,140b,140c,1412,141b,1432,1433,1436,14ac,1506,1511"

MessageContent="55534243123456780000000000000011062000000100000000000000000000"
Manually everything works well, i.e. i do

Code: Select all

usb_modeswitch -c /etc/usb_modeswitch.d/12d1:1446
modprobe usbserial vendor=0x12d1 product=0x1506
But after a reboot i have to enter these commands again.

How to automatically run usb_modeswitch on SLES?
I tried to add rules to the udev rules.d

Code: Select all

SUBSYSTEM=="usb", SYSFS(idProduct)=="1446", SYSFS(idVendor)=="12d1", RUN+="/usr/local/sbin/my.sh"

Code: Select all

lll:~ # more /usr/local/sbin/my.sh
usb_modeswitch -c /etc/usb_modeswitch.d/12d1:1446
modprobe usbserial vendor=0x12d1 product=0x1506
but it did not help
I enabled logging on /etc/usb_modeswitch.conf, but no log file created...

Thanks for help.

sedsed
Posts: 11
Joined: 19 Jan 2013, 23:50

Re: SLES 10. autorun USB_ModeSwitch

Post by sedsed » 24 Jan 2013, 16:51

shouldnt you run something like this:
sudo usb_modeswitch -c /etc/usb_modeswitch.conf
instead of
usb_modeswitch -c /etc/usb_modeswitch.d/12d1:1446


btw in usm_modeswitch.conf you have the parameter for autoswitching , maybe set that to enabled. Like you did for logging. Run that and you should get a log file.

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

Re: SLES 10. autorun USB_ModeSwitch

Post by Josh » 24 Jan 2013, 18:20

No no, please don't use /etc/usb_modeswitch.conf for device-specific settings !!!

This advice is from around four years ago, things have changed quite a bit since then.


The whole point of the current 'framework' of usb_modeswitch is to make the process fully automatic. If that does not work for you, evdras, make sure you have the required system packages installed, especially "tcl".

Have a look at the USB_ModeSwitch main doc page again (see top nav bar) or re-read the README in the "usb-modeswitch" source package.

I just looked up the kernel version of SLES 10 and it's very dated; it may be that other components are quite old as well.
If you have the "tcl" package installed and there is still no log created, have a look at your syslog (in /var/log). There may be an issue with "udev" and the "rules" file syntax, which should be mentioned in the log.

evdras
Posts: 4
Joined: 24 Jan 2013, 14:42

Re: SLES 10. autorun USB_ModeSwitch

Post by evdras » 25 Jan 2013, 07:49

Thanks for the answer.
Josh wrote: The whole point of the current 'framework' of usb_modeswitch is to make the process fully automatic. If that does not work for you, evdras, make sure you have the required system packages installed, especially "tcl".
TCL installed - ver 8.4.12
tclsh - command available
Josh wrote: Have a look at the USB_ModeSwitch main doc page again (see top nav bar) or re-read the README in the "usb-modeswitch" source package.

If you have the "tcl" package installed and there is still no log created, have a look at your syslog (in /var/log). There may be an issue with "udev" and the "rules" file syntax, which should be mentioned in the log.
I re-read main doc page in section "Old systems (e.g. CentOS 5 or Xandros 6)"
Then copy 40-usb_modeswitch.rules from /lib/udev/rules.d to /etc/udev/rules.d and change the logging level to "debug" in /etc/udev/udev.conf.
In messages log:

Code: Select all

Jan 25 08:17:48 krp-vc udevd[937]: add_to_rules: unknown key 'ATTRS{bNumConfigurations}', in 'KERNEL'
...
Jan 25 08:18:28 krp-vc udevd[937]: add_to_rules: unknown key 'ATTRS{bNumConfigurations}', in 'ATTR{bInterfaceClass}'
Then i replace all occurences of "ATTR" and "ATTRS" with "SYSFS" in /etc/udev/rules.d/40-usb_modeswitch.rules
No error in messages with rules, but USB_ModeSwitch log not cteated.

What event search in messages log which starts (or not) USB_ModeSwitch?

evdras
Posts: 4
Joined: 24 Jan 2013, 14:42

Re: SLES 10. autorun USB_ModeSwitch

Post by evdras » 28 Jan 2013, 14:27

I looked man udev in SLES10 and your rules file.
Then rewrote the rules, now it looks like this:

Code: Select all

ACTION=="add|change", KERNEL=="ttyUSB*", SYSFS{bNumConfigurations}=="*", PROGRAM="usb_modeswitch --symlink-name %p %s{idVendor} %s{idProduct} %E{PRODUCT}", SYMLINK="%c"
ACTION=="add|change", SUBSYSTEM=="usb", SYSFS{bInterfaceClass}=="ff", SYSFS{bInterfaceNumber}=="00", SYSFS{bNumConfigurations}=="*", RUN+="usb_modeswitch --driver-bind %p %s{idVendor} %s{idProduct} %E{PRODUCT}"
ACTION=="add|change", SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", SYSFS{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"
1. Now USB_ModeSwitch logs are created.
2. If system already started and work, i remove/insert modem and all work good.

Code: Select all

Jan 28 14:34:27 krp-vc udevd-event[5933]: run_program: 'usb_modeswitch --driver-bind /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0 12d1 1506 12d1/1506/0'
Jan 28 14:34:27 krp-vc udevd-event[5959]: run_program: 'usb_modeswitch --symlink-name /class/tty/ttyUSB2 12d1 1506 '
Jan 28 14:34:27 krp-vc udevd-event[5967]: run_program: 'usb_modeswitch --symlink-name /class/tty/ttyUSB1 12d1 1506 '
Jan 28 14:34:27 krp-vc udevd-event[5959]: run_program: '/lib/udev/usb_modeswitch' returned with status 0
Jan 28 14:34:27 krp-vc udevd-event[5967]: run_program: '/lib/udev/usb_modeswitch' returned with status 0
Jan 28 14:34:28 krp-vc udevd-event[5933]: run_program: '/lib/udev/usb_modeswitch' returned with status 0
Jan 28 14:34:28 krp-vc udevd-event[5986]: run_program: 'usb_modeswitch --symlink-name /class/tty/ttyUSB0 12d1 1506 '
Jan 28 14:34:28 krp-vc udevd-event[5986]: run_program: '/lib/udev/usb_modeswitch' (stdout) 'gsmmodem'
Jan 28 14:34:28 krp-vc udevd-event[5986]: run_program: '/lib/udev/usb_modeswitch' returned with status 0
Jan 28 14:34:28 krp-vc usb_modeswitch: switched to 12d1:1506 on 001/006
Jan 28 14:34:28 krp-vc usb_modeswitch: switched to 12d1:1506 on 001/006
Jan 28 14:34:28 krp-vc usb_modeswitch: switched to 12d1:1506 on 001/006

3. If turn off the computer and then turn, no switched device...

Code: Select all

USB_ModeSwitch log from Mon Jan 28 15:42:19 MSK 2013

Raw args from udev: 1-5/1-5

Using global config file: /etc/usb_modeswitch.conf
Using top device dir /sys/bus/usb/devices/1-5
   Warning: USB attribute "busnum" not found
Using interface 1.0
----------------
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: /etc/usb_modeswitch.d/12d1:1446
! matched. Reading config data
Using config file from override folder /etc/usb_modeswitch.d
Logger is /bin/logger
config: TargetVendor set to 12d1
config: TargetProductList set to 1001,1406,140b,140c,1412,141b,1432,1433,1436,14ac,1506,1511
Driver module is "option", ID path is /sys/bus/usb-serial/drivers/option1

Command to be run:
usb_modeswitch -W -D -s 20 -u -1   -v 12d1 -p 1446 -f $configBuffer

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------
usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 004
usb_os_find_busses: Found 005
usb_os_find_busses: Found 003
usb_os_find_busses: Found 002
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 001 on 005
usb_os_find_devices: Found 001 on 003
usb_os_find_devices: Found 001 on 002

Reading long config from command line

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 1.2.5 (C) Josua Dietze 2012
 * 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,1432,1433,1436,14ac,1506,1511"

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

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
 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
 No devices in default mode found. Nothing to do. Bye.

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

Core program reported switching failure. Exiting

In usb_modeswitch log device has not been defined in the system... but if execute the command lsusb after boot the system:

Code: Select all

Bus 001 Device 002: ID 12d1:1446
Bus 001 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Maybe i need to add "sleep <sec>" in code?

Thanks for help.

evdras
Posts: 4
Joined: 24 Jan 2013, 14:42

Re: SLES 10. autorun USB_ModeSwitch

Post by evdras » 30 Jan 2013, 16:01

I was able to switch modem at cold start the PC, but this is wrong way...
I wrote startup script:
1. Create file after.local in /etc/init.d
2. Add code

Code: Select all

#!/bin/sh
/usr/sbin/usb_modeswitch -c /usr/local/bin/12d1:1446
аfter this udev rules work (from the previous post) at cold start the PC.

P.S. /usr/local/bin/12d1:1446 - the path where i copied config 12d1:1446

Post Reply