From fd7863270e77a90fd309642b1707eb7424c0decb Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Fri, 13 Mar 2015 16:58:24 -0700 Subject: [PATCH] Nuttx: fixed missing changes from AppMgr to AppState Signed-off-by: Mark Charlebois --- src/examples/publisher/publisher_example.cpp | 4 +- src/examples/publisher/publisher_example.h | 2 +- .../subscriber/subscriber_example.cpp | 2 +- src/examples/subscriber/subscriber_example.h | 2 +- src/modules/dataman/dataman.c | 42 +++++++++++++------ .../mc_att_control.cpp | 2 +- .../mc_att_control.h | 2 +- .../mc_pos_control.cpp | 2 +- .../mc_pos_control.h | 2 +- 9 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/examples/publisher/publisher_example.cpp b/src/examples/publisher/publisher_example.cpp index 4fddd072e1..7ce1533125 100644 --- a/src/examples/publisher/publisher_example.cpp +++ b/src/examples/publisher/publisher_example.cpp @@ -44,7 +44,7 @@ using namespace px4; PublisherExample::PublisherExample() : - _n(mgr), + _n(appState), _rc_channels_pub(_n.advertise()), _v_att_pub(_n.advertise()), _parameter_update_pub(_n.advertise()) @@ -55,7 +55,7 @@ int PublisherExample::main() { px4::Rate loop_rate(10); - while (!mgr.exitRequested()) { + while (!appState.exitRequested()) { loop_rate.sleep(); _n.spinOnce(); diff --git a/src/examples/publisher/publisher_example.h b/src/examples/publisher/publisher_example.h index 8b0d806bd0..2841320734 100644 --- a/src/examples/publisher/publisher_example.h +++ b/src/examples/publisher/publisher_example.h @@ -50,7 +50,7 @@ public: int main(); - static px4::AppMgr mgr; + static px4::AppState appState; protected: px4::NodeHandle _n; px4::Publisher *_rc_channels_pub; diff --git a/src/examples/subscriber/subscriber_example.cpp b/src/examples/subscriber/subscriber_example.cpp index 91fb131f32..ae58f634ce 100644 --- a/src/examples/subscriber/subscriber_example.cpp +++ b/src/examples/subscriber/subscriber_example.cpp @@ -49,7 +49,7 @@ void rc_channels_callback_function(const px4_rc_channels &msg) } SubscriberExample::SubscriberExample() : - _n(_mgr), + _n(_appState), _p_sub_interv("SUB_INTERV", PARAM_SUB_INTERV_DEFAULT), _p_test_float("SUB_TESTF", PARAM_SUB_TESTF_DEFAULT) { diff --git a/src/examples/subscriber/subscriber_example.h b/src/examples/subscriber/subscriber_example.h index 8003525dd5..4fdd236366 100644 --- a/src/examples/subscriber/subscriber_example.h +++ b/src/examples/subscriber/subscriber_example.h @@ -58,7 +58,7 @@ protected: px4::ParameterFloat _p_test_float; px4::Subscriber *_sub_rc_chan; - AppMgr _mgr; + AppState _appState; void rc_channels_callback(const px4_rc_channels &msg); void vehicle_attitude_callback(const px4_vehicle_attitude &msg); diff --git a/src/modules/dataman/dataman.c b/src/modules/dataman/dataman.c index c3b4ab8d4d..9b64b8baa1 100644 --- a/src/modules/dataman/dataman.c +++ b/src/modules/dataman/dataman.c @@ -40,7 +40,7 @@ * @author Thomas Gubler */ -#include +#include #include #include #include @@ -129,7 +129,12 @@ static sem_t g_sys_state_mutex; /* The data manager store file handle and file name */ static int g_fd = -1, g_task_fd = -1; +// FIXME - need a configurable path that is not OS specific +#ifdef __PX4_NUTTX static const char *k_data_manager_device_path = "/fs/microsd/dataman"; +#else +static const char *k_data_manager_device_path = "/tmp/dataman"; +#endif /* The data manager work queues */ @@ -668,7 +673,7 @@ task_main(int argc, char *argv[]) } /* Open or create the data manager file */ - g_task_fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY); + g_task_fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY, 0x0777); if (g_task_fd < 0) { warnx("Could not open data manager file %s", k_data_manager_device_path); @@ -827,31 +832,40 @@ stop(void) static void usage(void) { - errx(1, "usage: dataman {start|stop|status|poweronrestart|inflightrestart}"); + warnx("usage: dataman {start|stop|status|poweronrestart|inflightrestart}"); } int dataman_main(int argc, char *argv[]) { - if (argc < 2) + if (argc < 2) { usage(); + return -1; + } if (!strcmp(argv[1], "start")) { - if (g_fd >= 0) - errx(1, "already running"); + if (g_fd >= 0) { + warnx("dataman already running"); + return -1; + } start(); - if (g_fd < 0) - errx(1, "start failed"); + if (g_fd < 0) { + warnx("dataman start failed"); + return -1; + } - exit(0); + return 0; } /* Worker thread should be running for all other commands */ - if (g_fd < 0) - errx(1, "not running"); + if (g_fd < 0) { + warnx("dataman worker thread not running"); + usage(); + return -1; + } if (!strcmp(argv[1], "stop")) stop(); @@ -861,8 +875,10 @@ dataman_main(int argc, char *argv[]) dm_restart(DM_INIT_REASON_POWER_ON); else if (!strcmp(argv[1], "inflightrestart")) dm_restart(DM_INIT_REASON_IN_FLIGHT); - else + else { usage(); + return -1; + } - exit(1); + return 1; } diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control.cpp b/src/modules/mc_att_control_multiplatform/mc_att_control.cpp index 34859071f8..e478a92e9e 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control.cpp +++ b/src/modules/mc_att_control_multiplatform/mc_att_control.cpp @@ -71,7 +71,7 @@ MulticopterAttitudeControl::MulticopterAttitudeControl() : _att_sp_pub(nullptr), _v_rates_sp_pub(nullptr), _actuators_0_pub(nullptr), - _n(_mgr), + _n(_appState), /* parameters */ _params_handles({ diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control.h b/src/modules/mc_att_control_multiplatform/mc_att_control.h index 50f06d6967..aab41f97ba 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control.h +++ b/src/modules/mc_att_control_multiplatform/mc_att_control.h @@ -94,7 +94,7 @@ private: px4::NodeHandle _n; - px4::AppMgr _mgr; + px4::AppState _appState; struct { px4::ParameterFloat roll_p; diff --git a/src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp b/src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp index 1fd86fd509..72ee214292 100644 --- a/src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp +++ b/src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp @@ -65,7 +65,7 @@ MulticopterPositionControl::MulticopterPositionControl() : _local_pos_sp_msg(), _global_vel_sp_msg(), - _n(_mgr), + _n(_appState), /* parameters */ _params_handles({ diff --git a/src/modules/mc_pos_control_multiplatform/mc_pos_control.h b/src/modules/mc_pos_control_multiplatform/mc_pos_control.h index 3c6f28050e..4f786c4298 100644 --- a/src/modules/mc_pos_control_multiplatform/mc_pos_control.h +++ b/src/modules/mc_pos_control_multiplatform/mc_pos_control.h @@ -107,7 +107,7 @@ protected: px4::NodeHandle _n; - px4::AppMgr _mgr; + px4::AppState _appState; struct { px4::ParameterFloat thr_min;