Hello I am working on an embedded linux device with a usb port that uses the g_ether driver for usb networking.
When the usb plug is connected the dmesg output is:
You can use libudev or parse udevadm
output as @Ambroz Bizjak suggested. Although, I advise against adding an additional process (stdbuf
) and language (NCD
), just to parse udevadm's output.
A step between plain libudev and parsing output is modifying the udevadm sources. This solution reduces the needed resources and skips the parsing process altogether. When you look at the udev package, you will find the sources for udevd and udevadm in the udev
directory.
There, you have the main routine in udevadm.c
and the source for udevadm monitor
in udevadm-monitor.c
. Every event received will be printed through print_device()
. This is where you insert your code.
If you're tight on memory, you can strip off unneeded code for control
, info
, settle
, test-builtin
, test
and trigger
. On my system (Ubuntu 12.04), this reduces the size of udevadm by about 75%.