mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 07:03:33 +08:00
Reset the collection state machine on all I2C errors, increase the retry count.
This commit is contained in:
@@ -331,7 +331,7 @@ MS5611::probe()
|
|||||||
|
|
||||||
if ((OK == probe_address(MS5611_ADDRESS_1)) ||
|
if ((OK == probe_address(MS5611_ADDRESS_1)) ||
|
||||||
(OK == probe_address(MS5611_ADDRESS_2))) {
|
(OK == probe_address(MS5611_ADDRESS_2))) {
|
||||||
_retries = 1;
|
_retries = 2;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,13 +574,15 @@ MS5611::cycle_trampoline(void *arg)
|
|||||||
void
|
void
|
||||||
MS5611::cycle()
|
MS5611::cycle()
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* collection phase? */
|
/* collection phase? */
|
||||||
if (_collect_phase) {
|
if (_collect_phase) {
|
||||||
|
|
||||||
/* perform collection */
|
/* perform collection */
|
||||||
if (OK != collect()) {
|
ret = collect();
|
||||||
log("collection error");
|
if (ret != OK) {
|
||||||
|
log("collection error %d", ret);
|
||||||
/* reset the collection state machine and try again */
|
/* reset the collection state machine and try again */
|
||||||
start();
|
start();
|
||||||
return;
|
return;
|
||||||
@@ -609,8 +611,13 @@ MS5611::cycle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* measurement phase */
|
/* measurement phase */
|
||||||
if (OK != measure())
|
ret = measure();
|
||||||
log("measure error");
|
if (ret != OK) {
|
||||||
|
log("measure error %d", ret);
|
||||||
|
/* reset the collection state machine and try again */
|
||||||
|
start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* next phase is collection */
|
/* next phase is collection */
|
||||||
_collect_phase = true;
|
_collect_phase = true;
|
||||||
@@ -647,6 +654,7 @@ MS5611::measure()
|
|||||||
int
|
int
|
||||||
MS5611::collect()
|
MS5611::collect()
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint8_t data[3];
|
uint8_t data[3];
|
||||||
union {
|
union {
|
||||||
@@ -662,9 +670,10 @@ MS5611::collect()
|
|||||||
/* this should be fairly close to the end of the conversion, so the best approximation of the time */
|
/* this should be fairly close to the end of the conversion, so the best approximation of the time */
|
||||||
_reports[_next_report].timestamp = hrt_absolute_time();
|
_reports[_next_report].timestamp = hrt_absolute_time();
|
||||||
|
|
||||||
if (OK != transfer(&cmd, 1, &data[0], 3)) {
|
ret = transfer(&cmd, 1, &data[0], 3);
|
||||||
|
if (ret != OK) {
|
||||||
perf_count(_comms_errors);
|
perf_count(_comms_errors);
|
||||||
return -EIO;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fetch the raw value */
|
/* fetch the raw value */
|
||||||
|
|||||||
Reference in New Issue
Block a user