#include #include #include #include #include #include "message_handler.h" #include "interfaces.h" #include "DCPlugin/include/hwapi.h" #include #include #include #ifdef PTU5 #define SERIAL_PORT "ttymxc2" #else #define SERIAL_PORT "ttyUSB0" #endif static void updateBinary(std::unique_ptr hw, // update d2dc*.bin 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)); } QCoreApplication::quit(); } static void updatePrinterConf(std::unique_ptr hw, // update printer-file int nrOfTemplate, char const *fileToSendToDC) { for (int i=0; i < 1;++i) { hw->dc_updatePrinterTemplate(hwapi::FileTypeJson::PRINTER, nrOfTemplate, fileToSendToDC); } QCoreApplication::quit(); } // argv[1]: file to send to dc int main(int argc, char *argv[]) { QApplication a(argc, argv); if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling atbInstallMessageHandler(atbDebugOutput); setDebugLevel(QtMsgType::QtDebugMsg); //setDebugLevel(QtMsgType::QtDebugMsg); } if (argc > 2) { qCritical() << "Usage: " << argv[0] << ""; return -1; } std::unique_ptr hw(new hwapi()); QFileInfo fileInfo(argv[1]); QString fname(fileInfo.fileName()); int ret = 0; if (fname.startsWith("dc") && fname.endsWith(".bin")) { std::thread t(updateBinary, std::move(hw), fname.toStdString().c_str(), "115200", SERIAL_PORT); ret = a.exec(); t.join(); } else if (fname.startsWith("DC2C_print") && fname.endsWith(".json")) { std::thread t(updatePrinterConf, std::move(hw), fname.midRef(10, 2).toInt(), fname.toStdString().c_str()); ret = a.exec(); t.join(); } return ret; }