Sunday, September 20, 2009

Autolaunching our Application in Embedded Linux

After all our developments, to make ready our hard ware to show our shoftware, our Application should start as soon as the system is ON.

We have used Qt 4.3 for developing HMI(GUI) application.

What I wanted to do was, our USB device detection shell script detect.sh and our GUI application 'Myplayer' both should launch when the system is switched ON. Hence i have written my own shell script at the end of init script in /etc/rc.d/rc.local file.

I have restarted the system and i was waiting for our application come up. But system is restarted but application hasn't come!

I have seen the currently running proccess using 'ps' command. My shell script was running, but after insertion of USB device, no statements were printing! i thought something is going wrong. I was trying more times.

After some time, just i have executes 'ls /mnt/Device'. This was the mounting point after USB insertion. All files were displayed!!!! I have shocked. Then i came to know, 'echo' will not print any statements because before 'console' application is started, shell script has started and hence any outputs will not come to console. I was heppy at that time.

Now i have started to think about the launching of HMI application. Actually to run our application, some paths has to be exported. I was doing this by exceuting a shell script. But those were not exported in console! Exporting of those paths were not affecting the console. Then i came to know that their scope is within the script only. Then i have written an extra statement at the end in shell script /opt/Myplayer where our application was in /opt/ directory.
I was successful.l.l.l.l.l....!!!!!!

Say example, OurStartupScript.sh would be,

export1
export2
export3
.
./opt/Myplayer

Our init script would be,

if [ -f /opt/Myplayer ]
then
sh /root/OurStrtupScript.sh &

if [ -f /root/detect.sh ]
then
sh /root/detect.sh &
fi
fi

Previously it was like,

if [ -f /opt/exportEcript.sh ]
then
/opt/exportScript.sh
/opt/Myplayer

if [ -f /root/detect.sh ]
then
sh /root/detect.sh &
fi
fi

After all, our application was starting after 1 min 40 seconds after rebooting/powering the system. Detection was robust. I was feeling happy....!!!

In my next posts, i will be sharing about the creation of shared objects in Linux and one small C program(but inconsistent) to detect the inserted device.

If u get any idea or doubt or solution or suggestion, please mail to pramoda.ma@gmail.com

Good luck.....

No comments:

Post a Comment