mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 04:41:35 +08:00
Qshell static subscription (#21081)
* Changed QShell uorb subscription to be static to avoid the duplicate sequence number error
This commit is contained in:
@@ -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");
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user