Skip to content

Commit

Permalink
ver add px4io manifest check and update rcS logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKlimaj committed Nov 14, 2023
1 parent 58d2bad commit 4023f61
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
42 changes: 22 additions & 20 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -274,37 +274,39 @@ else
. $FCONFIG
fi

# Check if PX4IO present and update firmware if needed.
if [ -f $IOFW ]
if ver px4io_present
then
if ! px4io checkcrc ${IOFW}
# Check if PX4IO present and update firmware if needed.
if [ -f $IOFW ]
then
# tune Program PX4IO
tune_control play -t 16 # tune 16 = PROG_PX4IO

if px4io update ${IOFW}
if ! px4io checkcrc ${IOFW}
then
usleep 10000
tune_control stop
if px4io checkcrc ${IOFW}
# tune Program PX4IO
tune_control play -t 16 # tune 16 = PROG_PX4IO

if px4io update ${IOFW}
then
tune_control play -t 17 # tune 17 = PROG_PX4IO_OK
usleep 10000
tune_control stop
if px4io checkcrc ${IOFW}
then
tune_control play -t 17 # tune 17 = PROG_PX4IO_OK
else
tune_control play -t 18 # tune 18 = PROG_PX4IO_ERR
fi
else
tune_control play -t 18 # tune 18 = PROG_PX4IO_ERR
tune_control stop
fi
else
tune_control stop
fi
fi

if ! px4io start
then
echo "PX4IO start failed"
set STARTUP_TUNE 2 # tune 2 = ERROR_TUNE
if ! px4io start
then
echo "PX4IO start failed"
set STARTUP_TUNE 2 # tune 2 = ERROR_TUNE
fi
fi
fi


#
# RC update (map raw RC input to calibrate manual control)
# start before commander
Expand Down
16 changes: 15 additions & 1 deletion src/systemcmds/ver/ver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static const char sz_ver_buri_str[] = "uri";
static const char sz_ver_gcc_str[] = "gcc";
static const char sz_ver_all_str[] = "all";
static const char mcu_ver_str[] = "mcu";
static const char px4_guid_str[] = "px4guid";
static const char px4_guid_str[] = "px4guid";
static const char px4io_present_str[] = "px4io_present";

static void usage(const char *reason)
{
Expand All @@ -76,6 +77,7 @@ static void usage(const char *reason)
PRINT_MODULE_USAGE_COMMAND_DESCR("bdate", "Build date and time");
PRINT_MODULE_USAGE_COMMAND_DESCR("px4guid", "PX4 GUID");
PRINT_MODULE_USAGE_COMMAND_DESCR("uri", "Build URI");
PRINT_MODULE_USAGE_COMMAND_DESCR("px4io_present", "PX4IO MCU present");

PRINT_MODULE_USAGE_COMMAND_DESCR("all", "Print all versions");
PRINT_MODULE_USAGE_COMMAND_DESCR("hwcmp", "Compare hardware version (returns 0 on match)");
Expand Down Expand Up @@ -269,6 +271,18 @@ extern "C" __EXPORT int ver_main(int argc, char *argv[])
ret = 0;
}

if (show_all || !strncmp(argv[1], px4io_present_str, sizeof(px4io_present_str))) {
bool px4io_supported = PX4_MFT_HW_SUPPORTED(PX4_MFT_PX4IO);

PX4_INFO_RAW("PX4IO MCU supported: %s\n", px4io_supported ? "YES" : "NO");

if (!show_all) {
return px4io_supported ? 0 : 1;;
}

ret = 0;
}

if (ret == 1) {
PX4_ERR("unknown command");
return 1;
Expand Down

0 comments on commit 4023f61

Please sign in to comment.