mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_OpticalFlow: pack struct passed to I2C layer
We pass "sizeof(i2c_integral_frame)" to hal.i2c->readRegisters(). Since we have a padding in i2c_integral_frame we actually read 3 bytes more than we should. Add PACKED to the struct so this is fixed. i2c_frame doesn't have a padding (or hole) so there isn't this problem, but since it's also used to calculate the frame size, use PACKED there too.
This commit is contained in:
parent
6bad33c922
commit
41ddb67712
@ -9,6 +9,8 @@
|
||||
#define AP_OpticalFlow_Linux_H
|
||||
|
||||
#include "OpticalFlow.h"
|
||||
|
||||
#include <AP_Common/AP_Common.h>
|
||||
#include <AP_Math/AP_Math.h>
|
||||
|
||||
class AP_OpticalFlow_Linux : public OpticalFlow_backend
|
||||
@ -25,7 +27,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
typedef struct {
|
||||
typedef struct PACKED {
|
||||
uint16_t frame_count;
|
||||
int16_t pixel_flow_x_sum;
|
||||
int16_t pixel_flow_y_sum;
|
||||
@ -40,7 +42,7 @@ private:
|
||||
int16_t ground_distance;
|
||||
} i2c_frame;
|
||||
|
||||
typedef struct {
|
||||
typedef struct PACKED {
|
||||
uint16_t frame_count_since_last_readout;
|
||||
int16_t pixel_flow_x_integral;
|
||||
int16_t pixel_flow_y_integral;
|
||||
|
Loading…
Reference in New Issue
Block a user