Qshell static subscription (#21081)

* Changed QShell uorb subscription to be static to avoid the duplicate sequence number error
This commit is contained in:
Eric Katzfey
2023-02-07 17:18:01 -05:00
committed by GitHub
parent 7b3befded5
commit db24c2b233
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -47,9 +47,19 @@
// Static variables // Static variables
px4::AppState QShell::appState; px4::AppState QShell::appState;
uint32_t QShell::_current_sequence{0}; uint32_t QShell::_current_sequence{0};
uORB::Subscription *QShell::_qshell_retval_sub{nullptr};
int QShell::main(std::vector<std::string> argList) int QShell::main(std::vector<std::string> 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); int ret = _send_cmd(argList);
if (ret != 0) { if (ret != 0) {
@@ -109,7 +119,7 @@ int QShell::_wait_for_retval()
memset(&retval, 0, sizeof(qshell_retval_s)); memset(&retval, 0, sizeof(qshell_retval_s));
while (hrt_elapsed_time(&time_started_us) < QSHELL_RESPONSE_WAIT_TIME_US) { 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) { if (retval.return_sequence != _current_sequence) {
PX4_WARN("Ignoring return value with wrong sequence"); PX4_WARN("Ignoring return value with wrong sequence");
+1 -1
View File
@@ -58,7 +58,7 @@ private:
uORB::Publication<qshell_req_s> _qshell_req_pub{ORB_ID(qshell_req)}; uORB::Publication<qshell_req_s> _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; static uint32_t _current_sequence;
}; };