AP_InertialSensor: AuxiliaryBus: fix return value

We should return the number of bytes written/read, not 0 on success.
This number may be useful in some cases so return it.

While at it fix a simple wrong space in the header.
This commit is contained in:
Lucas De Marchi 2016-03-03 18:22:26 -03:00
parent 6a6175df1c
commit 057822b51c
3 changed files with 11 additions and 7 deletions

View File

@ -771,7 +771,7 @@ int AP_MPU6000_AuxiliaryBusSlave::passthrough_write(uint8_t reg, uint8_t val)
/* disable new writes */
backend._register_write(_mpu6000_ctrl, 0);
return 0;
return 1;
}
int AP_MPU6000_AuxiliaryBusSlave::read(uint8_t *buf)
@ -782,9 +782,11 @@ int AP_MPU6000_AuxiliaryBusSlave::read(uint8_t *buf)
}
auto &backend = AP_InertialSensor_MPU6000::from(_bus.get_backend());
backend._block_read(MPUREG_EXT_SENS_DATA_00 + _ext_sens_data, buf, _sample_size);
if (!backend._block_read(MPUREG_EXT_SENS_DATA_00 + _ext_sens_data, buf, _sample_size)) {
return -1;
}
return 0;
return _sample_size;
}
/* MPU6000 provides up to 5 slave devices, but the 5th is way too different to

View File

@ -644,7 +644,7 @@ int AP_MPU9250_AuxiliaryBusSlave::passthrough_write(uint8_t reg, uint8_t val)
/* disable new writes */
backend._register_write(_mpu9250_ctrl, 0);
return 0;
return 1;
}
int AP_MPU9250_AuxiliaryBusSlave::read(uint8_t *buf)
@ -655,9 +655,11 @@ int AP_MPU9250_AuxiliaryBusSlave::read(uint8_t *buf)
}
auto &backend = AP_InertialSensor_MPU9250::from(_bus.get_backend());
backend._block_read(MPUREG_EXT_SENS_DATA_00 + _ext_sens_data, buf, _sample_size);
if (!backend._block_read(MPUREG_EXT_SENS_DATA_00 + _ext_sens_data, buf, _sample_size)) {
return -1;
}
return 0;
return _sample_size;
}
/* MPU9250 provides up to 5 slave devices, but the 5th is way too different to

View File

@ -83,7 +83,7 @@ private:
* account */
bool _block_read(uint8_t reg, uint8_t *buf, uint32_t size);
uint8_t _register_read(uint8_t reg);
void _register_write(uint8_t reg, uint8_t val );
void _register_write(uint8_t reg, uint8_t val);
void _register_write_check(uint8_t reg, uint8_t val);
void _accumulate(uint8_t *sample);