From 1b53ed35d9fa902efa898dd6d051eca52e85af08 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 25 Feb 2023 15:23:24 -0800 Subject: [PATCH] Fix Status Text option Status text messages were being sent too early in the creation of the MockLink. This would cause the ui to not see them. Making the whole thing useless for testing. --- src/comm/MockLink.cc | 16 ++++++++++------ src/comm/MockLink.h | 10 +++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/comm/MockLink.cc b/src/comm/MockLink.cc index 6203873..bd264e3 100644 --- a/src/comm/MockLink.cc +++ b/src/comm/MockLink.cc @@ -199,15 +199,23 @@ void MockLink::run(void) QTimer timer1HzTasks; QTimer timer10HzTasks; QTimer timer500HzTasks; + QTimer timerStatusText; - QObject::connect(&timer1HzTasks, &QTimer::timeout, this, &MockLink::_run1HzTasks); - QObject::connect(&timer10HzTasks, &QTimer::timeout, this, &MockLink::_run10HzTasks); + QObject::connect(&timer1HzTasks, &QTimer::timeout, this, &MockLink::_run1HzTasks); + QObject::connect(&timer10HzTasks, &QTimer::timeout, this, &MockLink::_run10HzTasks); QObject::connect(&timer500HzTasks, &QTimer::timeout, this, &MockLink::_run500HzTasks); + QObject::connect(&timerStatusText, &QTimer::timeout, this, &MockLink::_sendStatusTextMessages); timer1HzTasks.start(1000); timer10HzTasks.start(100); timer500HzTasks.start(2); + // Wait a little bit for the ui to finish loading up before sending out status text messages + if (_sendStatusText) { + timerStatusText.setSingleShot(true); + timerStatusText.start(10000); + } + // Send first set right away _run1HzTasks(); _run10HzTasks(); @@ -242,10 +250,6 @@ void MockLink::_run1HzTasks(void) } else { _sendHomePosition(); } - if (_sendStatusText) { - _sendStatusText = false; - _sendStatusTextMessages(); - } } } } diff --git a/src/comm/MockLink.h b/src/comm/MockLink.h index a729fb0..d1b4e64 100644 --- a/src/comm/MockLink.h +++ b/src/comm/MockLink.h @@ -189,10 +189,11 @@ private slots: // LinkInterface overrides void _writeBytes(const QByteArray bytes) final; - void _writeBytesQueued(const QByteArray bytes); - void _run1HzTasks(void); - void _run10HzTasks(void); - void _run500HzTasks(void); + void _writeBytesQueued (const QByteArray bytes); + void _run1HzTasks (void); + void _run10HzTasks (void); + void _run500HzTasks (void); + void _sendStatusTextMessages(void); private: // LinkInterface overrides @@ -232,7 +233,6 @@ private: void _sendVibration (void); void _sendSysStatus (void); void _sendBatteryStatus (void); - void _sendStatusTextMessages (void); void _sendChunkedStatusText (uint16_t chunkId, bool missingChunks); void _respondWithAutopilotVersion (void); void _sendRCChannels (void);