Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_GPS: remove dedundant crc32 routine from Nova #26798

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading