diff --git a/src/drivers/qshell/posix/qshell.cpp b/src/drivers/qshell/posix/qshell.cpp index c9c223ed0b..6d90ce073a 100644 --- a/src/drivers/qshell/posix/qshell.cpp +++ b/src/drivers/qshell/posix/qshell.cpp @@ -47,9 +47,19 @@ // Static variables px4::AppState QShell::appState; uint32_t QShell::_current_sequence{0}; +uORB::Subscription *QShell::_qshell_retval_sub{nullptr}; + int QShell::main(std::vector argList) { + if (_qshell_retval_sub == nullptr) { + _qshell_retval_sub = new uORB::Subscription(ORB_ID(qshell_retval)); + + if (_qshell_retval_sub == nullptr) { + PX4_ERR("Couldn't initialilze Qshell response subscription"); + } + } + int ret = _send_cmd(argList); if (ret != 0) { @@ -109,7 +119,7 @@ int QShell::_wait_for_retval() memset(&retval, 0, sizeof(qshell_retval_s)); while (hrt_elapsed_time(&time_started_us) < QSHELL_RESPONSE_WAIT_TIME_US) { - if (_qshell_retval_sub.update(&retval)) { + if (_qshell_retval_sub->update(&retval)) { if (retval.return_sequence != _current_sequence) { PX4_WARN("Ignoring return value with wrong sequence"); diff --git a/src/drivers/qshell/posix/qshell.h b/src/drivers/qshell/posix/qshell.h index 877b13de52..9202303663 100644 --- a/src/drivers/qshell/posix/qshell.h +++ b/src/drivers/qshell/posix/qshell.h @@ -58,7 +58,7 @@ private: uORB::Publication _qshell_req_pub{ORB_ID(qshell_req)}; - uORB::Subscription _qshell_retval_sub{ORB_ID(qshell_retval)}; + static uORB::Subscription *_qshell_retval_sub; static uint32_t _current_sequence; };