2009-06-04 02:28:06 Issue with Script file for Hot plug
Narendra Nath (INDIA)
Message: 75140
Hi
I have enabled hotplug for USB .The following is script file i am using
#!/bin/sh
output=/dev/ttyBF0
/bin/mdev > $output
echo $DEVPATH | grep sda
if [ $? -ne 0 ]
then
exit 0
fi
echo "Hotplug Script" > $output
echo $ACTION $output
if [ "$(ACTION)" = "add" ]
then
echo "USB Inserted" > $output
fi
if [ "$(ACTION)" = "remove" ]
then
echo "USB Remove" > $output
fi
Now that i am enable to get Hotplug Script but USB inserted /USB removed is not coming.So is that missing from my side for hot plug to detect ADD/Remove action .Please suggest me.
Best Regards
Narendra
QuoteReplyEditDelete
2009-06-04 03:01:59 Re: Issue with Script file for Hot plug
Mike Frysinger (UNITED STATES)
Message: 75141
your shell script is wrong. $(...) is for subshells, not variables like ${...}.
otherwise, are you sure your hardware is working ? are you getting the mass storage debug messages on the console from the kernel itself ?
QuoteReplyEditDelete
2009-06-04 06:01:23 Re: Issue with Script file for Hot plug
Narendra Nath (INDIA)
Message: 75205
Hi Mike
Thanks for your inputs.I corrected and its working .Now that here i have two issues
1.Right now i am entering script through command line,i want to include that script in my code.how can i include this script into my code either in kernel or my application(C file).
2.Is there any way this script sends a message/signal to my application saying that USB is been attached/reemoved.
Please help me in this regard
Narendra
QuoteReplyEditDelete
2009-06-04 06:10:08 Re: Issue with Script file for Hot plug
Mike Frysinger (UNITED STATES)
Message: 75207
i dont really know what you mean by "include in my code". you'll have to be more specific and/or describe what you're actually trying to do.
as for communicating with another process, any more IPC method will work. there isnt anything special going on here to prevent that. the easiest method is probably to send a custom signal like `killall -USR1 yourapp`.
QuoteReplyEditDelete
2009-06-05 01:50:16 Re: Issue with Script file for Hot plug
Narendra Nath (INDIA)
Message: 75224
Hi Mike
1. As a script file i included the following in script file
#!/bin/sh
echo /salonusb.sh > /proc/sys/kernel/hotplug
cat /proc/sys/kernel/hotplug
cat >salonusb.sh
when i try to run the script file i am getting following error
: cannot createl/hotplug
: No such file or directoryug
2. Also i tried to use kill all with following in my application
int main()
{
struct dirent *entry;
struct sigaction act;
memset (&act, '\0', sizeof(act));
act.sa_sigaction = &hdl;
act.sa_flags = SA_SIGINFO;
sigaction(SIGUSR2, &act, NULL);
}
2 static void hdl (int sig, siginfo_t *siginfo, void *context)
{
printf("Signal received from kernel");
}
I gave killall -USR2 Myapp
and the result i got is killall: Myapp: no process killed
Please suggest me to sort tout these two
Best Regards
Narendra