USB detection

Submitted by Anonymous
on March 24, 2009 - 9:29am

Hi,
I have a USB device which should get detected and the application running on 2.4 kernel should respond to it,
For example,
I have a printer and if you connect the printer, The application should show the printer button and disable the printer button accordingly if the printer is absent,Disabling and enabling button in the application is one part which I am able to achieve and whats bothering me is the signal part which is given to the application when printer is hooked on...
How exactly is it being done with USB memory ? or How to achieve that in an efficient way? Any ideas , suggestions or any documentation ??

PS:
1) Right now,I have kept a thread running to detect if the printer path can be opened; if it returns valid consider printer is present else vice-versa

use udev

on
March 24, 2009 - 12:17pm

Hi,
I guess you are looking for some thing like udev rules.
udev-rules
You can run any application/scripts on events from device.

Rgrds
srini

2.4

on
March 24, 2009 - 5:27pm

no udev for 2.4 ... there may be something possible with scripts called by /sbin/hotplug

if only one application is doing that, polling is a valid solution. if you need more applications with that functionality, to prevent polling storms use a helper program that does the polling and informs the applications via sockets or some other protocol.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.