aboutsummaryrefslogtreecommitdiff
path: root/ROMFS/px4fmu_common/init.d/rcS
diff options
context:
space:
mode:
Diffstat (limited to 'ROMFS/px4fmu_common/init.d/rcS')
-rw-r--r--ROMFS/px4fmu_common/init.d/rcS207
1 files changed, 110 insertions, 97 deletions
diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS
index c8272a59e..19d42dfa5 100644
--- a/ROMFS/px4fmu_common/init.d/rcS
+++ b/ROMFS/px4fmu_common/init.d/rcS
@@ -20,7 +20,7 @@ echo "[init] Looking for microSD..."
if mount -t vfat /dev/mmcsd0 /fs/microsd
then
set LOG_FILE /fs/microsd/bootlog.txt
- echo "[init] microSD card mounted at /fs/microsd"
+ echo "[init] microSD mounted: /fs/microsd"
# Start playing the startup tune
tone_alarm start
else
@@ -65,12 +65,12 @@ then
# Start CDC/ACM serial driver
#
sercon
-
+
#
# Start the ORB (first app to start)
#
uorb start
-
+
#
# Load parameters
#
@@ -79,29 +79,33 @@ then
then
set PARAM_FILE /fs/mtd_params
fi
-
+
param select $PARAM_FILE
if param load
then
- echo "[init] Parameters loaded: $PARAM_FILE"
+ echo "[init] Params loaded: $PARAM_FILE"
else
- echo "[init] ERROR: Parameters loading failed: $PARAM_FILE"
+ echo "[init] ERROR: Params loading failed: $PARAM_FILE"
fi
-
+
#
# Start system state indicator
#
if rgbled start
then
- echo "[init] Using external RGB Led"
+ echo "[init] RGB Led"
else
if blinkm start
then
- echo "[init] Using blinkm"
+ echo "[init] BlinkM"
blinkm systemstate
fi
fi
-
+
+ if pca8574 start
+ then
+ fi
+
#
# Set default values
#
@@ -120,17 +124,23 @@ then
set EXIT_ON_END no
set MAV_TYPE none
set LOAD_DEFAULT_APPS yes
-
+ set GPS yes
+ set GPS_FAKE no
+
#
# Set DO_AUTOCONFIG flag to use it in AUTOSTART scripts
#
if param compare SYS_AUTOCONFIG 1
then
+ # We can't be sure the defaults haven't changed, so
+ # if someone requests a re-configuration, we do it
+ # cleanly from scratch (except autostart / autoconfig)
+ param reset_nostart
set DO_AUTOCONFIG yes
else
set DO_AUTOCONFIG no
fi
-
+
#
# Set USE_IO flag
#
@@ -140,13 +150,13 @@ then
else
set USE_IO no
fi
-
+
#
# Set parameters and env variables for selected AUTOSTART
#
if param compare SYS_AUTOSTART 0
then
- echo "[init] Don't try to find autostart script"
+ echo "[init] No autostart"
else
sh /etc/init.d/rc.autostart
fi
@@ -156,10 +166,10 @@ then
#
if [ -f $CONFIG_FILE ]
then
- echo "[init] Reading config: $CONFIG_FILE"
+ echo "[init] Config: $CONFIG_FILE"
sh $CONFIG_FILE
else
- echo "[init] Config file not found: $CONFIG_FILE"
+ echo "[init] Config not found: $CONFIG_FILE"
fi
#
@@ -170,9 +180,9 @@ then
param set SYS_AUTOCONFIG 0
param save
fi
-
+
set IO_PRESENT no
-
+
if [ $USE_IO == yes ]
then
#
@@ -184,19 +194,19 @@ then
else
set IO_FILE /etc/extras/px4io-v1_default.bin
fi
-
+
if px4io checkcrc $IO_FILE
then
echo "[init] PX4IO CRC OK"
echo "PX4IO CRC OK" >> $LOG_FILE
-
+
set IO_PRESENT yes
else
echo "[init] Trying to update"
echo "PX4IO Trying to update" >> $LOG_FILE
-
+
tone_alarm MLL32CP8MB
-
+
if px4io forceupdate 14662 $IO_FILE
then
usleep 500000
@@ -205,7 +215,7 @@ then
echo "[init] PX4IO CRC OK, update successful"
echo "PX4IO CRC OK after updating" >> $LOG_FILE
tone_alarm MLL8CDE
-
+
set IO_PRESENT yes
else
echo "[init] ERROR: PX4IO update failed"
@@ -218,19 +228,13 @@ then
tone_alarm $TUNE_OUT_ERROR
fi
fi
-
+
if [ $IO_PRESENT == no ]
then
echo "[init] ERROR: PX4IO not found"
tone_alarm $TUNE_OUT_ERROR
fi
fi
-
- if param compare SYS_AUTOSTART 901
- then
- sh /etc/init.d/901_bottle_drop_test.hil
- set MODE custom
- fi
#
# Set default output if not set
@@ -250,9 +254,9 @@ then
# Need IO for output but it not present, disable output
set OUTPUT_MODE none
echo "[init] ERROR: PX4IO not found, disabling output"
-
+
# Avoid using ttyS0 for MAVLink on FMUv1
- if hw_ver compare PX4FMU_V1
+ if ver hwcmp PX4FMU_V1
then
set FMU_MODE serial
fi
@@ -266,29 +270,44 @@ then
if [ $HIL == yes ]
then
set OUTPUT_MODE hil
- if hw_ver compare PX4FMU_V1
+ if ver hwcmp PX4FMU_V1
then
set FMU_MODE serial
fi
- else
- # Try to get an USB console if not in HIL mode
- nshterm /dev/ttyACM0 &
fi
-
+
+ # Try to get an USB console
+ nshterm /dev/ttyACM0 &
+
+ #
+ # Start the datamanager
+ #
+ dataman start
+
#
# Start the Commander (needs to be this early for in-air-restarts)
#
commander start
-
+
#
# Start primary output
#
set TTYS1_BUSY no
-
+
# If OUTPUT_MODE == none then something is wrong with setup and we shouldn't try to enable output
if [ $OUTPUT_MODE != none ]
then
- if [ $OUTPUT_MODE == io ]
+ if [ $OUTPUT_MODE == uavcan_esc ]
+ then
+ if uavcan start 1
+ then
+ echo "CAN UP"
+ else
+ echo "CAN ERR"
+ fi
+ fi
+
+ if [ $OUTPUT_MODE == io -o $OUTPUT_MODE == uavcan_esc ]
then
echo "[init] Use PX4IO PWM as primary output"
if px4io start
@@ -300,6 +319,7 @@ then
tone_alarm $TUNE_OUT_ERROR
fi
fi
+
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == ardrone ]
then
echo "[init] Use FMU as primary output"
@@ -310,8 +330,8 @@ then
echo "[init] ERROR: FMU mode_$FMU_MODE start failed"
tone_alarm $TUNE_OUT_ERROR
fi
-
- if hw_ver compare PX4FMU_V1
+
+ if ver hwcmp PX4FMU_V1
then
if [ $FMU_MODE == pwm -o $FMU_MODE == gpio ]
then
@@ -323,6 +343,7 @@ then
fi
fi
fi
+
if [ $OUTPUT_MODE == mkblctrl ]
then
echo "[init] Use MKBLCTRL as primary output"
@@ -335,7 +356,7 @@ then
then
set MKBLCTRL_ARG "-mkmode +"
fi
-
+
if mkblctrl $MKBLCTRL_ARG
then
echo "[init] MKBLCTRL started"
@@ -343,8 +364,9 @@ then
echo "[init] ERROR: MKBLCTRL start failed"
tone_alarm $TUNE_OUT_ERROR
fi
-
- fi
+
+ fi
+
if [ $OUTPUT_MODE == hil ]
then
echo "[init] Use HIL as primary output"
@@ -356,7 +378,7 @@ then
tone_alarm $TUNE_OUT_ERROR
fi
fi
-
+
#
# Start IO or FMU for RC PPM input if needed
#
@@ -383,8 +405,8 @@ then
echo "[init] ERROR: FMU mode_$FMU_MODE start failed"
tone_alarm $TUNE_OUT_ERROR
fi
-
- if hw_ver compare PX4FMU_V1
+
+ if ver hwcmp PX4FMU_V1
then
if [ $FMU_MODE == pwm -o $FMU_MODE == gpio ]
then
@@ -398,64 +420,50 @@ then
fi
fi
fi
-
+
#
# MAVLink
#
-
if [ $MAVLINK_FLAGS == default ]
then
- if [ $HIL == yes ]
+ # Normal mode, use baudrate 57600 (default) and data rate 1000 bytes/s
+ if [ $TTYS1_BUSY == yes ]
then
- sleep 1
- set MAVLINK_FLAGS "-r 10000 -d /dev/ttyACM0"
- usleep 5000
+ # Start MAVLink on ttyS0, because FMU ttyS1 pins configured as something else
+ set MAVLINK_FLAGS "-r 1000 -d /dev/ttyS0"
+
+ # Exit from nsh to free port for mavlink
+ set EXIT_ON_END yes
else
- # Normal mode, use baudrate 57600 (default) and data rate 1000 bytes/s
- if [ $TTYS1_BUSY == yes ]
- then
- # Start MAVLink on ttyS0, because FMU ttyS1 pins configured as something else
- set MAVLINK_FLAGS "-r 1000 -d /dev/ttyS0"
- usleep 5000
-
- # Exit from nsh to free port for mavlink
- set EXIT_ON_END yes
- else
- # Start MAVLink on default port: ttyS1
- set MAVLINK_FLAGS "-r 1000"
- usleep 5000
- fi
+ # Start MAVLink on default port: ttyS1
+ set MAVLINK_FLAGS "-r 1000"
fi
fi
mavlink start $MAVLINK_FLAGS
- usleep 5000
-
- #
- # Start the datamanager
- #
- dataman start
-
- #
- # Start the navigator
- #
- navigator start
-
+
#
# Sensors, Logging, GPS
#
- echo "[init] Start sensors"
sh /etc/init.d/rc.sensors
- if [ $HIL == no ]
+ #
+ # Start logging in all modes, including HIL
+ #
+ sh /etc/init.d/rc.logging
+
+ if [ $GPS == yes ]
then
- echo "[init] Start logging"
- sh /etc/init.d/rc.logging
-
echo "[init] Start GPS"
- gps start
+ if [ $GPS_FAKE == yes ]
+ then
+ echo "[init] Faking GPS"
+ gps start -f
+ else
+ gps start
+ fi
fi
-
+
#
# Start up ARDrone Motor interface
#
@@ -470,24 +478,24 @@ then
if [ $VEHICLE_TYPE == fw ]
then
echo "[init] Vehicle type: FIXED WING"
-
+
if [ $MIXER == none ]
then
# Set default mixer for fixed wing if not defined
set MIXER FMU_AERT
fi
-
+
if [ $MAV_TYPE == none ]
then
# Use MAV_TYPE = 1 (fixed wing) if not defined
set MAV_TYPE 1
fi
-
+
param set MAV_TYPE $MAV_TYPE
-
+
# Load mixer and configure outputs
sh /etc/init.d/rc.interface
-
+
# Start standard fixedwing apps
if [ $LOAD_DEFAULT_APPS == yes ]
then
@@ -522,7 +530,7 @@ then
then
set MAV_TYPE 13
fi
- if [ $MIXER == hexa_cox ]
+ if [ $MIXER == FMU_hexa_cox ]
then
set MAV_TYPE 13
fi
@@ -535,7 +543,7 @@ then
set MAV_TYPE 14
fi
fi
-
+
# Still no MAV_TYPE found
if [ $MAV_TYPE == none ]
then
@@ -543,10 +551,10 @@ then
else
param set MAV_TYPE $MAV_TYPE
fi
-
+
# Load mixer and configure outputs
sh /etc/init.d/rc.interface
-
+
# Start standard multicopter apps
if [ $LOAD_DEFAULT_APPS == yes ]
then
@@ -555,6 +563,11 @@ then
fi
#
+ # Start the navigator
+ #
+ navigator start
+
+ #
# Generic setup (autostart ID not found)
#
if [ $VEHICLE_TYPE == none ]
@@ -569,7 +582,7 @@ then
echo "[init] Starting addons script: $EXTRAS_FILE"
sh $EXTRAS_FILE
else
- echo "[init] Addons script not found: $EXTRAS_FILE"
+ echo "[init] No addons script: $EXTRAS_FILE"
fi
if [ $EXIT_ON_END == yes ]