Added sendData function call to remote main.

Commented out more things that are currently not needed.
This commit is contained in:
Nffj84
2024-07-03 16:10:24 +03:00
parent 3e0841b0ca
commit 0b4b2f9f10
4 changed files with 24 additions and 6 deletions
+9
View File
@@ -5,6 +5,14 @@
#include <QString> #include <QString>
#include <QThread> #include <QThread>
struct RectangleProperties
{
uint16_t width;
uint16_t height;
uint16_t middleX;
uint16_t middleY;
};
class RemoteControl : public QObject class RemoteControl : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -21,6 +29,7 @@ private slots:
void zoomToTarget(QJsonObject &commandObject); void zoomToTarget(QJsonObject &commandObject);
void restoreOrientation(void); void restoreOrientation(void);
void restoreZoom(void); void restoreZoom(void);
RectangleProperties calculateRectangleProperties(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right);
private: private:
void openNamedPipe(void); void openNamedPipe(void);
+5 -3
View File
@@ -6,8 +6,10 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
RemoteControl remoteControl; RemoteControl remoteControl;
remoteControl.createNamedPipe(); #ifdef FIFO_TEST
remoteControl.startCommunication(); remoteControl.startTest();
#else
remoteControl.sendData(200, 200, 400, 400);
#endif
return 0; return 0;
} }
+8 -1
View File
@@ -13,13 +13,18 @@
#include <random> #include <random>
#endif #endif
RemoteControl::RemoteControl() {} RemoteControl::RemoteControl()
{
createNamedPipe();
}
RemoteControl::~RemoteControl() RemoteControl::~RemoteControl()
{ {
#ifdef FIFO_TEST
if (mFifoFdIn != -1) { if (mFifoFdIn != -1) {
close(mFifoFdIn); close(mFifoFdIn);
} }
#endif
if (mFifoFdOut != -1) { if (mFifoFdOut != -1) {
close(mFifoFdOut); close(mFifoFdOut);
} }
@@ -29,6 +34,7 @@ void RemoteControl::createNamedPipe()
{ {
struct stat statBuf; struct stat statBuf;
#ifdef FIFO_TEST
// Open incoming pipe (READ ONLY) // Open incoming pipe (READ ONLY)
if (stat(FIFO_FROM_GIMBAL, &statBuf) == 0) { if (stat(FIFO_FROM_GIMBAL, &statBuf) == 0) {
if (S_ISFIFO(statBuf.st_mode)) { if (S_ISFIFO(statBuf.st_mode)) {
@@ -51,6 +57,7 @@ void RemoteControl::createNamedPipe()
} else { } else {
qInfo().noquote().nospace() << "Opened pipe: " << FIFO_FROM_GIMBAL; qInfo().noquote().nospace() << "Opened pipe: " << FIFO_FROM_GIMBAL;
} }
#endif
// Open outgoing pipe (WRITE ONLY) // Open outgoing pipe (WRITE ONLY)
if (stat(FIFO_TO_GIMBAL, &statBuf) == 0) { if (stat(FIFO_TO_GIMBAL, &statBuf) == 0) {
+2 -2
View File
@@ -12,16 +12,16 @@ class RemoteControl
public: public:
RemoteControl(); RemoteControl();
~RemoteControl(); ~RemoteControl();
void createNamedPipe(void);
void sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right); void sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right);
#ifdef FIFO_TEST #ifdef FIFO_TEST
void startTest(void); void startTest(void);
#endif #endif
private: private:
void createNamedPipe(void);
#ifdef FIFO_TEST #ifdef FIFO_TEST
float randomFloatBetween(float min, float max); float randomFloatBetween(float min, float max);
#endif
int mFifoFdIn; int mFifoFdIn;
#endif
int mFifoFdOut; int mFifoFdOut;
}; };