1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 03:30:33 +00:00

Remove redundant fields in an_packet_t

This commit is contained in:
Carles Fernandez 2021-10-22 15:51:38 +02:00
parent 7f45739cf0
commit 69c4f9f7fc
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 11 additions and 13 deletions

View File

@ -98,6 +98,7 @@ void An_Packet_Printer::update_sdr_gnss_packet(sdr_gnss_packet_t* _packet, const
uint8_t num_gps_sats = 0;
uint8_t num_gal_sats = 0;
int index = 0;
bool fix_3d = pvt->is_valid_position();
const int max_reported_sats = *(&_packet->sats + 1) - _packet->sats;
for (gnss_observables_iter = gnss_observables_map.cbegin();
@ -178,8 +179,10 @@ void An_Packet_Printer::update_sdr_gnss_packet(sdr_gnss_packet_t* _packet, const
_packet->velocity[2] = static_cast<float>(-pvt->get_rx_vel()[2]);
uint16_t status = 0;
// Set 3D fix (bit 0 and 1) / Set Doppler velocity valid (bit 2) / Set Time valid (bit 3)
status = status & 0b00001111;
if (fix_3d)
{
status = 15; // Set 3D fix (bit 0 and 1) / Set Doppler velocity valid (bit 2) / Set Time valid (bit 3)
}
_packet->status = status;
}
@ -192,8 +195,6 @@ void An_Packet_Printer::update_sdr_gnss_packet(sdr_gnss_packet_t* _packet, const
*/
void An_Packet_Printer::encode_sdr_gnss_packet(sdr_gnss_packet_t* sdr_gnss_packet, an_packet_t* _packet) const
{
_packet->id = SDR_GNSS_PACKET_ID;
_packet->length = SDR_GNSS_PACKET_LENGTH;
uint8_t offset = 0;
LSB_bytes_to_array(reinterpret_cast<uint8_t*>(&sdr_gnss_packet->nsvfix), offset, _packet->data, sizeof(sdr_gnss_packet->nsvfix));
offset += sizeof(sdr_gnss_packet->nsvfix);
@ -238,10 +239,9 @@ void An_Packet_Printer::encode_sdr_gnss_packet(sdr_gnss_packet_t* sdr_gnss_packe
void An_Packet_Printer::an_packet_encode(an_packet_t* an_packet) const
{
uint16_t crc;
an_packet->header[1] = an_packet->id;
an_packet->header[2] = an_packet->length;
crc = calculate_crc16(an_packet->data, an_packet->length);
memcpy(&an_packet->header[3], &crc, sizeof(uint16_t));
an_packet->header[1] = SDR_GNSS_PACKET_ID;
crc = calculate_crc16(an_packet->data, SDR_GNSS_PACKET_LENGTH);
memcpy(&an_packet->header[2], &crc, sizeof(uint16_t));
an_packet->header[0] = calculate_header_lrc(&an_packet->header[1]);
}
@ -251,7 +251,7 @@ void An_Packet_Printer::an_packet_encode(an_packet_t* an_packet) const
*/
uint8_t An_Packet_Printer::calculate_header_lrc(const uint8_t* data) const
{
return ((data[0] + data[1] + data[2] + data[3]) ^ 0xFF) + 1;
return ((data[0] + data[1] + data[2]) ^ 0xFF) + 1;
}

View File

@ -61,10 +61,8 @@ struct sdr_gnss_packet_t
struct an_packet_t
{
uint8_t id;
uint8_t length;
uint8_t header[5]; // AN_PACKET_HEADER_SIZE
uint8_t data[126]; // AN_MAXIMUM_PACKET_SIZE
uint8_t header[4];
uint8_t data[73]; // SDR_GNSS_PACKET_LENGTH
};