mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 02:51:37 +08:00
Baro sim: Fix up struct use
This commit is contained in:
@@ -653,11 +653,11 @@ BAROSIM::collect()
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct {
|
struct raw_baro_s {
|
||||||
float pressure;
|
float pressure;
|
||||||
float altitude;
|
float altitude;
|
||||||
float temperature;
|
float temperature;
|
||||||
} baro_report;
|
} raw_baro;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
@@ -669,7 +669,7 @@ BAROSIM::collect()
|
|||||||
|
|
||||||
/* read the most recent measurement - read offset/size are hardcoded in the interface */
|
/* read the most recent measurement - read offset/size are hardcoded in the interface */
|
||||||
uint8_t cmd = 0;
|
uint8_t cmd = 0;
|
||||||
ret = transfer(&cmd, 1, (uint8_t *)&report, sizeof(baro_report));
|
ret = transfer(&cmd, 1, (uint8_t*)(&raw_baro), sizeof(raw_baro));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
perf_count(_comms_errors);
|
perf_count(_comms_errors);
|
||||||
@@ -679,16 +679,14 @@ BAROSIM::collect()
|
|||||||
|
|
||||||
/* handle a measurement */
|
/* handle a measurement */
|
||||||
if (_measure_phase == 0) {
|
if (_measure_phase == 0) {
|
||||||
report.pressure = baro_report.pressure;
|
report.pressure = raw_baro.pressure;
|
||||||
report.altitude = baro_report.altitude;
|
report.altitude = raw_baro.altitude;
|
||||||
report.temperature = baro_report.temperature;
|
report.temperature = raw_baro.temperature;
|
||||||
report.timestamp = hrt_absolute_time();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
report.pressure = baro_report.pressure;
|
report.pressure = raw_baro.pressure;
|
||||||
report.altitude = baro_report.altitude;
|
report.altitude = raw_baro.altitude;
|
||||||
report.temperature = baro_report.temperature;
|
report.temperature = raw_baro.temperature;
|
||||||
report.timestamp = hrt_absolute_time();
|
|
||||||
|
|
||||||
/* publish it */
|
/* publish it */
|
||||||
if (!(m_pub_blocked)) {
|
if (!(m_pub_blocked)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user