Monday, 12 August 2013

Auto-Runing a C Program on Raspberry PI

Auto-Runing a C Program on Raspberry PI

how can I make my C code to auto-run on my Raspberry PI? I have seen a
tutorial so as to achieve that but I do not really know what I am still
missing. My initialization script is shown as it follows:
#! /bin/sh
# /etc/init.d/my_settings
#
# Something that could run always can be written here
### BEGIN INIT INFO
# Provides: my_settings
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Script to start C program at boot time
# Description: Enable service provided by my_settings
### END INIT INFO
# Carry out different functions when asked to by the system
case "$1" in
start)
echo "Starting RPi Data Collector Program"
# run application you want to start
sudo /home/pi/Documents/C_Projects/cfor_RPi/charlie &
;;
stop)
echo "Killing RPi Data Collector Program"
# kills the application you want to stop
sudo killall charlie
;;
*)
echo "Usage: /etc/init.d/my_settings {start | stop}"
exit 1
;;
esac
exit 0
The problem is that my program does not run at boot time and I do not
really know why. What would I be missing? Is this "killall" statement
"killing" some useful process during execution time? I am making this code
to run as a background application but I know that after a few seconds,
when the RPi is initializing, it asks for an username and a password in
order to initialize the session. Is it possible that my RPi is not
executing this code because I am not providing the logging information? I
do not have a monitor so that my program has to run once I plug my Rpi in.
Thanks a lot in advance!!

No comments:

Post a Comment