Skip to content
Snippets Groups Projects
Commit 6ab9dc0a authored by Lorenz Meier's avatar Lorenz Meier
Browse files

Testing cleanup from Daniel Agar

parent 99aa5f49
No related branches found
No related tags found
No related merge requests found
Showing
with 511 additions and 271 deletions
......@@ -246,7 +246,7 @@ endforeach()
px4_add_git_submodule(TARGET git_genmsg PATH "Tools/genmsg")
px4_add_git_submodule(TARGET git_gencpp PATH "Tools/gencpp")
px4_add_git_submodule(TARGET git_mavlink PATH "mavlink/include/mavlink/v1.0")
px4_add_git_submodule(TARGET git_gtest PATH "unittets/gtest")
px4_add_git_submodule(TARGET git_gtest PATH "unittests/gtest")
px4_add_git_submodule(TARGET git_uavcan PATH "src/modules/uavcan/libuavcan")
px4_add_git_submodule(TARGET git_nuttx PATH "NuttX")
px4_add_git_submodule(TARGET git_driverframework PATH "src/lib/DriverFramework")
......
......@@ -174,9 +174,6 @@ posix_sitl_default:
posix_sitl_lpe:
$(call cmake-build,$@)
posix_sitl_test:
$(call cmake-build,$@)
posix_sitl_replay:
$(call cmake-build,$@)
......@@ -271,14 +268,14 @@ checks_uavcan: \
check_px4fmu-v4_default_and_uavcan
checks_sitls: \
check_posix_sitl_default \
check_posix_sitl_test \
check_posix_sitl_default
checks_last: \
check_unittest \
check_tests \
check_format \
check: checks_defaults checks_tests checks_alts checks_uavcan checks_bootloaders checks_sitls checks_last
check: checks_defaults checks_tests checks_alts checks_uavcan checks_bootloaders checks_last
quick_check: check_px4fmu-v2_default check_px4fmu-v4_default check_tests check_format
check_format:
$(call colorecho,"Checking formatting with astyle")
......@@ -300,15 +297,18 @@ ifeq ($(VECTORCONTROL),1)
@rm -rf ROMFS/px4fmu_common/uavcan
endif
unittest: posix_sitl_test
unittest: posix_sitl_default
$(call cmake-build-other,unittest, ../unittests)
@(cd build_unittest && ctest -j2 --output-on-failure)
tests: posix_sitl_test unittest
test_onboard_sitl:
@HEADLESS=1 make posix_sitl_test gazebo_iris
run_tests_posix: posix_sitl_default
@mkdir -p build_posix_sitl_default/src/firmware/posix/rootfs/fs/microsd
@mkdir -p build_posix_sitl_default/src/firmware/posix/rootfs/eeprom
@touch build_posix_sitl_default/src/firmware/posix/rootfs/eeprom/parameters
@(cd build_posix_sitl_default/src/firmware/posix && ./mainapp -d ../../../../posix-configs/SITL/init/rcS_tests | tee test_output)
@(cd build_posix_sitl_default/src/firmware/posix && grep --color=always "All tests passed" test_output)
tests: check_unittest run_tests_posix
# QGroundControl flashable firmware
qgc_firmware: \
......
......@@ -111,87 +111,22 @@ fi
sh /etc/init.d/rc.sensors
# Check for flow sensor
if px4flow start
then
fi
if ll40ls start
then
fi
ver all
#
# Run unit tests at board boot, reporting failure as needed.
# Add new unit tests using the same pattern as below.
#
echo
echo "--------------------------------------------------------------------------------"
echo "[mavlink_tests] STARTING TEST"
if mavlink_tests
then
echo "[mavlink_tests] PASS"
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} mavlink_tests"
echo "[mavlink_tests] FAILED"
fi
echo "--------------------------------------------------------------------------------"
echo
echo "--------------------------------------------------------------------------------"
echo "[commander_tests] STARTING TEST"
if commander_tests
then
echo "[commander_tests] PASS"
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} commander_tests"
echo "[commander_tests] FAILED"
fi
echo "--------------------------------------------------------------------------------"
echo
echo "--------------------------------------------------------------------------------"
echo "[controllib_test] STARTING TEST"
if controllib_test
then
echo "[controllib_test] PASS"
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} controllib_tests"
echo "[controllib_test] FAILED"
fi
echo "--------------------------------------------------------------------------------"
echo
echo "--------------------------------------------------------------------------------"
echo "[uorb_tests] STARTING TEST"
if uorb_tests
then
echo "[uorb_tests] PASS"
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} uorb_tests"
echo "[uorb_tests] FAILED"
fi
echo "--------------------------------------------------------------------------------"
if tests all
then
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} system_tests"
fi
if [ $unit_test_failure == 0 ]
then
echo
echo "All Unit Tests PASSED"
rgbled rgb 20 255 20
else
echo
echo "Some Unit Tests FAILED:${unit_test_failure_list}"
echo "Some Unit Tests FAILED"
rgbled rgb 255 20 20
fi
ver all
free
......@@ -53,22 +53,34 @@ set(config_module_list
# System commands
#
systemcmds/bl_update
systemcmds/config
systemcmds/dumpfile
#systemcmds/esc_calib
systemcmds/mixer
#systemcmds/motor_ramp
systemcmds/mtd
systemcmds/nshterm
systemcmds/param
systemcmds/perf
systemcmds/pwm
#systemcmds/esc_calib
systemcmds/reboot
#systemcmds/topic_listener
#systemcmds/sd_bench
systemcmds/top
systemcmds/config
systemcmds/nshterm
systemcmds/mtd
systemcmds/dumpfile
#systemcmds/topic_listener
systemcmds/ver
#systemcmds/sd_bench
#
# Testing
#
#drivers/sf0x/sf0x_tests
#drivers/test_ppm
#lib/rc/rc_tests
#modules/commander/commander_tests
#modules/controllib_test
#modules/mavlink/mavlink_tests
#modules/unit_test
#modules/uORB/uORB_tests
#systemcmds/tests
#systemcmds/motor_ramp
#
# General system control
......
......@@ -53,32 +53,34 @@ set(config_module_list
# System commands
#
systemcmds/bl_update
systemcmds/config
systemcmds/dumpfile
#systemcmds/esc_calib
systemcmds/mixer
systemcmds/motor_ramp
systemcmds/mtd
systemcmds/nshterm
systemcmds/param
systemcmds/perf
systemcmds/pwm
systemcmds/esc_calib
systemcmds/reboot
#systemcmds/topic_listener
#systemcmds/sd_bench
systemcmds/top
systemcmds/config
systemcmds/nshterm
systemcmds/mtd
systemcmds/dumpfile
#systemcmds/topic_listener
systemcmds/ver
#systemcmds/sd_bench
systemcmds/tests
systemcmds/motor_ramp
#
# Testing
#
drivers/sf0x/sf0x_tests
drivers/test_ppm
#lib/rc/rc_tests
modules/commander/commander_tests
modules/controllib_test
modules/mavlink/mavlink_tests
modules/unit_test
modules/uORB/uORB_tests
systemcmds/tests
#
# General system control
......@@ -95,9 +97,10 @@ set(config_module_list
# Estimation modules (EKF/ SO3 / other filters)
#
modules/attitude_estimator_q
modules/ekf_att_pos_estimator
#modules/ekf_att_pos_estimator
modules/position_estimator_inav
modules/local_position_estimator
modules/ekf2
#
# Vehicle Control
......
......@@ -69,9 +69,20 @@ set(config_module_list
systemcmds/dumpfile
systemcmds/ver
systemcmds/sd_bench
systemcmds/tests
systemcmds/motor_ramp
#
# Testing
#
drivers/sf0x/sf0x_tests
drivers/test_ppm
modules/commander/commander_tests
modules/controllib_test
modules/mavlink/mavlink_tests
modules/unit_test
modules/uORB/uORB_tests
systemcmds/tests
#
# General system control
#
......
......@@ -70,6 +70,7 @@ set(config_module_list
lib/launchdetection
lib/mathlib
lib/mathlib/math/filter
lib/rc
lib/runway_takeoff
lib/tailsitter_recovery
lib/terrain_estimation
......@@ -79,9 +80,11 @@ set(config_module_list
#
# Testing
#
drivers/sf0x/sf0x_tests
lib/rc/rc_tests
modules/commander/commander_tests
modules/controllib_test
#modules/mavlink/mavlink_tests
#modules/mavlink/mavlink_tests #TODO: fix mavlink_tests
modules/unit_test
modules/uORB/uORB_tests
systemcmds/tests
......
include(posix/px4_impl_posix)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake)
set(config_module_list
drivers/boards/sitl
drivers/device
drivers/gps
drivers/pwm_out_sim
platforms/common
platforms/posix/drivers/accelsim
platforms/posix/drivers/adcsim
platforms/posix/drivers/airspeedsim
platforms/posix/drivers/barosim
platforms/posix/drivers/gpssim
platforms/posix/drivers/gyrosim
platforms/posix/drivers/ledsim
platforms/posix/drivers/rgbledsim
platforms/posix/drivers/tonealrmsim
platforms/posix/px4_layer
platforms/posix/work_queue
systemcmds/esc_calib
systemcmds/mixer
systemcmds/param
systemcmds/perf
systemcmds/reboot
systemcmds/sd_bench
systemcmds/topic_listener
systemcmds/ver
modules/attitude_estimator_ekf
modules/attitude_estimator_q
modules/commander
modules/dataman
modules/ekf2
modules/ekf_att_pos_estimator
modules/fw_att_control
modules/fw_pos_control_l1
modules/land_detector
modules/logger
modules/mavlink
modules/mc_att_control
modules/mc_att_control_multiplatform
modules/mc_pos_control
modules/mc_pos_control_multiplatform
modules/navigator
modules/param
modules/position_estimator_inav
modules/local_position_estimator
modules/sdlog2
modules/sensors
modules/simulator
modules/systemlib
modules/systemlib/mixer
modules/uORB
modules/vtol_att_control
lib/controllib
lib/conversion
lib/DriverFramework/framework
lib/ecl
lib/external_lgpl
lib/geo
lib/geo_lookup
lib/launchdetection
lib/mathlib
lib/mathlib/math/filter
lib/runway_takeoff
lib/tailsitter_recovery
lib/terrain_estimation
examples/px4_simple_app
#
# Testing
#
modules/commander/commander_tests
modules/controllib_test
#modules/mavlink/mavlink_tests
modules/unit_test
modules/uORB/uORB_tests
systemcmds/tests
)
set(config_extra_builtin_cmds
serdis
sercon
)
set(config_sitl_rcS
posix-configs/SITL/init/rcS_test
CACHE FILEPATH "init script for sitl"
)
set(config_sitl_viewer
jmavsim
CACHE STRING "viewer for sitl"
)
set_property(CACHE config_sitl_viewer
PROPERTY STRINGS "jmavsim;none")
set(config_sitl_debugger
disable
CACHE STRING "debugger for sitl"
)
set_property(CACHE config_sitl_debugger
PROPERTY STRINGS "disable;gdb;lldb")
uorb start
param load
dataman start
simulator start -s
rgbledsim start
tone_alarm start
gyrosim start
accelsim start
barosim start
adcsim start
gpssim start
pwm_out_sim mode_pwm
sleep 1
sensors start
commander_tests
controllib_test
uorb_tests
tests all
ver all
shutdown
uorb start
param load
dataman start
simulator start -s
rgbledsim start
tone_alarm start
gyrosim start
accelsim start
barosim start
adcsim start
gpssim start
pwm_out_sim mode_pwm
sleep 1
sensors start
commander_tests
controllib_test
uorb_tests
tests all
ver all
shutdown
uorb start
param load
param set SYS_RESTART_TYPE 0
dataman start
ver all
sleep 1
tests all
shutdown
############################################################################
#
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
px4_add_module(
MODULE drivers__sf0x__sf0x_tests
MAIN sf0x_tests
COMPILE_FLAGS
SRCS
SF0XTest.cpp
../sf0x_parser.cpp
DEPENDS
platforms__common
)
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <unit_test/unit_test.h>
#include <drivers/drv_hrt.h>
#include <drivers/sf0x/sf0x_parser.h>
#include <systemlib/err.h>
#include "gtest/gtest.h"
#include <stdio.h>
#include <unistd.h>
extern "C" __EXPORT int sf0x_tests_main(int argc, char *argv[]);
class SF0XTest : public UnitTest
{
public:
virtual bool run_tests(void);
private:
bool sf0xTest();
};
bool SF0XTest::run_tests(void)
{
ut_run_test(sf0xTest);
return (_tests_failed == 0);
}
TEST(SF0XTest, SF0X)
bool SF0XTest::sf0xTest(void)
{
const char _LINE_MAX = 20;
char _linebuf[_LINE_MAX];
_linebuf[0] = '\0';
//char _linebuf[_LINE_MAX];
//_linebuf[0] = '\0';
const char *lines[] = {"0.01\r\n",
"0.02\r\n",
......@@ -39,7 +55,6 @@ TEST(SF0XTest, SF0X)
unsigned _parsebuf_index = 0;
for (unsigned l = 0; l < sizeof(lines) / sizeof(lines[0]); l++) {
//printf("\n%s", _linebuf);
int parse_ret;
......@@ -48,6 +63,19 @@ TEST(SF0XTest, SF0X)
parse_ret = sf0x_parser(lines[l][i], _parserbuf, &_parsebuf_index, &state, &dist_m);
if (parse_ret == 0) {
if (l == 0) {
ut_test(dist_m - 0.010000f < 0.001f);
} else if (l == 1) {
ut_test(dist_m - 0.020000f < 0.001f);
} else if (l == 2) {
ut_test(dist_m - 0.030000f < 0.001f);
} else if (l == 3) {
ut_test(dist_m - 0.040000f < 0.001f);
}
//printf("\nparsed: %f %s\n", dist_m, (parse_ret == 0) ? "OK" : "");
}
}
......@@ -56,5 +84,8 @@ TEST(SF0XTest, SF0X)
}
warnx("test finished");
return true;
}
ut_declare_test_c(sf0x_tests_main, SF0XTest)
......@@ -34,6 +34,7 @@ px4_add_module(
MODULE lib__rc
COMPILE_FLAGS
-Os
-Wno-unused-result
SRCS
st24.c
sumd.c
......
############################################################################
#
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
px4_add_module(
MODULE lib__rc__rc_tests
MAIN rc_tests
COMPILE_FLAGS
-Wno-unused-result
SRCS
RCTest.cpp
DEPENDS
platforms__common
)
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
#include <unit_test/unit_test.h>
#include <systemlib/err.h>
#include <stdio.h>
#include <unistd.h>
#include <drivers/drv_hrt.h>
#define DSM_DEBUG
#include <lib/rc/sbus.h>
#include <lib/rc/dsm.h>
#include <lib/rc/st24.h>
#include <lib/rc/sumd.h>
#if !defined(CONFIG_ARCH_BOARD_SITL)
#define TEST_DATA_PATH "/fs/microsd"
#else
#define TEST_DATA_PATH "../../../../src/lib/rc/rc_tests/test_data/"
#endif
extern "C" __EXPORT int rc_tests_main(int argc, char *argv[]);
class RCTest : public UnitTest
{
public:
virtual bool run_tests(void);
private:
bool dsmTest();
bool sbus2Test();
bool st24Test();
bool sumdTest();
};
bool RCTest::run_tests(void)
{
ut_run_test(dsmTest);
ut_run_test(sbus2Test);
ut_run_test(st24Test);
ut_run_test(sumdTest);
return (_tests_failed == 0);
}
bool RCTest::dsmTest(void)
{
const char *filepath = TEST_DATA_PATH "dsm_x_data.txt";
FILE *fp;
fp = fopen(filepath, "rt");
ut_test(fp != nullptr);
//warnx("loading data from: %s", filepath);
float f;
unsigned x;
int ret;
// Trash the first 20 lines
for (unsigned i = 0; i < 20; i++) {
char buf[200];
(void)fgets(buf, sizeof(buf), fp);
}
// Init the parser
uint8_t frame[20];
uint16_t rc_values[18];
uint16_t num_values;
bool dsm_11_bit;
unsigned dsm_frame_drops = 0;
uint16_t max_channels = sizeof(rc_values) / sizeof(rc_values[0]);
int rate_limiter = 0;
unsigned last_drop = 0;
while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) {
ut_test(ret > 0);
frame[0] = x;
unsigned len = 1;
// Pipe the data into the parser
bool result = dsm_parse(f * 1e6f, &frame[0], len, rc_values, &num_values,
&dsm_11_bit, &dsm_frame_drops, max_channels);
if (result) {
//warnx("decoded packet with %d channels and %s encoding:", num_values, (dsm_11_bit) ? "11 bit" : "10 bit");
for (unsigned i = 0; i < num_values; i++) {
//printf("chan #%u:\t%d\n", i, (int)rc_values[i]);
}
}
if (last_drop != (dsm_frame_drops)) {
//warnx("frame dropped, now #%d", (dsm_frame_drops));
last_drop = dsm_frame_drops;
}
rate_limiter++;
}
ut_test(ret == EOF);
return true;
}
bool RCTest::sbus2Test(void)
{
const char *filepath = TEST_DATA_PATH "sbus2_r7008SB.txt";
FILE *fp;
fp = fopen(filepath, "rt");
ut_test(fp != nullptr);
//warnx("loading data from: %s", filepath);
// if (argc < 2)
// errx(1, "Need a filename for the input file");
//int byte_offset = 7;
// if (argc > 2) {
// char* end;
// byte_offset = strtol(argv[2],&end,10);
// }
//warnx("RUNNING TEST WITH BYTE OFFSET OF: %d", byte_offset);
float f;
unsigned x;
int ret;
// Trash the first 20 lines
for (unsigned i = 0; i < 20; i++) {
char buf[200];
(void)fgets(buf, sizeof(buf), fp);
}
// Init the parser
uint8_t frame[SBUS_BUFFER_SIZE];
uint16_t rc_values[18];
uint16_t num_values;
unsigned sbus_frame_drops = 0;
unsigned sbus_frame_resets = 0;
bool sbus_failsafe;
bool sbus_frame_drop;
uint16_t max_channels = sizeof(rc_values) / sizeof(rc_values[0]);
int rate_limiter = 0;
unsigned last_drop = 0;
while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) {
ut_test(ret > 0);
frame[0] = x;
unsigned len = 1;
// Pipe the data into the parser
hrt_abstime now = hrt_absolute_time();
// if (rate_limiter % byte_offset == 0) {
bool result = sbus_parse(now, &frame[0], len, rc_values, &num_values,
&sbus_failsafe, &sbus_frame_drop, &sbus_frame_drops, max_channels);
if (result) {
//warnx("decoded packet");
}
// }
if (last_drop != (sbus_frame_drops + sbus_frame_resets)) {
warnx("frame dropped, now #%d", (sbus_frame_drops + sbus_frame_resets));
last_drop = sbus_frame_drops + sbus_frame_resets;
}
rate_limiter++;
}
ut_test(ret == EOF);
return true;
}
bool RCTest::st24Test(void)
{
const char *filepath = TEST_DATA_PATH "st24_data.txt";
//warnx("loading data from: %s", filepath);
FILE *fp;
fp = fopen(filepath, "rt");
ut_test(fp != nullptr);
float f;
unsigned x;
int ret;
// Trash the first 20 lines
for (unsigned i = 0; i < 20; i++) {
char buf[200];
(void)fgets(buf, sizeof(buf), fp);
}
float last_time = 0;
while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) {
ut_test(ret > 0);
if (((f - last_time) * 1000 * 1000) > 3000) {
// warnx("FRAME RESET\n\n");
}
uint8_t b = static_cast<uint8_t>(x);
last_time = f;
// Pipe the data into the parser
//hrt_abstime now = hrt_absolute_time();
uint8_t rssi;
uint8_t rx_count;
uint16_t channel_count;
uint16_t channels[20];
if (!st24_decode(b, &rssi, &rx_count, &channel_count, channels, sizeof(channels) / sizeof(channels[0]))) {
//warnx("decoded: %u channels (converted to PPM range)", (unsigned)channel_count);
for (unsigned i = 0; i < channel_count; i++) {
//int16_t val = channels[i];
//warnx("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val));
}
}
}
ut_test(ret == EOF);
return true;
}
bool RCTest::sumdTest(void)
{
const char *filepath = TEST_DATA_PATH "sumd_data.txt";
//warnx("loading data from: %s", filepath);
FILE *fp;
fp = fopen(filepath, "rt");
ut_test(fp != nullptr);
float f;
unsigned x;
int ret;
// Trash the first 20 lines
for (unsigned i = 0; i < 20; i++) {
char buf[200];
(void)fgets(buf, sizeof(buf), fp);
}
float last_time = 0;
while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) {
ut_test(ret > 0);
if (((f - last_time) * 1000 * 1000) > 3000) {
// warnx("FRAME RESET\n\n");
}
uint8_t b = static_cast<uint8_t>(x);
last_time = f;
// Pipe the data into the parser
//hrt_abstime now = hrt_absolute_time();
uint8_t rssi;
uint8_t rx_count;
uint16_t channel_count;
uint16_t channels[32];
if (!sumd_decode(b, &rssi, &rx_count, &channel_count, channels, 32)) {
//warnx("decoded: %u channels (converted to PPM range)", (unsigned)channel_count);
for (unsigned i = 0; i < channel_count; i++) {
//int16_t val = channels[i];
//warnx("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val));
}
}
}
ut_test(ret == EOF);
return true;
}
ut_declare_test_c(rc_tests_main, RCTest)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment