No need to load plugin, as DCPlugin directly included

This commit is contained in:
Gerhard Hoffmann 2023-04-11 15:38:04 +02:00
parent 8cf2141916
commit c000971f14

View File

@ -9,22 +9,25 @@
#include "commands_to_update_dc.h" #include "commands_to_update_dc.h"
#include "plugins/interfaces.h" #include "plugins/interfaces.h"
#include "DCPlugin/include/hwapi.h"
#include <unistd.h> #include <unistd.h>
#include <thread> #include <thread>
#include <memory>
static void updateDC(hwinf const *hw) { //static void updateDC(hwinf const *hw) {
qDebug() << "ENTER"; static void updateDC(std::unique_ptr<hwinf> hw,
//return; char const *fileToSendToDC,
for (int i=0; i< 1;++i) { char const *baudrate,
hw->dc_updateDC("dc2c4.bin", "115200", "ttymxc2"); char const *serialInterface) {
for (int i=0; i < 1;++i) {
hw->dc_updateDC(fileToSendToDC, baudrate, serialInterface);
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); std::this_thread::sleep_for(std::chrono::milliseconds(3000));
} }
qDebug() << "LEAVE";
QCoreApplication::quit(); QCoreApplication::quit();
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[]) {
{
QApplication a(argc, argv); QApplication a(argc, argv);
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
@ -33,15 +36,17 @@ int main(int argc, char *argv[])
//setDebugLevel(QtMsgType::QtDebugMsg); //setDebugLevel(QtMsgType::QtDebugMsg);
} }
DCPlugin plugin; if (argc > 2) {
hwinf const* hw = plugin.loadPlugin(); qCritical() << "Usage: " << argv[0] << "<file to send to dc>";
if (!hw) {
qCritical() << "Cannot load plugin";
return -1; return -1;
} }
std::thread t(updateDC, hw); std::unique_ptr<hwinf> hw(new hwapi());
#ifdef PTU5
std::thread t(updateDC, std::move(hw), argv[1], "115200", "ttymxc2");
#else
std::thread t(updateDC, std::move(hw), "dc2c4.bin", "115200", "ttyUSB0");
#endif
int ret = a.exec(); int ret = a.exec();
t.join(); t.join();
return ret; return ret;