Unable to run a user program on usb device connection
Hi,
I'm a newbie to Linux hotplug sub-system. I want
to hook a user space application with the hot plug sub-system in such a way that the application is executed on attaching a specific USB device. I've explained what all I tried, please let me know where I'm going wrong.
My linux kernel version is 2.6.10 and it uses the “udev” mechanism to support hot plug. Our application should be executed when a device with a specific vendor id and product id is plugged in the USB bus. I’ve enabled the hot plug support in the kernel; in fact by default CONFIG_HOTPLUG was enabled. I included a test.rules file in the /etc/udev/rules.d/ directory in which I have included the above mentioned vendor id, product id and in the PROGRAM parameter the name of the application to be run. To start with, this program is just a shell script that prints “Hello World” on the console. After this, when we plug in the above mentioned device I’m sure that the kernel has detected it because I’m seeing the device’s information in /proc/bus/usb/devices. But our shell script is not getting called at all. Can some one let me know what I'm missing here? The test.rules file contains the following line only
ATTR{idVendor}="0451", ATTR{idProduct}="97fb", SYMLINK+="hello-%k", MODE="666", PROGRAM="/home/shankar/usb_disp.sh"
Thanks in Advance,
Shankar
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
http://mobile.yahoo.com/go?refer=1GNXIC
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Hi,
I'm a newbie to Linux hotplug sub-system. Please
excuse me if the question is very basic. I want to hook a user space application with the hot plug sub-system in such a way that the application is executed on attaching a specific USB device. I've explained what all I tried below, please let me know where I'm going wrong.
My linux kernel version is 2.6.10 and it uses the “udev” mechanism to support hot plug. Our application should be executed when a device with a specific vendor id and product id is plugged in the USB bus. I’ve enabled the hot plug support in the kernel; in fact by default CONFIG_HOTPLUG was enabled. I included a test.rules file in the /etc/udev/rules.d/ directory in which I have included the above mentioned vendor id, product id and in the PROGRAM parameter the name of the application to be run. To start with, this program is just a shell script that prints “Hello World” on the console. After this, when we plug in the above mentioned device I’m sure that the kernel has detected it because I’m seeing the device’s information in /proc/bus/usb/devices. But our shell script is not getting called at all. Can some one let me know what I'm missing here? The test.rules file contains the following line only
ATTR{idVendor}="0451", ATTR{idProduct}="97fb", SYMLINK+="hello-%k", MODE="666", PROGRAM="/home/shankar/usb_disp.sh"
Please help me in getting this sorted out.
Thanks in Advance,
Shankar
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid96545433
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Hi,
Thanks for the suggestion, but it didn't work for
me. I'm working on ARM architecture and yes the kernel detects device removal successfully. I get the following message on disconnecting a USB device
usb 1-1: USB disconnect, address 2
Also already there is a shell script called hotplug in the /sbin directory but its not called for some reason.
I think (I'm not 100% sure though) the kernel code calls the user program whose path is stored in "/proc/sys/kernel/hotplug" whenever a hotplug event happens. In my kernel this happens to be "/sbin/udevsend". If the kernel has to call /sbin/hotplug then I need to change this system variable mentioned above to /sbin/hotplug. I tried doing this but I was unable to change it (I'm root in the platform). I tried without changing this also without any success. By looking at all the documents I read, it sounds to me that if hot plug is enabled in the kernel then by default it'll call the program whose path info is stored in "/proc/sys/kernel/hotplug". I think for some reason thats not happening with my setup.
Warm Regards,
Shankar
Quoted 41 lines · --- ½ðÈÚ Ð»
You can put "hotplug" script under directory
/sbin/. It can be invoked once the kernel detects that your usb device has been pluged in. So, put whatever shell script you want to invoke into this service script. Note, make sure the file name of the service script under/sbin/is "hotplug", not anythis else. The system will automatically call this file once you attach a usb device to your system.
By the way, can your system detect the removal event once you remove the usb device? Did the terminal promt out some information about the disconnection of the usb device? What is your hardware architecture£¿> Date: Sun, 7 Oct 2007 21:10:50 -0700> From: [email protected]> Subject: Unable to run a user program on usb device connection> To:
[email protected]> > Hi,> I'm a newbie to Linux hotplug sub-system. Please> excuse me if the question is very basic. I want> to hook a user space application with the hot plug> sub-system in such a way that the application is> executed on attaching a specific USB device. I've> explained what all I tried below, please let me know> where I'm going wrong.> > My linux kernel version is 2.6.10 and it uses the> ¡°udev¡± mechanism to support hot plug. Our application> should be executed when a device with a specific> vendor id and product id is plugged in the USB bus.> I¡¯ve enabled the hot plug support in the kernel; in> fact by defaultCONFIG_HOTPLUGwas enabled. I included> a test.rules file in the/etc/udev/rules.d/directory> in which I have included the above mentioned vendor> id, product id and in the PROGRAM parameter the name> of the application to be run. To start with, this> program is just a shell script that prints ¡°Hello> World¡± on the console. After this, when we plug in the> above mentioned device I¡¯m sure that the kernel has> detected it because I¡¯m seeing the device¡¯s> information in/proc/bus/usb/devices. But our shell>
Quoted 9 lines
script is not getting called at all. Can some one let> me know what I'm missing here? The test.rules file> contains the following line only> > ATTR{idVendor}="0451", ATTR{idProduct}="97fb",> SYMLINK+="hello-%k", MODE="666",> PROGRAM="/home/shankar/usb_disp.sh"> > Please help me in getting this sorted out.> > Thanks in Advance,> Shankar > > > >
____________________________________________________________________________________>
Quoted 4 lines
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. >
http://answers.yahoo.com/dir/?link=list&sid96545433>
Quoted 2 lines
Quoted 1 line
------------------------------------------------------------------------->
Quoted 10 lines
This SF.net email is sponsored by: Splunk Inc.> Still grepping through log files to find problems? Stop.> Now Search log events and configuration files using AJAX and a browser.> Download your FREE copy of Splunk now >> http://get.splunk.com/>
_______________________________________________> Linux-hotplug-devel mailing list
http://linux-hotplug.sourceforge.net>
[email protected]>
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 1 line
_________________________________________________________________
Quoted 3 lines
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Hi Shankar,
If you are not using montavista kernel distribution, then you should follow the udev theory.
On Montavista kernel, udev does not work.
It supports the hotplug in a different way so you don't need udevd and its rules in /etc/udev.
Any kernel event is reported to user space first by executing the /sbin/hotplug script.
If your USB device is Memory Device(Flash/Disk) For usb device, you should have the following scripts (since mass storage device appears as SCSI devices)/etc/hotplug.d/scsi/scsi.hotplug
For other USB devices you need to have appropriate scripts in /etc/hotplug.d/ folder.
Nazim
Quoted 117 lines · On 10/8/07, [email protected] <[email protected]> wrote:
Hi,
Thanks for the suggestion, but it didn't work for
me. I'm working on ARM architecture and yes the kernel detects device removal successfully. I get the following message on disconnecting a USB deviceusb 1-1: USB disconnect, address 2
Also already there is a shell script called hotplug in the /sbin directory but its not called for some reason.
I think (I'm not 100% sure though) the kernel code calls the user program whose path is stored in "
/proc/sys/kernel/hotplug" whenever a hotplug event happens. In my kernel this happens to be "/sbin/udevsend". If the kernel has to call/sbin/hotplugthen I need to change this system variable mentioned above to/sbin/hotplug. I tried doing this but I was unable to change it (I'm root in the platform). I tried without changing this also without any success. By looking at all the documents I read, it sounds to me that if hot plug is enabled in the kernel then by default it'll call the program whose path info is stored in "/proc/sys/kernel/hotplug". I think for some reason thats not happening with my setup.Warm Regards,
ShankarQuoted 41 lines · --- ½ðÈÚ Ð»
You can put "hotplug" script under directory
/sbin/. It can be invoked once the kernel detects that your usb device has been pluged in. So, put whatever shell script you want to invoke into this service script. Note, make sure the file name of the service script under/sbin/is "hotplug", not anythis else. The system will automatically call this file once you attach a usb device to your system.
By the way, can your system detect the removal event once you remove the usb device? Did the terminal promt out some information about the disconnection of the usb device? What is your hardware architecture£¿> Date: Sun, 7 Oct 2007 21:10:50 -0700> From: [email protected]> Subject: Unable to run a user program on usb device connection> To:
[email protected]> > Hi,> I'm a newbie to Linux hotplug sub-system. Please> excuse me if the question is very basic. I want> to hook a user space application with the hot plug> sub-system in such a way that the application is> executed on attaching a specific USB device. I've> explained what all I tried below, please let me know> where I'm going wrong.> > My linux kernel version is 2.6.10 and it uses the> ¡°udev¡± mechanism to support hot plug. Our application> should be executed when a device with a specific> vendor id and product id is plugged in the USB bus.> I¡¯ve enabled the hot plug support in the kernel; in> fact by defaultCONFIG_HOTPLUGwas enabled. I included> a test.rules file in the/etc/udev/rules.d/directory> in which I have included the above mentioned vendor> id, product id and in the PROGRAM parameter the name> of the application to be run. To start with, this> program is just a shell script that prints ¡°Hello> World¡± on the console. After this, when we plug in the> above mentioned device I¡¯m sure that the kernel has> detected it because I¡¯m seeing the device¡¯s> information in/proc/bus/usb/devices. But our shell>Quoted 9 lines
script is not getting called at all. Can some one let> me know what I'm missing here? The test.rules file> contains the following line only> > ATTR{idVendor}="0451", ATTR{idProduct}="97fb",> SYMLINK+="hello-%k", MODE="666",> PROGRAM="/home/shankar/usb_disp.sh"> > Please help me in getting this sorted out.> > Thanks in Advance,> Shankar > > > >
____________________________________________________________________________________>
Quoted 4 lines
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. >
http://answers.yahoo.com/dir/?link=list&sid96545433>
Quoted 2 lines
Quoted 1 line
------------------------------------------------------------------------->
Quoted 10 lines
This SF.net email is sponsored by: Splunk Inc.> Still grepping through log files to find problems? Stop.> Now Search log events and configuration files using AJAX and a browser.> Download your FREE copy of Splunk now >> http://get.splunk.com/>
_______________________________________________> Linux-hotplug-devel mailing list
http://linux-hotplug.sourceforge.net>
[email protected]>https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 1 line
_________________________________________________________________
Quoted 3 lines
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
Quoted 10 lines
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Hi Nazim,
Thank you for the suggestion. Yes I'm using
montavista kernel, so tried whatever you suggested but without any success. The following are the steps I tried,
1)Modified the usb.usermap file in /etc/hotplug directory as follows
# For our device
test.sh 0x0003 0x0451 0x97FB 0x0000 0x00000x00 0x00 0x00 0x00 0x00 0x000x00000000
# Test for a USB mouse first
test.sh 0x0003 0x0461 0x4D15 0x0000 0x00000x00 0x00 0x00 0x00 0x00 0x000x00000000
2)Wrote the test.sh to write a string “Hello World” in a file debug_out (I’m doing this because I was informed that in some kernels the echo statements from the scripts executed as part of hotplug are re-direceted to /dev/null. By doing this I can look at this debug_out file and ensure that whether our script is executed or not) and placed the script under /etc/hotplug, /etc/hotplug.d and /etc/hotplug.d/default. The following is the script
echo “Hello World” >> /debug_out
This was also not working. I'm running out of ideas now. Thanks one again.
Warm Regards,
Shankar
Quoted 137 lines · --- Nazim Khan
Hi Shankar,
If you are not using montavista kernel distribution, then you should
follow the udev theory.On Montavista kernel, udev does not work. It supports the hotplug in a different way so you don't need udevd and
its rules in/etc/udev.Any kernel event is reported to user space first by executing the
/sbin/hotplugscript.
If your USB device is Memory Device(Flash/Disk) For usb device, you
should have the following scripts (since mass storage device appears
as SCSI devices)/etc/hotplug.d/scsi/scsi.hotplugFor other USB devices you need to have appropriate scripts in
/etc/hotplug.d/folder.Nazim
Quoted 2 lines · On 10/8/07, [email protected] <[email protected]> wrote:
Hi,
Thanks for the suggestion, but it didn't workfor
Quoted 1 line
me. I'm working on ARM architecture and yes the
kernel
Quoted 6 lines
detects device removal successfully. I get the following message on disconnecting a USB device
usb 1-1: USB disconnect, address 2
Also already there is a shell script called
hotplug in
Quoted 6 lines
the /sbin directory but its not called for some reason.
I think (I'm not 100% sure though) the kernel code calls the user program whose path is stored in "
/proc/sys/kernel/hotplug" whenever a hotplugevent
Quoted 5 lines
happens. In my kernel this happens to be "
/sbin/udevsend". If the kernel has to call/sbin/hotplugthen I need to change this system variable mentioned above to/sbin/hotplug. I tried doing this but I was unable to change it (I'm rootin
Quoted 2 lines
the platform). I tried without changing this also without any success. By looking at all the
documents I
Quoted 1 line
read, it sounds to me that if hot plug is enabled
in
Quoted 3 lines
the kernel then by default it'll call the program whose path info is stored in "
/proc/sys/kernel/hotplug". I think for somereason
Quoted 9 lines
thats not happening with my setup.
Warm Regards,
ShankarQuoted 2 lines · --- ½ðÈÚ Ð»
You can put "hotplug" script under directory
/sbin/Quoted 3 lines
Quoted 3 lines
. It can be invoked once the kernel detects that your usb device has been pluged in. So, put whatever shell script you want to invoke into
this
Quoted 1 line
Quoted 1 line
service script. Note, make sure the file name of
the
Quoted 5 lines
Quoted 5 lines
service script under
/sbin/is "hotplug", not anythis else. The system will automatically call this file once you attach a usb device to your system.
By the way, can your system detect the removalevent
Quoted 2 lines
Quoted 2 lines
once you remove the usb device? Did the terminal promt out some information about the
disconnection
Quoted 3 lines
Quoted 3 lines
of the usb device? What is your hardware architecture£¿> Date: Sun, 7 Oct 2007 21:10:50 -0700> From: [email protected]> Subject:
Unable to
Quoted 2 lines
Quoted 2 lines
run a user program on usb device connection> To:
[email protected]> >Hi,>
Quoted 1 line
Quoted 1 line
I'm a newbie to Linux hotplug sub-system.
Please>
Quoted 1 line
Quoted 1 line
excuse me if the question is very basic. I want>
to
Quoted 2 lines
Quoted 2 lines
hook a user space application with the hot plug> sub-system in such a way that the application
is>
Quoted 1 line
Quoted 1 line
executed on attaching a specific USB device.
I've>
Quoted 5 lines
Quoted 5 lines
explained what all I tried below, please let me know> where I'm going wrong.> > My linux kernel version is 2.6.10 and it uses the> ¡°udev¡± mechanism to support hot plug. Our application> should be executed when a device with a
specific>
Quoted 1 line
Quoted 1 line
vendor id and product id is plugged in the USB
bus.>
Quoted 1 line
Quoted 1 line
I¡¯ve enabled the hot plug support in the
kernel;
Quoted 1 line
Quoted 1 line
in> fact by default
CONFIG_HOTPLUGwas enabled.I
Quoted 3 lines
Quoted 3 lines
included> a test.rules file in the
/etc/udev/rules.d/directory> in which I have included the above mentioned vendor> id, productid
Quoted 2 lines
Quoted 2 lines
and in the PROGRAM parameter the name> of the application to be run. To start with, this>
program
Quoted 1 line
Quoted 1 line
is just a shell script that prints ¡°Hello>
World¡±
Quoted 3 lines
Quoted 3 lines
on the console. After this, when we plug in the> above mentioned device I¡¯m sure that the kernel has> detected it because I¡¯m seeing the
device¡¯s>
Quoted 1 line
Quoted 1 line
information in
/proc/bus/usb/devices. But ourshell>
Quoted 1 line
Quoted 1 line
script is not getting called at all. Can some
one
Quoted 13 lines
Quoted 1 line
Quoted 1 line
let> me know what I'm missing here? The
test.rules
Quoted 2 lines
Quoted 2 lines
file> contains the following line only> > ATTR{idVendor}="0451",
ATTR{idProduct}="97fb",>
Quoted 2 lines
Quoted 2 lines
SYMLINK+="hello-%k", MODE="666",> PROGRAM="/home/shankar/usb_disp.sh"> > Please
help
Quoted 4 lines
Quoted 3 lines
me in getting this sorted out.> > Thanks in Advance,> Shankar > > > >
____________________________________________________________________________________>
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. >
http://answers.yahoo.com/dir/?link=list&sid96545433>
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
------------------------------------------------------------------------->
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
This SF.net email is sponsored by: Splunk Inc.> Still grepping through log files to find
problems?
Quoted 1 line
Quoted 1 line
Stop.> Now Search log events and configuration
files
Quoted 1 line
Quoted 1 line
using AJAX and a browser.> Download your FREE
copy
Quoted 7 lines
Quoted 6 lines
of Splunk now >> http://get.splunk.com/>
_______________________________________________> Linux-hotplug-devel mailing list
http://linux-hotplug.sourceforge.net>
[email protected]>
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
_________________________________________________________________
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Invite your mail contacts to join your friends
list
Quoted 3 lines
Quoted 2 lines
with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
Quoted 6 lines
Quoted 5 lines
____________________________________________________________________________________
Quoted 6 lines
Quoted 1 line
Pinpoint customers who are looking for what you
sell.
Quoted 3 lines
-------------------------------------------------------------------------
Quoted 6 lines
Quoted 2 lines
This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems?
Stop.
Quoted 1 line
Now Search log events and configuration files
using AJAX and a browser.
== message truncated =
____________________________________________________________________________________
Check out the hottest 2008 models today at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · On Tue, Oct 09, 2007 at 10:38:52PM -0700, [email protected] wrote:
Hi Nazim,
Thank you for the suggestion. Yes I'm using
montavista kernel, so tried whatever you suggested but
I really suggest asking montavista, as they are the ones who support their "odd" hotplug-like setup, not anyone in the community.
Ah the joys of doing things different from the rest of the Linux world...
good luck,
greg k-h
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Hi All,
Finally I was able to find the fix. Wanted to post
the solution also to the group so that some one facing the same problem can be helped. The mistake was in my script file. I was told that the first line in a script file should always be
#!/sbin/sh
which was not the case with mine. Once I added this line things started working for me.
Warm Regards,
Shankar
Quoted 12 lines · --- Greg KH
Quoted 3 lines · On Tue, Oct 09, 2007 at 10:38:52PM -0700, [email protected] wrote:
Hi Nazim,
Thank you for the suggestion. Yes I'm using
montavista kernel, so tried whatever you suggestedbut
I really suggest asking montavista, as they are the ones who support
their "odd" hotplug-like setup, not anyone in the community.
Quoted 8 lines
Ah the joys of doing things different from the rest of the Linux
world...good luck,
greg k-h
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel