diff --git a/groundStation/gui/MicroCART/crazyflieworker.cpp b/groundStation/gui/MicroCART/crazyflieworker.cpp index 33cecb732a25b8a462801d15fb9ed7eb923426da..b34028768179406367bad14b4fd1666c937f09c0 100644 --- a/groundStation/gui/MicroCART/crazyflieworker.cpp +++ b/groundStation/gui/MicroCART/crazyflieworker.cpp @@ -63,6 +63,9 @@ void CrazyflieWorker::connectBackend() } } emit(gotActiveLogVariables(activeVars)); + std::string realLogfile = getLogFile(0); + QString qLogfile(realLogfile.c_str()); + emit(gotLogFile(qLogfile)); } /** @@ -99,7 +102,7 @@ void CrazyflieWorker::setCurrAttRateSetpoint(float rollRate, float pitchRate, fl } void CrazyflieWorker::setCurrMixedSetpoint(float roll, float pitch, float yawRate, float throttle){ - qInfo() << "set rate"; + //qInfo() << "set rate"; currMixedSetpoint.roll = roll; currMixedSetpoint.pitch = pitch; currMixedSetpoint.yaw = yawRate; @@ -112,7 +115,7 @@ void CrazyflieWorker::sendAttRateSetpoint() { if(isBackendConnected){ - qInfo() << " send att rate" << currAttitudeRateSetpoint.throttle << " " << currAttitudeRateSetpoint.roll; + //qInfo() << " send att rate" << currAttitudeRateSetpoint.throttle << " " << currAttitudeRateSetpoint.roll; struct frontend_override_data data; data.enable = 2; //attitude rate @@ -134,7 +137,7 @@ void CrazyflieWorker::sendAttSetpoint() { if(isBackendConnected){ - qInfo() << " send att" << currAttitudeSetpoint.throttle; + //qInfo() << " send att" << currAttitudeSetpoint.throttle; struct frontend_override_data data; data.enable = 1; //attitude @@ -164,7 +167,7 @@ void CrazyflieWorker::sendMixedAttSetpoint(){ data.pitch = currMixedSetpoint.pitch; data.yaw = currMixedSetpoint.yaw; - qInfo() << "send mixed setpoint" << "roll:" << data.roll << " pitch:" << data.pitch; + //qInfo() << "send mixed setpoint" << "roll:" << data.roll << " pitch:" << data.pitch; //send setpoint diff --git a/groundStation/gui/MicroCART/crazyflieworker.h b/groundStation/gui/MicroCART/crazyflieworker.h index 3e57d4fee11407934ae72f4f35a7845d49f80766..a68502486b6b1d15fc3e25af4fd7ba3e379681e8 100644 --- a/groundStation/gui/MicroCART/crazyflieworker.h +++ b/groundStation/gui/MicroCART/crazyflieworker.h @@ -55,6 +55,7 @@ signals: void changeLogBlock_comboBox(QStringList logBlockNames); void gotBlockisEnabled(bool isEnabled); void gotActiveLogVariables(QStringList activeVars); + void gotLogFile(QString filename); void connected(); void disconnected(); diff --git a/groundStation/gui/MicroCART/logworker.cpp b/groundStation/gui/MicroCART/logworker.cpp index 745c5b4a8fc89f05bbced0554e3539645c79bb27..37d3f98aa5936537e0c09b427630e166c1fa0daa 100644 --- a/groundStation/gui/MicroCART/logworker.cpp +++ b/groundStation/gui/MicroCART/logworker.cpp @@ -26,19 +26,6 @@ void LogWorker::connectBackend() } else { qInfo() << "Attempted to connect crazyflieworker when already connected!"; } - startReadingLogFile(); -} - -std::string LogWorker::getLogFile(int type) { - struct frontend_getlogfile_data logfile; - char fname[256]; - logfile.command = type; - logfile.name = fname; - if(frontend_getlogfile(conn, &logfile)) { - return ""; - } - std::string result(logfile.name, strlen(logfile.name)); - return result; } /** @@ -56,10 +43,10 @@ void LogWorker::disconnectBackend() } } -void LogWorker::startReadingLogFile() { - std::string filename = getLogFile(0); +void LogWorker::startLogging(QString filename) { + std::string logFileName = filename.toStdString(); std::ifstream logFile; - logFile.open(filename.c_str()); + logFile.open(logFileName.c_str()); //std::streamoff p = 0; std::string line; @@ -87,5 +74,6 @@ void LogWorker::startReadingLogFile() { break; } logFile.clear(); + usleep(500000); } } \ No newline at end of file diff --git a/groundStation/gui/MicroCART/logworker.h b/groundStation/gui/MicroCART/logworker.h index 0341c29b59a1b8b37d68bfea5a46e6eb4921776e..a59d06b90eca3a562c72daa760719939ad4f0189 100644 --- a/groundStation/gui/MicroCART/logworker.h +++ b/groundStation/gui/MicroCART/logworker.h @@ -35,11 +35,10 @@ signals: public slots: void connectBackend(); void disconnectBackend(); + void startLogging(QString filename); private: struct backend_conn * conn; - void startReadingLogFile(); - std::string getLogFile(int type); }; #endif // LOGWORKER_H diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index c82b64746506b02f729d70a9f53cfa6a198cb0e4..97219d0503733705ed8d31716971bd4d810c05f1 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -131,6 +131,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(crazyflieWorker, SIGNAL (gotLogBlockID(int, int8_t)), this, SLOT(useLogBlockID(int, int8_t))); connect(crazyflieWorker, SIGNAL (changeLogBlock_comboBox(QStringList)), SLOT(gotLogBlockNames(QStringList))); connect(crazyflieWorker, SIGNAL (gotActiveLogVariables(QStringList)), this, SLOT(fillLogVariablesBox(QStringList))); + connect(crazyflieWorker, SIGNAL (gotLogFile(QString)), this, SLOT (receiveLogFile(QString))); + connect(this, SIGNAL (beginReadingLogFile(QString)), logWorker, SLOT(startLogging(QString))); connect(this, SIGNAL (rateSetpointSignal(float, float, float, float)), crazyflieWorker, SLOT (setCurrAttRateSetpoint(float, float, float, float))); connect(this, SIGNAL (angleSetpointSignal(float, float, float, float)), crazyflieWorker, SLOT (setCurrAttSetpoint(float, float, float, float))); @@ -1462,3 +1464,6 @@ void MainWindow::on_pb_stopLog_clicked() graphLogs(test); } +void MainWindow::receiveLogFile(QString filename) { + emit(beginReadingLogFile(filename)); +} diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h index 660cbef6b199234d1364db6ad2c07ff1a4767477..7be700dd35c1a7a28dbd4dcb17b04ab94ee541b5 100644 --- a/groundStation/gui/MicroCART/mainwindow.h +++ b/groundStation/gui/MicroCART/mainwindow.h @@ -42,6 +42,7 @@ signals: void getLogValues(QString log1, QString log2, QString log3, QString log4, QString log5); void sendLogBlockCommand(int8_t command, int8_t id); void requestLogBlockID(QString name, int8_t command); + void beginReadingLogFile(QString name); private slots: void on_pbStart_clicked(); @@ -171,6 +172,8 @@ private slots: void getLogEntryBoxChange3(QString text); void getLogEntryBoxChange4(QString text); void getLogEntryBoxChange5(QString text); + void receiveLogFile(QString filename); + void on_pb_stopLog_clicked();