mahachi
Posts: 2
Joined: Fri May 31, 2013 10:46 am

rasp shell script and serial ports

Tue Jun 04, 2013 9:28 am

I have a c++ code which reads data from the serial port. if i run it from the terminal using the ./a.out command, it runs pretty well but fails to run when i put it on boot using the script below.

Code: Select all

    #! /bin/sh
    # /etc/init.d/myCode

    ### BEGIN INIT INFO
    # Provides:          myCode
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Simple script to start a program at boot
    # Description:       This simple script calls to /home/pi/myCode
    ### END INIT INFO

    # Carry out specific functions when asked to by the system
    case "$1" in
      start)
        # run application you want to start
        /home/pi/myCode
        ;;
      stop)
        # kill application you want to stop
        killall myCode
        ;;
      *)
        echo "Usage: /etc/init.d/myCode {start|stop}"
        exit 1
        ;;
    esac

    exit 0
How do i start this script when all the serial ports (USB0 and USB1) have been initialised?

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: rasp shell script and serial ports

Tue Jun 04, 2013 9:37 am

You can use udev to trigger things when a device becomes available.

Return to “C/C++”