mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 12:48:53 +08:00
septentrio: avoid compilation error
Even though all enum values fit into 13 bits, there's an error: ../../src/drivers/gnss/septentrio/sbf/messages.h:101:21: error: ‘septentrio::sbf::Header::id_number’ is too small to hold all values of ‘enum class septentrio::sbf::BlockID’ [-Werror] This is with GCC 13.3.0 under Ubuntu 24.04
This commit is contained in:
@@ -102,7 +102,7 @@ Decoder::State Decoder::add_byte(uint8_t byte)
|
|||||||
|
|
||||||
BlockID Decoder::id() const
|
BlockID Decoder::id() const
|
||||||
{
|
{
|
||||||
return _state == State::Done ? _message.header.id_number : BlockID::Invalid;
|
return _state == State::Done ? static_cast<BlockID>(_message.header.id_number) : BlockID::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Decoder::parse(Header *header) const
|
int Decoder::parse(Header *header) const
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ struct Header {
|
|||||||
uint8_t sync1;
|
uint8_t sync1;
|
||||||
uint8_t sync2;
|
uint8_t sync2;
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
BlockID id_number: 13;
|
uint16_t id_number: 13;
|
||||||
uint16_t id_revision: 3;
|
uint16_t id_revision: 3;
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
uint32_t tow;
|
uint32_t tow;
|
||||||
@@ -143,7 +143,7 @@ struct PVTGeodetic {
|
|||||||
MissingBaseStationCoordinates = 9,
|
MissingBaseStationCoordinates = 9,
|
||||||
MissingRequiredRTKFixedPosition = 10,
|
MissingRequiredRTKFixedPosition = 10,
|
||||||
};
|
};
|
||||||
ModeType mode_type: 4;
|
uint8_t mode_type: 4;
|
||||||
uint8_t mode_reserved: 2;
|
uint8_t mode_reserved: 2;
|
||||||
uint8_t mode_base_fixed: 1;
|
uint8_t mode_base_fixed: 1;
|
||||||
uint8_t mode_2d: 1;
|
uint8_t mode_2d: 1;
|
||||||
@@ -314,8 +314,8 @@ struct AttEuler {
|
|||||||
InsufficientMeasurements = 1,
|
InsufficientMeasurements = 1,
|
||||||
};
|
};
|
||||||
uint8_t nr_sv;
|
uint8_t nr_sv;
|
||||||
Error error_aux1: 2;
|
uint8_t error_aux1: 2;
|
||||||
Error error_aux2: 2;
|
uint8_t error_aux2: 2;
|
||||||
uint8_t error_reserved: 3;
|
uint8_t error_reserved: 3;
|
||||||
uint8_t error_not_requested: 1;
|
uint8_t error_not_requested: 1;
|
||||||
uint16_t mode;
|
uint16_t mode;
|
||||||
@@ -334,8 +334,8 @@ struct AttCovEuler {
|
|||||||
InsufficientMeasurements = 1,
|
InsufficientMeasurements = 1,
|
||||||
};
|
};
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
Error error_aux1: 2;
|
uint8_t error_aux1: 2;
|
||||||
Error error_aux2: 2;
|
uint8_t error_aux2: 2;
|
||||||
uint8_t error_reserved: 3;
|
uint8_t error_reserved: 3;
|
||||||
uint8_t error_not_requested: 1;
|
uint8_t error_not_requested: 1;
|
||||||
float cov_headhead;
|
float cov_headhead;
|
||||||
|
|||||||
@@ -1075,7 +1075,7 @@ int SeptentrioDriver::process_message()
|
|||||||
PVTGeodetic pvt_geodetic;
|
PVTGeodetic pvt_geodetic;
|
||||||
|
|
||||||
if (_sbf_decoder.parse(&header) == PX4_OK && _sbf_decoder.parse(&pvt_geodetic) == PX4_OK) {
|
if (_sbf_decoder.parse(&header) == PX4_OK && _sbf_decoder.parse(&pvt_geodetic) == PX4_OK) {
|
||||||
switch (pvt_geodetic.mode_type) {
|
switch (static_cast<sbf::PVTGeodetic::ModeType>(pvt_geodetic.mode_type)) {
|
||||||
case ModeType::NoPVT:
|
case ModeType::NoPVT:
|
||||||
_message_gps_state.fix_type = sensor_gps_s::FIX_TYPE_NONE;
|
_message_gps_state.fix_type = sensor_gps_s::FIX_TYPE_NONE;
|
||||||
break;
|
break;
|
||||||
@@ -1242,8 +1242,8 @@ int SeptentrioDriver::process_message()
|
|||||||
|
|
||||||
if (_sbf_decoder.parse(&att_euler) == PX4_OK &&
|
if (_sbf_decoder.parse(&att_euler) == PX4_OK &&
|
||||||
!att_euler.error_not_requested &&
|
!att_euler.error_not_requested &&
|
||||||
att_euler.error_aux1 == Error::None &&
|
static_cast<AttEuler::Error>(att_euler.error_aux1) == Error::None &&
|
||||||
att_euler.error_aux2 == Error::None &&
|
static_cast<AttEuler::Error>(att_euler.error_aux2) == Error::None &&
|
||||||
att_euler.heading > k_dnu_f4_value) {
|
att_euler.heading > k_dnu_f4_value) {
|
||||||
float heading = att_euler.heading * M_PI_F / 180.0f; // Range of degrees to range of radians in [0, 2PI].
|
float heading = att_euler.heading * M_PI_F / 180.0f; // Range of degrees to range of radians in [0, 2PI].
|
||||||
|
|
||||||
@@ -1267,8 +1267,8 @@ int SeptentrioDriver::process_message()
|
|||||||
|
|
||||||
if (_sbf_decoder.parse(&att_cov_euler) == PX4_OK &&
|
if (_sbf_decoder.parse(&att_cov_euler) == PX4_OK &&
|
||||||
!att_cov_euler.error_not_requested &&
|
!att_cov_euler.error_not_requested &&
|
||||||
att_cov_euler.error_aux1 == Error::None &&
|
static_cast<AttCovEuler::Error>(att_cov_euler.error_aux1) == Error::None &&
|
||||||
att_cov_euler.error_aux2 == Error::None &&
|
static_cast<AttCovEuler::Error>(att_cov_euler.error_aux2) == Error::None &&
|
||||||
att_cov_euler.cov_headhead > k_dnu_f4_value) {
|
att_cov_euler.cov_headhead > k_dnu_f4_value) {
|
||||||
_message_gps_state.heading_accuracy = att_cov_euler.cov_headhead * M_PI_F / 180.0f; // Convert range of degrees to range of radians in [0, 2PI]
|
_message_gps_state.heading_accuracy = att_cov_euler.cov_headhead * M_PI_F / 180.0f; // Convert range of degrees to range of radians in [0, 2PI]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ TEST(SeptentrioTestDecoding, decodeMessage)
|
|||||||
septentrio::sbf::message_t m{};
|
septentrio::sbf::message_t m{};
|
||||||
m.header.sync1 = '$';
|
m.header.sync1 = '$';
|
||||||
m.header.sync2 = '@';
|
m.header.sync2 = '@';
|
||||||
m.header.id_number = septentrio::sbf::BlockID::PVTGeodetic;
|
m.header.id_number = static_cast<uint16_t>(septentrio::sbf::BlockID::PVTGeodetic);
|
||||||
m.header.length = sizeof(m.header) + sizeof(septentrio::sbf::PVTGeodetic);
|
m.header.length = sizeof(m.header) + sizeof(septentrio::sbf::PVTGeodetic);
|
||||||
septentrio::sbf::PVTGeodetic pvt{};
|
septentrio::sbf::PVTGeodetic pvt{};
|
||||||
pvt.latitude = 123;
|
pvt.latitude = 123;
|
||||||
|
|||||||
Reference in New Issue
Block a user