Skip to contentSkip to conversation

How to trigger a udev rule

DISCUSSION Thomas Bechtold 4 participants 6 messages Mar 3, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

i have a udev rule and want to trigger this rule with "udevadm trigger". The rule is:

### only check /dev/ttyS1 (atmel_usart.1) for modem ### ACTION!="add|change", GOTO="mm_platform_device_whitelist_end" SUBSYSTEM!="platform", GOTO="mm_platform_device_whitelist_end" DRIVERS=="atmel_usart",KERNELS=="atmel_usart.1",ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1" LABEL="mm_platform_device_whitelist_end"

Any idea how to trigger this?

Cheers,

Tom

#1 lore raw
Quoted 5 lines · Thomas Bechtold

Hi,

i have a udev rule and want to trigger this rule with "udevadm trigger". The rule is:

Quoted 9 lines

### only check /dev/ttyS1 (atmel_usart.1) for modem ### ACTION!="add|change", GOTO="mm_platform_device_whitelist_end" SUBSYSTEM!="platform", GOTO="mm_platform_device_whitelist_end" DRIVERS="atmel_usart",KERNELS="atmel_usart.1",ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1" LABEL="mm_platform_device_whitelist_end"

Any idea how to trigger this?

You can't trigger specific rule. You can trigger processing for specific device; and check whether this rule is executed as part of it.

#2 lore raw
In reply to Thomas Bechtold
Quoted 4 lines · On Thu, 03 Mar 2011 07:21:27 +0100 Thomas Bechtold…

Hi,

i have a udev rule and want to trigger this rule with "udevadm trigger".

I am also interested to know how to trigger udev rule / event

Thank

#3 lore raw
In reply to Thomas Bechtold

Hello Thomas,

funny that you ask, a few days ago someone asked exactly the same thing in #udev.

Thomas Bechtold [2011-03-03 7:21 +0100]:

Quoted 5 lines

### only check /dev/ttyS1 (atmel_usart.1) for modem ### ACTION!="add|change", GOTO="mm_platform_device_whitelist_end" SUBSYSTEM!="platform", GOTO="mm_platform_device_whitelist_end" DRIVERS=="atmel_usart",KERNELS=="atmel_usart.1",ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1" LABEL="mm_platform_device_whitelist_end"

I'm afraid udevadm trigger doesn't support the same parental matching as udev rules themselves do, so I don't think there can be a precise trigger unless you already know the corresponding /dev/ttySn device node. If you do, then just do

  udevadm trigger --sysname-match=ttySn

If you dont, it shouldn't matter much to trigger all ttyS devices:

  udevadm trigger --sysname-match=ttyS*

BTW, you can also try with --verbose --dry-run (also works as user) to see what it would do, and refine the match until it works to your needs.

Martin

Signature · 2 lines
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
#4 lore raw
In reply to Thomas Bechtold

Hi Martin,

Quoted 4 lines · Martin Pitt

Hello Thomas,

funny that you ask, a few days ago someone asked exactly the same thing in #udev.

that was me:)

Quoted 7 lines

Thomas Bechtold [2011-03-03 7:21 +0100]:

Quoted 5 lines

### only check /dev/ttyS1 (atmel_usart.1) for modem ### ACTION!="add|change", GOTO="mm_platform_device_whitelist_end" SUBSYSTEM!="platform", GOTO="mm_platform_device_whitelist_end" DRIVERS="atmel_usart",KERNELS="atmel_usart.1",ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1" LABEL="mm_platform_device_whitelist_end"

Quoted 6 lines

I'm afraid udevadm trigger doesn't support the same parental matching as udev rules themselves do, so I don't think there can be a precise trigger unless you already know the corresponding /dev/ttySn device node. If you do, then just do

   udevadm trigger --sysname-match=ttySn

i know the device name. it's always ttyS1. But your trigger does not match the rule:

# udevadm trigger --sysname-match=ttyS1 --verbose
/sys/devices/platform/atmel_usart.1/tty/ttyS1

I tried to do this with udevadm (modemmanager is running in background and log is written to sdtout):

# udevadm trigger --action­d --subsystem-match=tty 
--subsystem-match=platform --sysname-match=ttyS1 --verbose
/sys/devices/platform/atmel_usart.1/tty/ttyS1

Here, ModemManager does nothing.

When i execute the command with ttyS0, the output is:

# udevadm trigger --action­d --subsystem-match=tty 
--subsystem-match=platform --sysname-match=ttyS0 --verbose
/sys/devices/platform/atmel_usart.1/tty/ttyS0
modem-manager[772]: <debug> [1299145393.216952] [mm-manager.c:802] 
device_added(): (tty/ttyS0): port's parent platform driver is not 
whitelisted

Here, ModemManager detects the trigger.

I think the question is how to set DRIVERS="atmel_usart" and KERNELS="atmel_usart.1" !?

Cheers,

Tom

#5 lore raw
In reply to Thomas Bechtold
Quoted 3 lines · Thomas Bechtold

i know the device name. it's always ttyS1. But your trigger does not match the rule:

Then you have to fix the rule :) because it won't be applied to real device as well.