Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ping360flash-supplemental: various changes + fixes #1069

Closed
wants to merge 7 commits into from
16 changes: 13 additions & 3 deletions qml/DeviceManagerViewer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions qml/FirmwareUpdate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion src/flash/flasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -122,6 +125,6 @@ class Flasher : public QObject {
LinkConfiguration _link;
QString _message;
States _state = Idle;
const QList<int> _validBaudRates = {57600, 115200, 230400};
const QList<QVariant> _validBaudRates = {57600, 115200, 230400};
bool _verify = true;
};
15 changes: 7 additions & 8 deletions src/sensor/ping360.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 5 additions & 2 deletions src/sensor/protocoldetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/sensor/protocoldetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <QThread>

#include "abstractlink.h"
#include "linkconfiguration.h"
#include "pingparserext.h"

Expand Down
Loading