Fixed Frsky-D telemetry protocol GPS sensor, gtests added

This commit is contained in:
Damjan Adamic
2016-10-05 17:57:02 +02:00
parent 5157a9f33c
commit f3c2a4db93
2 changed files with 23 additions and 2 deletions
+2 -2
View File
@@ -172,7 +172,7 @@ void processHubPacket(uint8_t id, int16_t value)
return;
}
else if (id == GPS_LAT_NS_ID) {
if (lastId == GPS_LONG_BP_ID) {
if (lastId == GPS_LAT_AP_ID) {
id = GPS_LAT_AP_ID;
unit = UNIT_GPS_LATITUDE;
data = getFrSkyDProtocolGPSValue(value == 'N' ? 1 : -1);
@@ -182,7 +182,7 @@ void processHubPacket(uint8_t id, int16_t value)
}
}
else if (id == GPS_LONG_EW_ID) {
if (lastId == GPS_LONG_BP_ID) {
if (lastId == GPS_LONG_AP_ID) {
id = GPS_LAT_AP_ID;
unit = UNIT_GPS_LONGITUDE;
data = getFrSkyDProtocolGPSValue(value == 'E' ? 1 : -1);
+21
View File
@@ -173,6 +173,27 @@ TEST(FrSky, HubAltNegative)
processHubPacket(BARO_ALT_AP_ID, 05);
EXPECT_EQ(telemetryItems[0].value, 120);
}
TEST(FrSky, Gps)
{
MODEL_RESET();
TELEMETRY_RESET();
EXPECT_EQ(telemetryItems[0].value, 0);
// latitude 15 degrees north, 30.5000 minutes = 15.508333333333333 degrees
processHubPacket(GPS_LAT_BP_ID, 1530); // DDDMM.
processHubPacket(GPS_LAT_AP_ID, 5000); // .MMMM
processHubPacket(GPS_LAT_NS_ID, 'N');
// longitude 45 degrees west, 20.5000 minutes = 45.34166666666667 degrees
processHubPacket(GPS_LONG_BP_ID, 4520);
processHubPacket(GPS_LONG_AP_ID, 5000);
processHubPacket(GPS_LONG_EW_ID, 'E');
EXPECT_EQ(telemetryItems[0].gps.latitude, 15508333);
EXPECT_EQ(telemetryItems[0].gps.longitude, 45341666);
}
#endif // defined(TELEMETRY_FRSKY) && defined(CPUARM)
#if defined(TELEMETRY_FRSKY_SPORT)