diff --git a/qml/DeviceManagerViewer.qml b/qml/DeviceManagerViewer.qml index 757965c57..5b5a49b23 100644 --- a/qml/DeviceManagerViewer.qml +++ b/qml/DeviceManagerViewer.qml @@ -21,7 +21,14 @@ PingPopup { closePolicy: Popup.NoAutoClose onVisibleChanged: { - visible ? DeviceManager.startDetecting() : DeviceManager.stopDetecting(); + print(stack.depth); + if (visible) { + if (stack.depth == 1) { + DeviceManager.startDetecting() + } + } else { + DeviceManager.stopDetecting(); + } } Component.onCompleted: { if (!DeviceManager.primarySensor) @@ -57,10 +64,13 @@ PingPopup { Layout.fillWidth: true onClicked: { print(stack.depth); - if (stack.depth == 1) + if (stack.depth == 1) { + DeviceManager.stopDetecting(); stack.push(connectionMenu); - else + } else { + DeviceManager.startDetecting(); stack.pop(); + } } } diff --git a/qml/FirmwareUpdate.qml b/qml/FirmwareUpdate.qml index 6901a09b8..d144a954e 100644 --- a/qml/FirmwareUpdate.qml +++ b/qml/FirmwareUpdate.qml @@ -70,8 +70,7 @@ RowLayout { PingComboBox { id: baudComboBox - // This should use the same values in Flasher::_validBaudRates - model: [57600, 115200, 230400] + model: ping.flasher.validBaudRates Layout.fillWidth: true visible: SettingsManager.debugMode } diff --git a/src/flash/flasher.h b/src/flash/flasher.h index 56ee4dd8b..1d7ac2d1f 100644 --- a/src/flash/flasher.h +++ b/src/flash/flasher.h @@ -72,6 +72,9 @@ class Flasher : public QObject { Flasher::States state() const { return _state; }; Q_PROPERTY(Flasher::States state READ state NOTIFY stateChanged) + const QVariantList& validBaudRates() const { return _validBaudRates; }; + Q_PROPERTY(QVariant validBaudRates READ validBaudRates CONSTANT); + /** * @brief Start the flash procedure * @@ -122,6 +125,6 @@ class Flasher : public QObject { LinkConfiguration _link; QString _message; States _state = Idle; - const QList _validBaudRates = {57600, 115200, 230400}; + const QList _validBaudRates = {57600, 115200, 230400}; bool _verify = true; }; diff --git a/src/sensor/ping360.cpp b/src/sensor/ping360.cpp index cd1bbff08..f5f1e064b 100644 --- a/src/sensor/ping360.cpp +++ b/src/sensor/ping360.cpp @@ -681,13 +681,12 @@ Ping360::~Ping360() { updateSensorConfigurationSettings(); - // TODO: Find a better way - // Force sensor to stop sensor if running with anything different from Legacy mode - // The sensor will stop any automatic behaviour when receiving a normal profile request message - if (_profileRequestLogic.type != Ping360RequestStateStruct::Type::Legacy) { - for (int i {0}; i < 10; i++) { - deltaStep(0); - QThread::msleep(100); - } + ping360_motor_off message; + message.updateChecksum(); + + // Stop scanning and turn off the stepper motor + for (int i {0}; i < 10; i++) { + writeMessage(message); + QThread::msleep(100); } } diff --git a/src/sensor/protocoldetector.cpp b/src/sensor/protocoldetector.cpp index 7f0464fd9..a34fb0c19 100644 --- a/src/sensor/protocoldetector.cpp +++ b/src/sensor/protocoldetector.cpp @@ -206,7 +206,7 @@ bool ProtocolDetector::checkUdp(LinkConfiguration& linkConf) int attempts = 0; - // Try to get a valid response, timeout after 10 * 50 ms + // Try to get a valid response, timeout after 20 * 50 ms while (_active && !_detected && attempts++ < 20) { socket.waitForReadyRead(50); /** @@ -234,7 +234,10 @@ bool ProtocolDetector::checkUdp(LinkConfiguration& linkConf) bool ProtocolDetector::checkBuffer(const QByteArray& buffer, LinkConfiguration& linkConf) { - qCDebug(PING_PROTOCOL_PROTOCOLDETECTOR) << buffer; + if (buffer.isEmpty()) { + return false; + } + qCDebug(PING_PROTOCOL_PROTOCOLDETECTOR) << "received buffer:" << buffer; for (const auto& byte : buffer) { if (_parser.parseByte(byte) == Parser::NEW_MESSAGE) { // Print information from detected devices diff --git a/src/sensor/protocoldetector.h b/src/sensor/protocoldetector.h index f39bfcf59..a8773aba0 100644 --- a/src/sensor/protocoldetector.h +++ b/src/sensor/protocoldetector.h @@ -2,7 +2,6 @@ #include -#include "abstractlink.h" #include "linkconfiguration.h" #include "pingparserext.h"