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 "plugins/interfaces.h"
#include "DCPlugin/include/hwapi.h"
#include <unistd.h>
#include <thread>
#include <memory>
static void updateDC(hwinf const *hw) {
qDebug() << "ENTER";
//return;
for (int i=0; i< 1;++i) {
hw->dc_updateDC("dc2c4.bin", "115200", "ttymxc2");
//static void updateDC(hwinf const *hw) {
static void updateDC(std::unique_ptr<hwinf> hw,
char const *fileToSendToDC,
char const *baudrate,
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));
}
qDebug() << "LEAVE";
QCoreApplication::quit();
}
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
@ -33,15 +36,17 @@ int main(int argc, char *argv[])
//setDebugLevel(QtMsgType::QtDebugMsg);
}
DCPlugin plugin;
hwinf const* hw = plugin.loadPlugin();
if (!hw) {
qCritical() << "Cannot load plugin";
if (argc > 2) {
qCritical() << "Usage: " << argv[0] << "<file to send to dc>";
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();
t.join();
return ret;