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 <QThread>
struct RectangleProperties
{
uint16_t width;
uint16_t height;
uint16_t middleX;
uint16_t middleY;
};
class RemoteControl : public QObject
{
Q_OBJECT
@@ -21,6 +29,7 @@ private slots:
void zoomToTarget(QJsonObject &commandObject);
void restoreOrientation(void);
void restoreZoom(void);
RectangleProperties calculateRectangleProperties(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right);
private:
void openNamedPipe(void);
+5 -3
View File
@@ -6,8 +6,10 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
RemoteControl remoteControl;
remoteControl.createNamedPipe();
remoteControl.startCommunication();
#ifdef FIFO_TEST
remoteControl.startTest();
#else
remoteControl.sendData(200, 200, 400, 400);
#endif
return 0;
}
+8 -1
View File
@@ -13,13 +13,18 @@
#include <random>
#endif
RemoteControl::RemoteControl() {}
RemoteControl::RemoteControl()
{
createNamedPipe();
}
RemoteControl::~RemoteControl()
{
#ifdef FIFO_TEST
if (mFifoFdIn != -1) {
close(mFifoFdIn);
}
#endif
if (mFifoFdOut != -1) {
close(mFifoFdOut);
}
@@ -29,6 +34,7 @@ void RemoteControl::createNamedPipe()
{
struct stat statBuf;
#ifdef FIFO_TEST
// Open incoming pipe (READ ONLY)
if (stat(FIFO_FROM_GIMBAL, &statBuf) == 0) {
if (S_ISFIFO(statBuf.st_mode)) {
@@ -51,6 +57,7 @@ void RemoteControl::createNamedPipe()
} else {
qInfo().noquote().nospace() << "Opened pipe: " << FIFO_FROM_GIMBAL;
}
#endif
// Open outgoing pipe (WRITE ONLY)
if (stat(FIFO_TO_GIMBAL, &statBuf) == 0) {
+2 -2
View File
@@ -12,16 +12,16 @@ class RemoteControl
public:
RemoteControl();
~RemoteControl();
void createNamedPipe(void);
void sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right);
#ifdef FIFO_TEST
void startTest(void);
#endif
private:
void createNamedPipe(void);
#ifdef FIFO_TEST
float randomFloatBetween(float min, float max);
#endif
int mFifoFdIn;
#endif
int mFifoFdOut;
};