Compare commits
5 Commits
3069c3bd65
...
ec08e04f2c
Author | SHA1 | Date | |
---|---|---|---|
ec08e04f2c | |||
b26b65ee76 | |||
674b572da5 | |||
9a6ac85f99 | |||
ae582b75d5 |
@ -1,7 +1,6 @@
|
||||
QT += core gui
|
||||
QT += widgets serialport network
|
||||
QT += core serialport
|
||||
|
||||
TARGET = ATBDownloadDCFirmware
|
||||
TARGET = ATBUpdateDC
|
||||
|
||||
VERSION="0.1.0"
|
||||
win32 {
|
||||
@ -77,21 +76,23 @@ contains( CONFIG, DesktopLinux ) {
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
../common/src/message_handler.cpp \
|
||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||
update.cpp \
|
||||
dc_download.cpp \
|
||||
../common/src/System.cpp
|
||||
../common/src/System.cpp \
|
||||
../common/src/utils_internal.cpp \
|
||||
../common/src/command.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
../common/include/message_handler.h \
|
||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||
update.h \
|
||||
dc_download.h \
|
||||
../common/include/System.h
|
||||
../common/include/System.h \
|
||||
../common/include/utils_internal.h \
|
||||
../common/include/command.h
|
||||
|
||||
|
||||
OTHER_FILES += \
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QProcess>
|
||||
@ -16,7 +15,6 @@
|
||||
#include "commandline_parser.h"
|
||||
#include "utils.h"
|
||||
#include "update.h"
|
||||
#include "mainwindow.h"
|
||||
#include "System.h"
|
||||
|
||||
#include <DeviceController/interfaces.h>
|
||||
@ -54,9 +52,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
openlog("DC", LOG_PERROR | LOG_CONS, LOG_USER);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setApplicationName("ATBDownloadDCFirmware");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
QCoreApplication a(argc, argv);
|
||||
QCoreApplication::setApplicationName("ATBDownloadDCFirmware");
|
||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
atbInstallMessageHandler(atbDebugOutput);
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QStatusBar>
|
||||
#include <QWidget>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
@ -147,6 +149,35 @@ Update::~Update() {
|
||||
unloadDCPlugin();
|
||||
}
|
||||
|
||||
bool Update::openSerialPort() {
|
||||
// const SettingsDialog::Settings p = m_settings->settings();
|
||||
m_serial->setPortName(SERIAL_PORT);
|
||||
m_serial->setBaudRate(QSerialPort::Baud115200);
|
||||
m_serial->setDataBits(QSerialPort::DataBits::Data8);
|
||||
m_serial->setParity(QSerialPort::Parity::NoParity);
|
||||
m_serial->setStopBits(QSerialPort::StopBits::OneStop);
|
||||
m_serial->setFlowControl(QSerialPort::FlowControl::NoFlowControl);
|
||||
if (m_serial->open(QIODevice::ReadWrite)) {
|
||||
//showStatusMessage(tr("Connected to %1 : %2, %3, %4, %5, %6")
|
||||
// .arg(p.name, p.stringBaudRate, p.stringDataBits,
|
||||
// p.stringParity, p.stringStopBits, p.stringFlowControl));
|
||||
return true;
|
||||
} else {
|
||||
//QMessageBox::critical(this, tr("Error"), m_serial->errorString());
|
||||
//showStatusMessage(tr("Open error"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::closeSerialPort() {
|
||||
if (m_serial->isOpen()) {
|
||||
m_serial->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
//showStatusMessage(tr("Disconnected"));
|
||||
}
|
||||
|
||||
Update::DownloadResult Update::sendStatus(int ret) const {
|
||||
switch (ret) { // return values of dc are:
|
||||
case 0: // 0: no answer by now
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
class QSerialPort;
|
||||
class Update : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -46,6 +47,12 @@ class Update : public QObject {
|
||||
return QStringLiteral("+%1s").arg(secs, 7, 'f', 2, QChar('0'));
|
||||
}
|
||||
|
||||
|
||||
bool openSerialPort();
|
||||
bool closeSerialPort();
|
||||
|
||||
QSerialPort *m_serial;
|
||||
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
|
||||
|
@ -90,5 +90,5 @@ int main(int argc, char **argv) {
|
||||
if (ret == 0) {
|
||||
ret = SyncCommand().exec("rsync", options << optInRepo << "/opt");
|
||||
}
|
||||
return ret;
|
||||
return (ret > 0) ? -ret : ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user