diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index 7234625594..1c807ccd6b 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -38,6 +38,7 @@ COMMON_VEHICLE_DEPENDENT_LIBRARIES = [ 'AP_Compass', 'AP_Declination', 'AP_GPS', + 'AP_GSOF', 'AP_HAL', 'AP_HAL_Empty', 'AP_InertialSensor', diff --git a/Tools/scripts/run_astyle.py b/Tools/scripts/run_astyle.py index c92fc9079f..7f5a694f73 100755 --- a/Tools/scripts/run_astyle.py +++ b/Tools/scripts/run_astyle.py @@ -23,6 +23,7 @@ class AStyleChecker(object): self.directories_to_check = [ 'libraries/AP_DDS', 'libraries/AP_ExternalControl', + 'libraries/AP_GSOF', ] self.files_to_check = [ pathlib.Path(s) for s in [ diff --git a/libraries/AP_GPS/AP_GPS_GSOF.cpp b/libraries/AP_GPS/AP_GPS_GSOF.cpp index 2b537fb08d..588265b533 100644 --- a/libraries/AP_GPS/AP_GPS_GSOF.cpp +++ b/libraries/AP_GPS/AP_GPS_GSOF.cpp @@ -157,7 +157,8 @@ AP_GPS_GSOF::requestGSOF(const uint8_t messageType, const HW_Port portIndex, con } bool -AP_GPS_GSOF::validate_com_port(const uint8_t com_port) const { +AP_GPS_GSOF::validate_com_port(const uint8_t com_port) const +{ switch(com_port) { case static_cast(HW_Port::COM1): case static_cast(HW_Port::COM2): @@ -168,7 +169,8 @@ AP_GPS_GSOF::validate_com_port(const uint8_t com_port) const { } void -AP_GPS_GSOF::pack_state_data() { +AP_GPS_GSOF::pack_state_data() +{ // TODO should we pack time data if there is no fix? state.time_week_ms = pos_time.time_week_ms; state.time_week = pos_time.time_week; diff --git a/libraries/AP_GSOF/tests/README.md b/libraries/AP_GSOF/tests/README.md new file mode 100644 index 0000000000..684c317474 --- /dev/null +++ b/libraries/AP_GSOF/tests/README.md @@ -0,0 +1,3 @@ +# GSOF Tests + +A UDP packet of binary GSOF data is attached in the `gsof_data` file. diff --git a/libraries/AP_GSOF/tests/gsof_gps.dat b/libraries/AP_GSOF/tests/gsof_gps.dat new file mode 100644 index 0000000000..8b856f475e Binary files /dev/null and b/libraries/AP_GSOF/tests/gsof_gps.dat differ diff --git a/libraries/AP_GSOF/tests/test_gsof.cpp b/libraries/AP_GSOF/tests/test_gsof.cpp index 7e23d9c3a6..628a6bf136 100644 --- a/libraries/AP_GSOF/tests/test_gsof.cpp +++ b/libraries/AP_GSOF/tests/test_gsof.cpp @@ -7,20 +7,34 @@ #include +#include +#include + const AP_HAL::HAL &hal = AP_HAL::get_HAL(); TEST(AP_GSOF, incomplete_packet) { AP_GSOF gsof; - EXPECT_FALSE(gsof.parse(0)); + EXPECT_FALSE(gsof.parse(0, 5)); } TEST(AP_GSOF, packet1) { - // 02084072580000010a1e02e0680909009400000218000000000000000000000000000000000000000000000000080d000000000000000000000000000910000000000000000000000000000000000c260000000000000000000000000000000000000000000000000000000000000000000000000000a503 + FILE* fp = std::fopen("libraries/AP_GSOF/tests/gsof_gps.dat", "rb"); + EXPECT_NE(fp, nullptr); AP_GSOF gsof; - EXPECT_FALSE(gsof.parse(0)); + char c = 0; + bool parsed = false; + while (c != EOF) { + c = fgetc (fp); + parsed |= gsof.parse((uint8_t)c, 5); + } + + EXPECT_TRUE(parsed); + + fclose(fp); + } AP_GTEST_MAIN()