From 791d780bb898e6f1ce840e3aa0245dbd99524b65 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Mon, 18 May 2015 13:29:20 -0700 Subject: [PATCH] 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 --- src/platforms/posix/drivers/barosim/baro.cpp | 12 ++++++------ src/platforms/posix/drivers/barosim/baro_sim.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/platforms/posix/drivers/barosim/baro.cpp b/src/platforms/posix/drivers/barosim/baro.cpp index 751ffd43db..4a247f85bd 100644 --- a/src/platforms/posix/drivers/barosim/baro.cpp +++ b/src/platforms/posix/drivers/barosim/baro.cpp @@ -280,7 +280,7 @@ BAROSIM::init() /* do temperature first */ if (OK != measure()) { ret = -EIO; - PX4_WARN("temp measure failed"); + PX4_ERR("temp measure failed"); break; } @@ -288,14 +288,14 @@ BAROSIM::init() if (OK != collect()) { ret = -EIO; - PX4_WARN("temp collect failed"); + PX4_ERR("temp collect failed"); break; } /* now do a pressure measurement */ if (OK != measure()) { ret = -EIO; - PX4_WARN("pressure collect failed"); + PX4_ERR("pressure collect failed"); break; } @@ -303,7 +303,7 @@ BAROSIM::init() if (OK != collect()) { ret = -EIO; - PX4_WARN("pressure collect failed"); + PX4_ERR("pressure collect failed"); break; } @@ -316,7 +316,7 @@ BAROSIM::init() &_orb_class_instance, (is_external()) ? ORB_PRIO_HIGH : ORB_PRIO_DEFAULT); if (_baro_topic == (orb_advert_t)(-1)) { - PX4_WARN("failed to create sensor_baro publication"); + PX4_ERR("failed to create sensor_baro publication"); } //PX4_WARN("sensor_baro publication %ld", _baro_topic); @@ -728,7 +728,7 @@ BAROSIM::collect() orb_publish(ORB_ID(sensor_baro), _baro_topic, &report); } else { - PX4_ERR("BAROSIM::collect _baro_topic not initialized"); + PX4_WARN("BAROSIM::collect _baro_topic not initialized"); } } diff --git a/src/platforms/posix/drivers/barosim/baro_sim.cpp b/src/platforms/posix/drivers/barosim/baro_sim.cpp index 42d52b4fef..7c267f6aaa 100644 --- a/src/platforms/posix/drivers/barosim/baro_sim.cpp +++ b/src/platforms/posix/drivers/barosim/baro_sim.cpp @@ -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;