3

I have been looking for a while, but I have not been able to find an answer to this question. I am trying to receive a connection notification for a specific usb device. Here is what I have/know:

I am running the linux kernel version 3.2. I have the id's needed to identify the usb device. I have created a kernel module for reading and writing to the device. The kernel module has been tested and works properly. The kernel module creates /dev/Component#.

I am trying to write a program that is notified of a USB device connection event and thus will not need to loop over the /dev/Component# and check if the file exists. My hope is that there is a signal/notification/event that already exists. I have seen the libusb, but my understanding is that you are really just creating a loop that reads all the devices. I have considered adding a syscall, but recompiling the kernel isn't really an option.

Any help would be greatly appreciated.

Thanks,

SgtSquatlow

sgtsquatlow
  • 31
  • 1
  • 2

1 Answers1

0

There is a solution using dbus. First you should install the library libdbus-glib (on Debian / Ubuntu the package is called libdbus-glib-1-dev) if it is not installed yet. Then you can peak a program here, compile the program like this:

gcc -o dbus-usb dbus-usb.c $(pkg-config --libs --cflags dbus-glib-1)
sshine
  • 15,635
  • 1
  • 41
  • 66
elhadi dp ıpɐɥןǝ
  • 4,763
  • 2
  • 30
  • 34
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/18632874) – sshine Jan 26 '18 at 14:44
  • @Simon Shine i have linked a stackoverflow example. i cannot see how a stackoverflow link become invalid. – elhadi dp ıpɐɥןǝ Jan 29 '18 at 13:32
  • I'm sorry, I didn't notice at first. You're quite right. This answer was automatically flagged for being short. I've improved on the formatting (using `$(...)` instead of backticks) and upvoted it. – sshine Jan 29 '18 at 15:36