muorb: don't start muorb with stop command

Previously using 'muorb stop' would in fact start at least part of the
muorb which is not what it's expected to do.
This commit is contained in:
Julian Oes 2016-02-10 10:55:14 +01:00
parent 338ccb34f5
commit e4398bc87c
2 changed files with 28 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
* Copyright (c) 2012-2016 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -57,18 +57,26 @@ muorb_main(int argc, char *argv[])
* XXX it would be nice to have a wrapper for this...
*/
if (!strcmp(argv[1], "start")) {
// register the fast rpc channel with UORB.
uORB::Manager::get_instance()->set_uorb_communicator(uORB::KraitFastRpcChannel::GetInstance());
if (uORB::KraitFastRpcChannel::isInstance()) {
PX4_WARN("muorb already running");
} else {
// register the fast rpc channel with UORB.
uORB::Manager::get_instance()->set_uorb_communicator(uORB::KraitFastRpcChannel::GetInstance());
// start the KaitFastRPC channel thread.
uORB::KraitFastRpcChannel::GetInstance()->Start();
// start the KaitFastRPC channel thread.
uORB::KraitFastRpcChannel::GetInstance()->Start();
}
return OK;
}
if (!strcmp(argv[1], "stop")) {
uORB::KraitFastRpcChannel::GetInstance()->Stop();
if (uORB::KraitFastRpcChannel::isInstance()) {
uORB::KraitFastRpcChannel::GetInstance()->Stop();
} else {
PX4_WARN("muorb not running");
}
return OK;
}
@ -76,6 +84,11 @@ muorb_main(int argc, char *argv[])
* Print driver information.
*/
if (!strcmp(argv[1], "status")) {
if (uORB::KraitFastRpcChannel::isInstance()) {
PX4_WARN("muorb running");
} else {
PX4_WARN("muorb not running");
}
return OK;
}

View File

@ -62,6 +62,15 @@ public:
return _InstancePtr;
}
/**
* Static method to check if there is an instance.
*/
static bool isInstance()
{
return (_InstancePtr != nullptr);
}
/**
* @brief Interface to notify the remote entity of interest of a
* subscription for a message.