mirror of https://github.com/ArduPilot/ardupilot
AP_GPS: remove dedundant crc32 routine from Nova
This commit is contained in:
parent
41474f862f
commit
cd9aa0e3ed
|
@ -176,8 +176,8 @@ AP_GPS_NOVA::parse(uint8_t temp)
|
||||||
nova_msg.crc += (uint32_t) (temp << 24);
|
nova_msg.crc += (uint32_t) (temp << 24);
|
||||||
nova_msg.nova_state = nova_msg_parser::PREAMBLE1;
|
nova_msg.nova_state = nova_msg_parser::PREAMBLE1;
|
||||||
|
|
||||||
uint32_t crc = CalculateBlockCRC32((uint32_t)nova_msg.header.nova_headeru.headerlength, (uint8_t *)&nova_msg.header.data, (uint32_t)0);
|
uint32_t crc = crc_crc32((uint32_t)0, (uint8_t *)&nova_msg.header.data, (uint32_t)nova_msg.header.nova_headeru.headerlength);
|
||||||
crc = CalculateBlockCRC32((uint32_t)nova_msg.header.nova_headeru.messagelength, (uint8_t *)&nova_msg.data, crc);
|
crc = crc_crc32(crc, (uint8_t *)&nova_msg.data, (uint32_t)nova_msg.header.nova_headeru.messagelength);
|
||||||
|
|
||||||
if (nova_msg.crc == crc) {
|
if (nova_msg.crc == crc) {
|
||||||
return process_message();
|
return process_message();
|
||||||
|
@ -293,25 +293,4 @@ AP_GPS_NOVA::process_message(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CRC32_POLYNOMIAL 0xEDB88320L
|
|
||||||
uint32_t AP_GPS_NOVA::CRC32Value(uint32_t icrc)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
uint32_t crc = icrc;
|
|
||||||
for ( i = 8 ; i > 0; i-- ) {
|
|
||||||
if ( crc & 1 )
|
|
||||||
crc = ( crc >> 1 ) ^ CRC32_POLYNOMIAL;
|
|
||||||
else
|
|
||||||
crc >>= 1;
|
|
||||||
}
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t AP_GPS_NOVA::CalculateBlockCRC32(uint32_t length, uint8_t *buffer, uint32_t crc)
|
|
||||||
{
|
|
||||||
while ( length-- != 0 ) {
|
|
||||||
crc = ((crc >> 8) & 0x00FFFFFFL) ^ (CRC32Value(((uint32_t) crc ^ *buffer++) & 0xff));
|
|
||||||
}
|
|
||||||
return( crc );
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,8 +39,6 @@ private:
|
||||||
|
|
||||||
bool parse(uint8_t temp);
|
bool parse(uint8_t temp);
|
||||||
bool process_message();
|
bool process_message();
|
||||||
uint32_t CRC32Value(uint32_t icrc);
|
|
||||||
uint32_t CalculateBlockCRC32(uint32_t length, uint8_t *buffer, uint32_t crc);
|
|
||||||
|
|
||||||
static const uint8_t NOVA_PREAMBLE1 = 0xaa;
|
static const uint8_t NOVA_PREAMBLE1 = 0xaa;
|
||||||
static const uint8_t NOVA_PREAMBLE2 = 0x44;
|
static const uint8_t NOVA_PREAMBLE2 = 0x44;
|
||||||
|
|
Loading…
Reference in New Issue