Browse Source

USB startup: Ensure that we are not talking to the peripheral too soon. Startup does not take longer due to smart rearrangement of launch calls

sbg
Lorenz Meier 10 years ago
parent
commit
18d756dd59
  1. 26
      ROMFS/px4fmu_common/init.d/rcS
  2. 2
      src/systemcmds/nshterm/module.mk
  3. 6
      src/systemcmds/nshterm/nshterm.c

26
ROMFS/px4fmu_common/init.d/rcS

@ -5,6 +5,11 @@ @@ -5,6 +5,11 @@
# NOTE: COMMENT LINES ARE REMOVED BEFORE STORED IN ROMFS.
#
#
# Start CDC/ACM serial driver
#
sercon
#
# Default to auto-start mode.
#
@ -43,29 +48,8 @@ else @@ -43,29 +48,8 @@ else
fi
unset FRC
# if this is an APM build then there will be a rc.APM script
# from an EXTERNAL_SCRIPTS build option
if [ -f /etc/init.d/rc.APM ]
then
if sercon
then
echo "[i] USB interface connected"
fi
echo "[i] Running rc.APM"
# if APM startup is successful then nsh will exit
sh /etc/init.d/rc.APM
fi
if [ $MODE == autostart ]
then
echo "[i] AUTOSTART mode"
#
# Start CDC/ACM serial driver
#
sercon
# Try to get an USB console
nshterm /dev/ttyACM0 &

2
src/systemcmds/nshterm/module.mk

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
MODULE_COMMAND = nshterm
SRCS = nshterm.c
MODULE_STACKSIZE = 1600
MODULE_STACKSIZE = 1500
MAXOPTIMIZATION = -Os

6
src/systemcmds/nshterm/nshterm.c

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
#include <apps/nsh.h>
#include <fcntl.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <uORB/topics/actuator_armed.h>
@ -67,6 +68,11 @@ nshterm_main(int argc, char *argv[]) @@ -67,6 +68,11 @@ nshterm_main(int argc, char *argv[])
int armed_fd = orb_subscribe(ORB_ID(actuator_armed));
struct actuator_armed_s armed;
/* back off 800 ms to avoid running into the USB setup timing */
while (hrt_absolute_time() < 800U * 1000U) {
usleep(50000);
}
/* try to bring up the console - stop doing so if the system gets armed */
while (true) {

Loading…
Cancel
Save