Sorry, I copied an old script, and here is a bit more simplified error
check. Only test error-status "$?" is needed.

 

 

#!/bin/ash

 

readsensor () (

    VAL=`owread -s 3002 $1/$2 2>&1`

    ERR=$?

    [ $ERR != 0 ] && {

        date >>$DEBUGFILE

        echo >>$DEBUGFILE "ERROR: owread $1 failed 1st time: $VAL"

        VAL=`owread -s 3002 $1/$2 2>&1`

        ERR=$?

        [ $ERR != 0 ] && {

            echo >>$DEBUGFILE "ERROR: owread $1 failed 2nd time: $VAL";
false; return;

        }

    }

    # save last value to a file as well (mostly for web-server)

    [ "$2" = "temperature" ] && echo "$VAL" > /tmp/last_val.$1.$2

    echo "$VAL"

    true;

)

 

writesensor () (

    VAL=`owwrite -s 3002 $1/$2 $3 2>&1`

    ERR=$?

    [ $ERR != 0 ] && {

        date >>$DEBUGFILE

        echo >>$DEBUGFILE "ERROR: owwrite $1/$2 $3 failed 1st time."

        VAL=`owwrite -s 3002 $1/$2 $3 2>&1`

        ERR=$?

        [ $ERR != 0 ] && {

            echo >>$DEBUGFILE "ERROR: owwrite $1/$2 $3 failed 2nd time.";
false; return;

        }

    }

    true;

)

 

VAL=`readsensor $SENSOR PIO`

ERR=$?

[ $ERR != 0 ] && exit 1

 

/Christian

 

 

-------------------------------------------------------------------------
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/
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to