Skip to content

Commit

Permalink
AP_GPS: remove dedundant crc32 routine from Nova
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Apr 14, 2024
1 parent 5a21d0c commit d14fb38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 2 additions & 23 deletions libraries/AP_GPS/AP_GPS_NOVA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ AP_GPS_NOVA::parse(uint8_t temp)
nova_msg.crc += (uint32_t) (temp << 24);
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);
crc = CalculateBlockCRC32((uint32_t)nova_msg.header.nova_headeru.messagelength, (uint8_t *)&nova_msg.data, crc);
uint32_t crc = crc_crc32((uint32_t)0, (uint8_t *)&nova_msg.header.data, (uint32_t)nova_msg.header.nova_headeru.headerlength);
crc = crc_crc32(crc, (uint8_t *)&nova_msg.data, (uint32_t)nova_msg.header.nova_headeru.messagelength);

if (nova_msg.crc == crc) {
return process_message();
Expand Down Expand Up @@ -293,25 +293,4 @@ AP_GPS_NOVA::process_message(void)
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
2 changes: 0 additions & 2 deletions libraries/AP_GPS/AP_GPS_NOVA.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class AP_GPS_NOVA : public AP_GPS_Backend

bool parse(uint8_t temp);
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_PREAMBLE2 = 0x44;
Expand Down

0 comments on commit d14fb38

Please sign in to comment.