From f2dc975d9f9614d0fccf82fb5124085776b3e12e Mon Sep 17 00:00:00 2001 From: Nffj84 Date: Wed, 3 Jul 2024 13:10:27 +0300 Subject: [PATCH] Minor improvements --- misc/camera/a8/a8.pro | 4 ++-- misc/camera/a8/remoteControl.cpp | 19 +++++++++++-------- misc/camera/a8/serialResponse.cpp | 3 ++- misc/camera/a8_remote/.gitignore | 3 +++ misc/camera/a8_remote/remoteControl.cpp | 4 ++++ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/misc/camera/a8/a8.pro b/misc/camera/a8/a8.pro index 08a4511..7fe3a64 100644 --- a/misc/camera/a8/a8.pro +++ b/misc/camera/a8/a8.pro @@ -6,8 +6,8 @@ CONFIG += c++17 console TARGET = a8 -QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum -QMAKE_LFLAGS = -O0 -g -ggdb -fsanitize=undefined,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum +QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum +QMAKE_LFLAGS = -O0 -g -ggdb -fsanitize=address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum QMAKE_CXX = clang++ QMAKE_CC = clang diff --git a/misc/camera/a8/remoteControl.cpp b/misc/camera/a8/remoteControl.cpp index 3442294..8673e4e 100644 --- a/misc/camera/a8/remoteControl.cpp +++ b/misc/camera/a8/remoteControl.cpp @@ -83,14 +83,17 @@ void RemoteControl::sendResponse(void) { QJsonDocument responseDocument(mResponseObject); std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString(); - write(mFifoFdOut, response.c_str(), response.size()); - qDebug().noquote().nospace() << "Sent: " << response; + qDebug().noquote().nospace() << "Sending responce: " << response; + + write(mFifoFdOut, response.c_str(), response.size()); mIsBusy = false; } void RemoteControl::restoreOrientation(void) { + qDebug().noquote().nospace() << "Restoring orientation"; + QByteArray serialCommandAngle = Config::getCommand()->getCommandForInternal(COMMAND_ID::TURN_TO_DEGREES); int16_t degreesVal = Config::getCurrentYaw() * 10; @@ -100,7 +103,6 @@ void RemoteControl::restoreOrientation(void) serialCommandAngle[10] = degreesVal & 0xFF; serialCommandAngle[11] = degreesVal >> 8; - qDebug().noquote().nospace() << serialCommandAngle; Config::getSerial()->sendCommand(serialCommandAngle); QTimer::singleShot(1000, this, [this]() mutable { sendResponse(); }); @@ -108,6 +110,8 @@ void RemoteControl::restoreOrientation(void) void RemoteControl::restoreZoom(void) { + qDebug().noquote().nospace() << "Restoring zoom"; + QByteArray serialCommandZoom = Config::getCommand()->getCommandForInternal(COMMAND_ID::ZOOM_TO_X); uint8_t integerPart = static_cast(Config::getCurrentZoom()); @@ -117,7 +121,6 @@ void RemoteControl::restoreZoom(void) serialCommandZoom[8] = integerPart; serialCommandZoom[9] = scaledFractional; - qDebug().noquote().nospace() << serialCommandZoom.toStdString(); Config::getSerial()->sendCommand(serialCommandZoom); QTimer::singleShot(3000, this, [this]() mutable { restoreOrientation(); }); @@ -125,7 +128,7 @@ void RemoteControl::restoreZoom(void) void RemoteControl::calculateTargetPosition(QJsonObject &commandObject) { - qDebug().noquote().nospace() << "Calculating?"; + qDebug().noquote().nospace() << "Getting target location"; float latitude = commandObject["latitude"].toDouble(); float longitude = commandObject["longitude"].toDouble(); @@ -147,7 +150,7 @@ void RemoteControl::calculateTargetPosition(QJsonObject &commandObject) void RemoteControl::turnToTarget(QJsonObject &commandObject) { - qDebug().noquote().nospace() << "Turning?"; + qDebug().noquote().nospace() << "Turning to target"; uint16_t targetX = commandObject["target_x"].toInt(); uint16_t targetY = commandObject["target_y"].toInt(); @@ -173,7 +176,7 @@ void RemoteControl::turnToTarget(QJsonObject &commandObject) void RemoteControl::zoomToTarget(QJsonObject &commandObject) { - qDebug().noquote().nospace() << "Zooming?"; + qDebug().noquote().nospace() << "Zooming to target"; float fillRatio = 0.5; float targetPixelWidth = commandObject["target_pixel_width"].toInt(); @@ -229,7 +232,7 @@ void RemoteControl::run() // Exit with exit message if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") { - return; + exit(EXIT_SUCCESS); } mIsBusy = true; diff --git a/misc/camera/a8/serialResponse.cpp b/misc/camera/a8/serialResponse.cpp index acb196d..638b8e9 100644 --- a/misc/camera/a8/serialResponse.cpp +++ b/misc/camera/a8/serialResponse.cpp @@ -35,7 +35,8 @@ QHash SerialResponse::getResponceValues(QByteArray response) QHash results; if (response.size() == 0) { - qCritical().noquote().nospace() << "Response is empty, exiting..."; + qWarning().noquote().nospace() << "Response is empty, exiting..."; + return results; } // Check response data validity diff --git a/misc/camera/a8_remote/.gitignore b/misc/camera/a8_remote/.gitignore index 4a0b530..9e5d99a 100644 --- a/misc/camera/a8_remote/.gitignore +++ b/misc/camera/a8_remote/.gitignore @@ -72,3 +72,6 @@ CMakeLists.txt.user* *.dll *.exe +# Folders +build/ + diff --git a/misc/camera/a8_remote/remoteControl.cpp b/misc/camera/a8_remote/remoteControl.cpp index c8eb814..afe5a98 100644 --- a/misc/camera/a8_remote/remoteControl.cpp +++ b/misc/camera/a8_remote/remoteControl.cpp @@ -103,6 +103,10 @@ void RemoteControl::startCommunication() write(mFifoFdOut, command.c_str(), command.size()); qDebug().noquote().nospace() << "Sent: " << command; + if (commandObject["extra"] == "EXIT") { + exit(EXIT_SUCCESS); + } + while (true) { char buffer[1024]; ssize_t bytesRead = read(mFifoFdIn, buffer, sizeof(buffer) - 1);