mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 06:36:45 +08:00
Expand RC test to 2nd receiver with 12 channels
This commit is contained in:
@@ -27,7 +27,9 @@ public:
|
||||
virtual bool run_tests(void);
|
||||
|
||||
private:
|
||||
bool dsmTest();
|
||||
bool dsmTest(const char *filepath, unsigned expected_chancount, unsigned expected_dropcount, unsigned chan0);
|
||||
bool dsmTest10Ch();
|
||||
bool dsmTest12Ch();
|
||||
bool sbus2Test();
|
||||
bool st24Test();
|
||||
bool sumdTest();
|
||||
@@ -35,7 +37,8 @@ private:
|
||||
|
||||
bool RCTest::run_tests(void)
|
||||
{
|
||||
ut_run_test(dsmTest);
|
||||
ut_run_test(dsmTest10Ch);
|
||||
ut_run_test(dsmTest12Ch);
|
||||
ut_run_test(sbus2Test);
|
||||
ut_run_test(st24Test);
|
||||
ut_run_test(sumdTest);
|
||||
@@ -43,16 +46,24 @@ bool RCTest::run_tests(void)
|
||||
return (_tests_failed == 0);
|
||||
}
|
||||
|
||||
bool RCTest::dsmTest(void)
|
||||
bool RCTest::dsmTest10Ch()
|
||||
{
|
||||
return dsmTest(TEST_DATA_PATH "dsm_x_data.txt", 10, 6, 0);
|
||||
}
|
||||
|
||||
const char *filepath = TEST_DATA_PATH "dsm_x_data.txt";
|
||||
bool RCTest::dsmTest12Ch()
|
||||
{
|
||||
return dsmTest(TEST_DATA_PATH "dsm_x_dx9_data.txt", 12, 11, 1500);
|
||||
}
|
||||
|
||||
bool RCTest::dsmTest(const char *filepath, unsigned expected_chancount, unsigned expected_dropcount, unsigned chan0)
|
||||
{
|
||||
|
||||
FILE *fp;
|
||||
fp = fopen(filepath, "rt");
|
||||
|
||||
ut_test(fp != nullptr);
|
||||
//warnx("loading data from: %s", filepath);
|
||||
//PX4_INFO("loading data from: %s", filepath);
|
||||
|
||||
float f;
|
||||
unsigned x;
|
||||
@@ -87,15 +98,21 @@ bool RCTest::dsmTest(void)
|
||||
&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");
|
||||
ut_test(num_values == expected_chancount);
|
||||
|
||||
if (chan0 > 0) {
|
||||
ut_test((chan0 - rc_values[0]) < 3);
|
||||
}
|
||||
|
||||
//PX4_INFO("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]);
|
||||
//PX4_INFO("chan #%u:\t%d", i, (int)rc_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (last_drop != (dsm_frame_drops)) {
|
||||
//warnx("frame dropped, now #%d", (dsm_frame_drops));
|
||||
//PX4_INFO("frame dropped, now #%d", (dsm_frame_drops));
|
||||
last_drop = dsm_frame_drops;
|
||||
}
|
||||
|
||||
@@ -103,6 +120,8 @@ bool RCTest::dsmTest(void)
|
||||
}
|
||||
|
||||
ut_test(ret == EOF);
|
||||
PX4_INFO("drop: %d", (int)last_drop);
|
||||
ut_test(last_drop == expected_dropcount);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -173,7 +192,7 @@ bool RCTest::sbus2Test(void)
|
||||
// }
|
||||
|
||||
if (last_drop != (sbus_frame_drops + sbus_frame_resets)) {
|
||||
warnx("frame dropped, now #%d", (sbus_frame_drops + sbus_frame_resets));
|
||||
PX4_WARN("frame dropped, now #%d", (sbus_frame_drops + sbus_frame_resets));
|
||||
last_drop = sbus_frame_drops + sbus_frame_resets;
|
||||
}
|
||||
|
||||
@@ -286,11 +305,11 @@ bool RCTest::sumdTest(void)
|
||||
|
||||
|
||||
if (!sumd_decode(b, &rssi, &rx_count, &channel_count, channels, 32)) {
|
||||
//warnx("decoded: %u channels (converted to PPM range)", (unsigned)channel_count);
|
||||
//PX4_INFO("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));
|
||||
//PX4_INFO("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user