diff --git a/src/drivers/sdp3x_airspeed/SDP3X.cpp b/src/drivers/sdp3x_airspeed/SDP3X.cpp index 100623ad80..b267025fd1 100644 --- a/src/drivers/sdp3x_airspeed/SDP3X.cpp +++ b/src/drivers/sdp3x_airspeed/SDP3X.cpp @@ -86,7 +86,7 @@ SDP3X::init_sdp3x() // step 3 - get scale uint8_t val[9]; - ret = transfer(nullptr, 0, &val[0], 9); + ret = transfer(nullptr, 0, &val[0], sizeof(val)); if (ret != PX4_OK) { perf_count(_comms_errors); @@ -110,9 +110,9 @@ SDP3X::collect() { perf_begin(_sample_perf); - // read 6 bytes from the sensor + // read 9 bytes from the sensor uint8_t val[6]; - int ret = transfer(nullptr, 0, &val[0], 6); + int ret = transfer(nullptr, 0, &val[0], sizeof(val)); if (ret != PX4_OK) { perf_count(_comms_errors); @@ -128,8 +128,8 @@ SDP3X::collect() ret = 0; } - int16_t P = (((uint16_t)val[0]) << 8) | val[1]; - int16_t temp = (((uint16_t)val[3]) << 8) | val[4]; + int16_t P = (((int16_t)val[0]) << 8) | val[1]; + int16_t temp = (((int16_t)val[3]) << 8) | val[4]; float diff_press_pa_raw = static_cast(P) / static_cast(_scale); float temperature_c = temp / static_cast(SDP3X_SCALE_TEMPERATURE); diff --git a/src/drivers/sdp3x_airspeed/SDP3X.hpp b/src/drivers/sdp3x_airspeed/SDP3X.hpp index d3cd7ce67f..eeae46d0ef 100644 --- a/src/drivers/sdp3x_airspeed/SDP3X.hpp +++ b/src/drivers/sdp3x_airspeed/SDP3X.hpp @@ -104,7 +104,7 @@ private: int write_command(uint16_t command); bool _inited{false}; - int16_t _scale{0}; + uint16_t _scale{0}; }; #endif /* DRIVERS_SDP3X_AIRSPEED_HPP_ */