I think I got it to work by checking if the RA coordinates changes. I did like this:
while true do result=$(indi_getprop "iOptron CEM40.EQUATORIAL_EOD_COORD.RA") sleep 2; previous_result=$result result=$(indi_getprop "iOptron CEM40.EQUATORIAL_EOD_COORD.RA") if [ "$result" = "$previous_result" ]; then echo "Lost connection - reconnect..." indi_setprop 'iOptron CEM40.CONNECTION.DISCONNECT=On' indi_setprop 'iOptron CEM40.CONNECTION.CONNECT=On' else echo "All OK" fi done
stellarmate@stellarmate:~ $ ./test.sh All OK All OK All OK All OK Lost connection - reconnect... All OK All OK All OK ^C