mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-04 06:11:36 +08:00
BAROSIM: Fixed error in transfer function
The transfer function would previously return error if the receive buffer length was 0. This appears to be a valid condition for requesting a measurmement be taken but no data returned. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -201,15 +201,20 @@ BARO_SIM::transfer(const uint8_t *send, unsigned send_len,
|
||||
{
|
||||
// TODO add Simulation data connection so calls retrieve
|
||||
// data from the simulator
|
||||
|
||||
if (send_len != 1 || send[0] != 0 || recv_len != 3) {
|
||||
if (recv_len == 0) {
|
||||
PX4_DEBUG("BARO_SIM measurement requested");
|
||||
}
|
||||
else if (send_len != 1 || send[0] != 0 || recv_len != 3) {
|
||||
PX4_WARN("BARO_SIM::transfer invalid param %u %u %u\n", send_len, send[0], recv_len);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
Simulator *sim = Simulator::getInstance();
|
||||
if (sim == NULL) {
|
||||
PX4_ERR("Error BARO_SIM::transfer no simulator \n");
|
||||
return -ENODEV;
|
||||
}
|
||||
PX4_DEBUG("BARO_SIM::transfer getting sample\n");
|
||||
sim->getBaroSample(recv, recv_len);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user