Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
jskowron
Posts: 1
Joined: 13 Jul 2013, 14:28

Why interface class check moved to dispatcher for 19d2:2000?

Post by jskowron » 13 Jul 2013, 14:52

In the old style (ver 20120815), I have found the udev rule for checking the interface class of my ZTE modem working after a small FIX (described below).

And thus, I am very curious why the interface class was moved away from configurable and user changeable text file: /lib/udev/rules.d/40-usb_modeswitch.rules to the unconfigurable, already compiled program usb_modeswitch_dispatcher? Is there some deeper reason, or it is just a hack. If so, my fix should help avoid this hack.

I have ZTE MF60 (default 19d2:2000, target 19d2:1402) and the old version (usb-modeswitch-data, version 20120815) was not working. But the fix is easy to include. The problem with the old udev rule not working was use of ATTRS instead of ATTR.
Old version was:
ATTRS{bInterfaceNumber}=="03", ATTRS{bInterfaceClass}=="08", ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="2000", GOTO="modeswitch_rules_begin"

my working version is:
ATTR{bInterfaceNumber}=="03", ATTR{bInterfaceClass}=="08", ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="2000", GOTO="modeswitch_rules_begin"

I have noticed that in the new version of usb-modeswitch-data, this check was removed from the text configuration file. However it was added to a compiled dispatcher in the usb-modeswitch package.

In the file: usb_modeswitch.tcl then loaded and compiled as dispatcher.c in usb-modeswitch package one can see:
if {$iface < 0} {
if {$usb(idVendor)=="19d2" && $usb(idProduct)=="2000"} {
set iface [ChkIface 3]
}

And there is only one block of this type, only for this single manufacturer. This looks like an unnecessary hack, which I hope can be avoided by editing udev rule.

Cheers,
Jan Skowron

LOM
Posts: 1404
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: Why interface class check moved to dispatcher for 19d2:2

Post by LOM » 13 Jul 2013, 16:08

Those questions should be addressed to the maintainer of the linux distro you are using.
If you want to check the original source with datapackage including the udev rules then they can be downloaded here:
http://www.draisberghof.de/usb_modeswitch/

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

Re: Why interface class check moved to dispatcher for 19d2:2

Post by Josh » 13 Jul 2013, 21:37

The Ubuntu people chose to re-implement the dispatcher script in compiled C. I very much prefer the script approach, for the same reason as you do.

You may complain to Ubuntu, or you can just use the original source. It should be enough to rename and replace two files:

- /lib/udev/usb_modeswitch, use "usb_modeswitch.sh" from the source package

- /usr/sbin/usb_modeswitch_dispatcher, use "usb_modeswitch.tcl" from the source package

Rename the Ubuntu version to *.orig or something and name the source files so that they take the place of the "origs". They should also be set to "executable".

Post Reply