Skip to content

Commit

Permalink
Move px4io firmware update logic block to rc.io.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsauder authored and bkueng committed Aug 2, 2018
1 parent 7723860 commit 0928112
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 60 deletions.
57 changes: 56 additions & 1 deletion ROMFS/px4fmu_common/init.d/rc.io
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,60 @@
# PX4IO interface init script.
#

#
# Check if PX4IO present and update firmware if needed.
#
if [ -f /etc/extras/px4io-v2.bin ]
then
set IO_FILE /etc/extras/px4io-v2.bin

if px4io checkcrc ${IO_FILE}
then
set IO_PRESENT yes
else
tune_control play -m MLL32CP8MB

if px4io start
then
# Try to safety px4 io so motor outputs dont go crazy.
if px4io safety_on
then
# success! no-op
else
# px4io did not respond to the safety command.
px4io stop
fi
fi

if px4io forceupdate 14662 ${IO_FILE}
then
usleep 10000
if px4io checkcrc ${IO_FILE}
then
echo "PX4IO CRC OK after updating" >> $LOG_FILE
tune_control play -m MLL8CDE

set IO_PRESENT yes
else
echo "PX4IO update failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
else
echo "PX4IO update failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
fi

if [ $USE_IO == yes -a $IO_PRESENT == no ]
then
echo "PX4IO not found" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi

if px4io start
then
# Allow PX4IO to recover from midair restarts.
Expand All @@ -12,5 +66,6 @@ then
px4io limit 400
else
echo "PX4IO start failed" >> $LOG_FILE
tune_control play -m ${TUNE_ERR}
# Error tune.
tune_control play -t 2
fi
67 changes: 8 additions & 59 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -335,53 +335,6 @@ else
param set SYS_AUTOCONFIG 0
fi

#
# Check if PX4IO present and update firmware if needed.
#
if [ -f /etc/extras/px4io-v2.bin ]
then
set IO_FILE /etc/extras/px4io-v2.bin

if px4io checkcrc ${IO_FILE}
then
set IO_PRESENT yes
else
tune_control play -m MLL32CP8MB

if px4io start
then
# Try to safety px4 io so motor outputs don't go crazy.
if px4io safety_on
then
# success! no-op
else
# px4io did not respond to the safety command.
px4io stop
fi
fi

if px4io forceupdate 14662 ${IO_FILE}
then
usleep 10000
if px4io checkcrc ${IO_FILE}
then
echo "PX4IO CRC OK after updating" >> $LOG_FILE
tune_control play -m MLL8CDE

set IO_PRESENT yes
else
echo "PX4IO update failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
else
echo "PX4IO update failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
fi

#
# Set USE_IO flag.
#
Expand All @@ -390,18 +343,6 @@ else
set USE_IO yes
fi

if [ $USE_IO == yes -a $IO_PRESENT == no ]
then
echo "PX4IO not found" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi

if [ $IO_PRESENT == no -o $USE_IO == no ]
then
rc_input start
fi

#
# Sensors System (start before Commander so Preflight checks are properly run).
# Commander needs to be this early for in-air-restarts.
Expand Down Expand Up @@ -504,6 +445,14 @@ else
#
sh /etc/init.d/rc.logging

#
# Start the rc_input driver.
#
if [ $USE_IO == no -o $IO_PRESENT == no ]
then
rc_input start
fi

#
# Start vmount to control mounts such as gimbals, disabled by default.
#
Expand Down

0 comments on commit 0928112

Please sign in to comment.