Re: Plugging in USB devices



DBBu***@xxxxxxxxx wrote:
> My program can already see/read/write to a device if it's plugged in
> before I start the program. But, I need to be able to keep this program
> running always and if I plug in a new device, my program needs to
> realize that it's there. Is this possible in Linux?

Yes, it is possible. The best way would probably be to let hotplug send a
message in some way to your program.

> If I plug in a USB device, a message shows up in one of my terminals
> saying that a device has been plugged in. Is there a system wide
> message that is being sent that I can catch with my already running
> program? How can I go about this?

There is a program called dmesg which displays those messages. Maybe you
could borrow some code from dmesg.

However, I still think that hotplug would be a better solution. There is
some good documentation describing how to set up hotplug to change
permissions for a usb digital camera at
http://www.gphoto.org/doc/manual/permissions-usb.html . Changing
permissions is not what you want to do, but if you modify those scripts to
send a message to your program (maybe with a socket) I think that you have
accomplished what you want.

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc7(at)uthyres.com Examples of addresses which go to spammers:
root@xxxxxxxxxxxxx root@localhost

.