Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
sandman
Posts: 2
Joined: 27 Jul 2016, 09:52

Syntax for RUN in UDEV rules?

Post by sandman » 27 Jul 2016, 10:07

Hi all,

I'm trying to get a better understanding for some things related to USB_ModeSwitch and UDEV. And I'm a bit confused by the RUN part of the rules:

Code: Select all

RUN+="usb_modeswitch '%b/%k'
To see what the %b and %k were, I tried to touch the values to a file. That gave me, for my modem, that %b was 1-1.4 and %k was 1-1.4.4 (if memory serves me right).

So far so good. But when I tried to manually run

Code: Select all

usb_modeswitch '1-1.4/1-1.4.4'
it failed and I got an error message. Also, I can't really find anything in the man page to suggest that this is a working command. Is this some sort of "hidden" way of activating usb_modeswitch, or what's the deal here?

(Sorry if this is covered in the documentation somewhere, I tried finding info about this and failed.)

Thanks

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

Re: Syntax for RUN in UDEV rules?

Post by Josh » 27 Jul 2016, 15:13

I admit there is some built-in confusion ...

The RUN entry from udev refers to a shell script in /lib/udev - with the same name ...
In the source folder the name is "usb_modeswitch.sh"; so it's different from the binary which ends up as "/sbin/usb_modeswitch".

In between, there is the wrapper "/sbin/usb_modeswitch_dispatcher". This is in turn called by the udev script.
For manual usage, only the binary in /sbin makes sense. That's what the man page refers to.

sandman
Posts: 2
Joined: 27 Jul 2016, 09:52

Re: Syntax for RUN in UDEV rules?

Post by sandman » 27 Jul 2016, 20:36

Aha, thanks. That clears up things quite a bit. :-)

The reason to why I was diving into this was that this rule:

Code: Select all

# Generic entry for all Huawei devices
ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
didn't work for my Huawei e3372. So I commented that and tried this:

Code: Select all

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f01", RUN+="usb_modeswitch '%b/%k'"
That also failed. But if I changed the RUN to this:

Code: Select all

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f01", RUN+="/usr/sbin/usb_modeswitch -v 12d1 -p 1f01 -c /usr/share/usb_modeswitch/12d1:1f01"
it worked just fine. (I want the modem to be in HiLink mode.)

Have I found a bug? Is this a new, weird modem that I should report somehow? Let me know if you need some info to peg down where it doesn't work.

I'm using version 2.2.0 on Raspbian on RPi.

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

Re: Syntax for RUN in UDEV rules?

Post by Josh » 28 Jul 2016, 12:10

Your version is already a bit outdated. In version 2.2.3, there was a fix for the problem which was introduced by changes in the udev/systemd pairing. I suggest you update to the latest version 2.4.0.

In a nutshell, the issue is the slash character in the parameter.

michaelarrington
Posts: 2
Joined: 11 Oct 2023, 09:53

Re: Syntax for RUN in UDEV rules?

Post by michaelarrington » 11 Oct 2023, 09:56

Once you've obtained the correct command and parameters to use with usb_modeswitch for your modem, you can then update your UDEV rule accordingly io games

timothyferriss
Posts: 5
Joined: 11 Oct 2023, 09:48

Re: Syntax for RUN in UDEV rules?

Post by timothyferriss » 16 Nov 2023, 04:50

The %b and %k variables in the RUN part of the udev rule are used to identify the specific USB bus and device to which the rule should apply. When you try to manually run the usb_modeswitch command with these values, it fails because the usb_modeswitch command expects the bus and device numbers to be separated by a colon, not a slash. The correct syntax for the command is usb_modeswitch 1-1.4:1-1.4.4.

retro bowl college

farare
Posts: 6
Joined: 30 Nov 2023, 06:41

Re: Syntax for RUN in UDEV rules?

Post by farare » 30 Nov 2023, 06:44

Josh wrote: 28 Jul 2016, 12:10 Your version is already a bit outdated. In version 2.2.3, there was a fix for the Geometry Dash problem which was introduced by changes in the udev/systemd pairing. I suggest you update to the latest version 2.4.0.

In a nutshell, the issue is the slash character in the parameter.
The 'RUN' directive in UDEV rules plays a pivotal role in facilitating the execution of custom actions triggered by device events. This directive is essential for users seeking to define specific commands or scripts that should be executed in response to particular device events.

Post Reply