I have unit named ARCO connected over USB to Tomato based ASUS router.
It is equipped in /bin/sh not in bash. The unit is equipped in 4 relay outputs. The command
returns current output states in the form of one hex digit command. If I want to set for example output no 2 I have to use command:
But the number after ./arco command must be in decimal form.
I want to turn off/on particular output in pre-defined time.
The part of program responsible for that looks like this:
Code:
if [ "$czas" -gt "$out4_off" -o "$czas" -lt "$out4_on" ]
then
set=$((0x$out & ~2))
else
set=$((0x$out |2))
fi
if [ "$czas" -gt "$out4_off_1" -o "$czas" -lt "$out4_on_1" ]
then
set=$((0x$out & ~2))
else
set=$((0x$out | 2))
fi
The variables represents as follows:
Code:
czas - actual time in my time-zone
out4_off - time of turning off particular output for the first time
out4_on - time of turning on particular output for the first time
out4_off_1 - time of turning off particular output for the second time
out4_on_1 - time of turning on particular output for the second time
set - represents number which will be written to ARCO unit over USB
All time values are represented in minutes from midnight.
Value of out4_on_1 is grater than out4_on
and similar
Value of out4_off_1 is grater than out4_off
In case of my program, the first "if" will for example set output to ON, but the second "if" statement set it again to OFF.
How can I modify the program above, to be sure that the result of first "if" statement will not be overwritten by second "if" and vice-versa.
Any idea?