linux usb connect/disconnect event

后端 未结 3 1787
滥情空心
滥情空心 2021-02-02 01:53

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:

3条回答
  •  有刺的猬
    2021-02-02 01:55

    Unfortunately, there is no udev event produced on connect/disconnect on gadget side, so it is almost to impossible to monitor these events.
    You could monitor kernel messages (dmesg). It seems to be stupid idea. Or watch some files in sysfs. Possible better way is kernel patching.

    update: I do not understand why this answer got negative rating.
    Maybe some people mix USB host part (which produces UDEV events on device plug/unplug) and USB device/gadget part (which doesn't produce such events)
    If your linux computer works as a gadget (USB device which is connected to some USB host) there is no good way to catch plug/unplug events.

    Proof: message by Greg Kroah-Hartman
    another copy if previous link is down

提交回复
热议问题