mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-23 03:06:34 +00:00
Small improvements.
This commit is contained in:
@@ -9,13 +9,13 @@ TARGET = a8
|
|||||||
QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,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_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,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=undefined,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=undefined,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_CXX = g++
|
||||||
#QMAKE_CC = clang
|
QMAKE_CC = gcc
|
||||||
|
|
||||||
# Not nice, but for some reason QtCreator doesn't use /usr/lib/ccache/g++ from the PATH
|
# Not nice, but for some reason QtCreator doesn't use /usr/lib/ccache/g++ from the PATH
|
||||||
linux-g++ {
|
linux-g++ {
|
||||||
# QMAKE_CXX = clang++
|
QMAKE_CXX = g++
|
||||||
# QMAKE_CC = clang
|
QMAKE_CC = gcc
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
@@ -84,9 +84,11 @@ void RemoteControl::sendResponse(void)
|
|||||||
QJsonDocument responseDocument(mResponseObject);
|
QJsonDocument responseDocument(mResponseObject);
|
||||||
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
|
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||||
|
|
||||||
// qDebug().noquote().nospace() << "Sending responce: " << response;
|
size_t bytesWritten = write(mFifoFdOut, response.c_str(), response.size());
|
||||||
|
if (bytesWritten < 1) {
|
||||||
write(mFifoFdOut, response.c_str(), response.size());
|
qWarning().noquote().nospace() << "Error writing response: " << bytesWritten;
|
||||||
|
}
|
||||||
|
qDebug().noquote().nospace() << "Responded: " << response;
|
||||||
mIsBusy = false;
|
mIsBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,22 +257,24 @@ void RemoteControl::run()
|
|||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
|
|
||||||
QJsonDocument commandDoc = QJsonDocument::fromJson(buffer);
|
QJsonDocument commandDoc = QJsonDocument::fromJson(buffer);
|
||||||
|
QString message = QString::fromUtf8(buffer);
|
||||||
|
|
||||||
// Ignore non json messages
|
// Ignore non json messages
|
||||||
if (commandDoc.isNull() == false) {
|
if (commandDoc.isNull() == false) {
|
||||||
|
qDebug().noquote().nospace() << "Received: " << message;
|
||||||
|
|
||||||
QJsonObject commandObject = commandDoc.object();
|
QJsonObject commandObject = commandDoc.object();
|
||||||
|
|
||||||
// Ignore own messages and messages that don't have sender
|
// Ignore messages that don't have sender
|
||||||
if (commandObject.contains("sender") == false || commandObject["sender"] == FIFO_WHO_AM_I) {
|
if (commandObject.contains("sender") == false) {
|
||||||
|
qDebug().noquote().nospace() << "No sender info: " << message;
|
||||||
mIsBusy = false;
|
mIsBusy = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString message = QString::fromUtf8(buffer);
|
|
||||||
qDebug().noquote().nospace() << "Received: " << message;
|
|
||||||
|
|
||||||
// Exit with exit message
|
// Exit with exit message
|
||||||
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
|
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
|
||||||
|
qDebug().noquote().nospace() << "Exit message received: Exiting...";
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,8 +300,6 @@ void RemoteControl::run()
|
|||||||
qInfo() << "target_pixel_height: " << commandObject["target_pixel_height"];
|
qInfo() << "target_pixel_height: " << commandObject["target_pixel_height"];
|
||||||
qInfo() << "target_pixel_width: " << commandObject["target_pixel_width"];
|
qInfo() << "target_pixel_width: " << commandObject["target_pixel_width"];
|
||||||
|
|
||||||
mIsBusy = true;
|
|
||||||
|
|
||||||
// Prepare responce object
|
// Prepare responce object
|
||||||
mResponseObject = QJsonObject();
|
mResponseObject = QJsonObject();
|
||||||
mResponseObject["sender"] = FIFO_WHO_AM_I;
|
mResponseObject["sender"] = FIFO_WHO_AM_I;
|
||||||
@@ -308,6 +310,7 @@ void RemoteControl::run()
|
|||||||
|
|
||||||
QTimer::singleShot(0, this, [this, commandObject]() mutable { turnToTarget(commandObject); });
|
QTimer::singleShot(0, this, [this, commandObject]() mutable { turnToTarget(commandObject); });
|
||||||
} else {
|
} else {
|
||||||
|
qDebug().noquote().nospace() << "Non JSON message received: " << message;
|
||||||
mIsBusy = false;
|
mIsBusy = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ TARGET = a8_remote
|
|||||||
QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,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_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,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=undefined,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=undefined,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_CXX = g++
|
||||||
QMAKE_CC = clang
|
QMAKE_CC = gcc
|
||||||
|
|
||||||
# Not nice, but for some reason QtCreator doesn't use /usr/lib/ccache/g++ from the PATH
|
# Not nice, but for some reason QtCreator doesn't use /usr/lib/ccache/g++ from the PATH
|
||||||
linux-g++ {
|
linux-g++ {
|
||||||
QMAKE_CXX = clang++
|
QMAKE_CXX = g++
|
||||||
QMAKE_CC = clang
|
QMAKE_CC = gcc
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
@@ -88,8 +88,11 @@ void RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint1
|
|||||||
QJsonObject commandObject = {{"sender", FIFO_WHO_AM_I}, {"top", top}, {"left", left}, {"bottom", bottom}, {"right", right}};
|
QJsonObject commandObject = {{"sender", FIFO_WHO_AM_I}, {"top", top}, {"left", left}, {"bottom", bottom}, {"right", right}};
|
||||||
QJsonDocument commandDocument(commandObject);
|
QJsonDocument commandDocument(commandObject);
|
||||||
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||||
write(mFifoFdOut, command.c_str(), command.size());
|
size_t bytesWritten = write(mFifoFdOut, command.c_str(), command.size());
|
||||||
//qDebug().noquote().nospace() << "Sent: " << command;
|
if (bytesWritten < 1) {
|
||||||
|
qWarning().noquote().nospace() << "Error writing data: " << bytesWritten;
|
||||||
|
}
|
||||||
|
qDebug().noquote().nospace() << "Sent: " << command;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FIFO_TEST
|
#ifdef FIFO_TEST
|
||||||
@@ -124,7 +127,10 @@ void RemoteControl::startTest()
|
|||||||
|
|
||||||
QJsonDocument commandDocument(commandObject);
|
QJsonDocument commandDocument(commandObject);
|
||||||
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString();
|
||||||
write(mFifoFdOut, command.c_str(), command.size());
|
size_t bytesWritten = write(mFifoFdOut, command.c_str(), command.size());
|
||||||
|
if (bytesWritten < 1) {
|
||||||
|
qWarning().noquote().nospace() << "Error writing data: " << bytesWritten;
|
||||||
|
}
|
||||||
qDebug().noquote().nospace() << "Sent: " << command;
|
qDebug().noquote().nospace() << "Sent: " << command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user