diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 07dd54467..b647d28ea 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -72,7 +72,8 @@ enum FSSP_SENSOR_ID2 = 0x0D, FSSP_SENSOR_ID3 = 0x34, FSSP_SENSOR_ID4 = 0x67, - // reverse engineering tells me that there are plenty more IDs + // there are 32 ID's polled by smartport master + // remaining 3 bits are crc (according to comments in openTx code) }; // these data identifiers are obtained from http://diydrones.com/forum/topics/amp-to-frsky-x8r-sport-converter @@ -181,8 +182,6 @@ static void smartPortSendByte(uint8_t c, uint16_t *crcp) crc += c; crc += crc >> 8; crc &= 0x00FF; - crc += crc >> 8; - crc &= 0x00FF; *crcp = crc; } @@ -315,7 +314,6 @@ void handleSmartPortTelemetry(void) } smartPortIdCnt++; - float tmpf; int32_t tmpi; uint32_t tmpui; static uint8_t t1Cnt = 0; @@ -323,9 +321,8 @@ void handleSmartPortTelemetry(void) switch(id) { case FSSP_DATAID_SPEED : if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) { - tmpf = GPS_speed; - tmpf *= 0.36f; - smartPortSendPackage(id, (uint32_t)lroundf(tmpf)); // given in 0.1 m/s, provide in KM/H + tmpui = (GPS_speed * 36 + 36 / 2) / 100; + smartPortSendPackage(id, tmpui); // given in 0.1 m/s, provide in KM/H smartPortHasRequest = 0; } break; @@ -380,7 +377,7 @@ void handleSmartPortTelemetry(void) smartPortHasRequest = 0; break; case FSSP_DATAID_HEADING : - smartPortSendPackage(id, heading / 10); // given in 0.1 deg, requested in 10000 = 100 deg + smartPortSendPackage(id, heading * 100); // given in deg, requested in 10000 = 100 deg smartPortHasRequest = 0; break; case FSSP_DATAID_ACCX :