mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
Make mixer upload not depending on single serial transfer error
This commit is contained in:
@@ -392,7 +392,7 @@ private:
|
||||
/**
|
||||
* Send mixer definition text to IO
|
||||
*/
|
||||
int mixer_send(const char *buf, unsigned buflen);
|
||||
int mixer_send(const char *buf, unsigned buflen, unsigned retries=3);
|
||||
|
||||
/**
|
||||
* Handle a status update from IO.
|
||||
@@ -1468,9 +1468,13 @@ PX4IO::io_reg_modify(uint8_t page, uint8_t offset, uint16_t clearbits, uint16_t
|
||||
}
|
||||
|
||||
int
|
||||
PX4IO::mixer_send(const char *buf, unsigned buflen)
|
||||
PX4IO::mixer_send(const char *buf, unsigned buflen, unsigned retries)
|
||||
{
|
||||
|
||||
uint8_t frame[_max_transfer];
|
||||
|
||||
do {
|
||||
|
||||
px4io_mixdata *msg = (px4io_mixdata *)&frame[0];
|
||||
unsigned max_len = _max_transfer - sizeof(px4io_mixdata);
|
||||
|
||||
@@ -1513,16 +1517,21 @@ PX4IO::mixer_send(const char *buf, unsigned buflen)
|
||||
|
||||
} while (buflen > 0);
|
||||
|
||||
retries--;
|
||||
|
||||
log("mixer sent");
|
||||
|
||||
} while (retries > 0 && (!(io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_FLAGS) & PX4IO_P_STATUS_FLAGS_MIXER_OK)));
|
||||
|
||||
/* check for the mixer-OK flag */
|
||||
if (io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_FLAGS) & PX4IO_P_STATUS_FLAGS_MIXER_OK) {
|
||||
debug("mixer upload OK");
|
||||
mavlink_log_info(_mavlink_fd, "[IO] mixer upload ok");
|
||||
return 0;
|
||||
} else {
|
||||
debug("mixer rejected by IO");
|
||||
mavlink_log_info(_mavlink_fd, "[IO] mixer upload fail");
|
||||
}
|
||||
|
||||
log("mixer rejected by IO");
|
||||
mavlink_log_info(_mavlink_fd, "[IO] mixer upload fail");
|
||||
|
||||
/* load must have failed for some reason */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user