diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 13179b1e..a870b8ca 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -26,45 +26,46 @@ { "name": "Linux", "includePath": [ - "/usr/local/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "${VSCP_ROOT}/src/**", - "${workspaceFolder}/", - "${workspaceFolder}/src/", - "${workspaceFolder}/common/", - "${workspaceFolder}/common/third_party/", - "${workspaceFolder}/common/third_party/nlohmann/", - "${workspaceFolder}/common/third_party/spdlog-1.9.2/include", - "${workspaceFolder}/common/third_party/sqlite3-3.35.4/", - "${workspaceFolder}/common/third_party/duktape-2.6.0/", - "${workspaceFolder}/common/third_party/fastpbkdf2-1.0.0/", - "${workspaceFolder}/../vscp/src/common", - "${workspaceFolder}/../vscp/src/vscp/common" + "/usr/local/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${VSCP_ROOT}/src/**", + "${workspaceFolder}/", + "${workspaceFolder}/src/", + "${workspaceFolder}/common/", + "${workspaceFolder}/common/third_party/", + "${workspaceFolder}/common/third_party/nlohmann/", + "${workspaceFolder}/common/third_party/spdlog-1.9.2/include", + "${workspaceFolder}/common/third_party/sqlite3-3.35.4/", + "${workspaceFolder}/common/third_party/duktape-2.6.0/", + "${workspaceFolder}/common/third_party/fastpbkdf2-1.0.0/", + "${workspaceFolder}/../vscp/src/common", + "${workspaceFolder}/../vscp/src/vscp/common", + "/home/akhe/Qt/6.8.0/gcc_64/include" ], "defines": [], - "intelliSenseMode": "clang-x64", + "intelliSenseMode": "gcc-x64", "browse": { - "path": [ - "/usr/local/include", - "/usr/include/x86_64-linux-gnu", - "/usr/include", - "${VSCP_ROOT}/src/**", - "${workspaceFolder}/src/", - "${workspaceFolder}/common/", - "${workspaceFolder}/common/third_party/", - "${workspaceFolder}/common/third_party/nlohmann/", - "${workspaceFolder}/common/third_party/spdlog-1.9.2/include", - "${workspaceFolder}/common/third_party/sqlite3-3.35.4/", - "${workspaceFolder}/common/third_party/duktape-2.6.0/", - "${workspaceFolder}/common/third_party/fastpbkdf2-1.0.0/", - "${workspaceFolder}/../vscp/src/common", - "${workspaceFolder}/../vscp/src/vscp/common" + "path": [ + "/usr/local/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${VSCP_ROOT}/src/**", + "${workspaceFolder}/src/", + "${workspaceFolder}/common/", + "${workspaceFolder}/common/third_party/", + "${workspaceFolder}/common/third_party/nlohmann/", + "${workspaceFolder}/common/third_party/spdlog-1.9.2/include", + "${workspaceFolder}/common/third_party/sqlite3-3.35.4/", + "${workspaceFolder}/common/third_party/duktape-2.6.0/", + "${workspaceFolder}/common/third_party/fastpbkdf2-1.0.0/", + "${workspaceFolder}/../vscp/src/common", + "${workspaceFolder}/../vscp/src/vscp/common" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, - "compilerPath": "/usr/bin/clang", + "compilerPath": "/usr/bin/g++", "cStandard": "c11", "cppStandard": "c++17", "configurationProvider": "ms-vscode.cmake-tools" diff --git a/.vscode/launch.json b/.vscode/launch.json index c8e6da4c..a5923d0a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,39 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Launch lldb", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build/vscp-works-qt", + "args": [], + "preLaunchTask": "build", + }, + { + "name": "(gdb) Launch X", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/vscp-works-qt", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + }, + { "name": "(gdb) Launch", "type": "cppdbg", @@ -15,6 +48,9 @@ "environment": [], "externalConsole": false, "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "visualizerFile": "/home/akhe/.config/Code/User/workspaceStorage/b3a88788bb1e8a32eb6392485a993de5/tonka3000.qtvsctools/qt.natvis.xml", + "logging": { "engineLogging": true, "trace": true, "traceResponse": true }, "setupCommands": [ { "description": "Enable pretty-printing for gdb", @@ -22,8 +58,6 @@ "ignoreFailures": true } ], - "preLaunchTask": "build", - "visualizerFile": "/home/akhe/.config/Code/User/workspaceStorage/b3a88788bb1e8a32eb6392485a993de5/tonka3000.qtvsctools/qt.natvis.xml" }, { "name": "g++ build and debug active file", @@ -52,11 +86,7 @@ "request": "launch", "name": "Debug portfile(s)", "cmakeDebugType": "external", -<<<<<<< HEAD "pipeName": "/tmp/vcpkg_ext_portfile_dbg", -======= - "pipeName": "\\\\.\\pipe\\vcpkg_ext_portfile_dbg", ->>>>>>> 99063577d2c6f0b876be4ba772a602728c9740bf "preLaunchTask": "Debug vcpkg commands" } ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 565e0e85..b913ad69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -111,7 +111,10 @@ ], "cSpell.language": "sv,en", "cSpell.words": [ - "MQTT" + "Grodans", + "Hedman", + "MQTT", + "Paradis" ], "cmake.clearOutputBeforeBuild": false, "cmake.configureEnvironment": { diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a7c27e57..797fe2cb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,13 +13,13 @@ "isDefault": true }, { - "taskName": "build", + "taskName": "make", + "label": "build", "type": "shell", - "command": "cd build; make -j4 -Wall", + "command": "cd build; make -j4 -Wall ", "args": [], "group": "build", - "problemMatcher": "$gcc", - "label": "build" + "problemMatcher": "$gcc" }, { "taskName": "clean & build all", @@ -47,7 +47,7 @@ { "taskName": "Clean & build all 6.8.0", "type": "shell", - "command": "cd build; make clean; export CMAKE_PREFIX_PATH=~/Qt/6.8.0/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/6.8.0/gcc_64 .. ; make -j4", + "command": "rm -rf build; mkdir build; cd build; export CMAKE_PREFIX_PATH=~/Qt/6.8.0/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/6.8.0/gcc_64 .. ; make -j4 -Wall", "args": [], "group": "build", "problemMatcher": { @@ -70,7 +70,7 @@ { "taskName": "Clean & build all 6.7.3", "type": "shell", - "command": "cd build; make clean; export CMAKE_PREFIX_PATH=~/Qt/6.7.3/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/7.3.0/gcc_64 .. ; make -j4", + "command": "rm -rf build; mkdir build; cd build; export CMAKE_PREFIX_PATH=~/Qt/6.7.3/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/7.3.0/gcc_64 .. ; make -j4 -Wall", "args": [], "group": "build", "problemMatcher": { @@ -93,7 +93,7 @@ { "taskName": "Clean & build all 6.5.3", "type": "shell", - "command": "cd build; make clean; export CMAKE_PREFIX_PATH=~/Qt/6.5.3/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/6.5.3/gcc_64 .. ; make -j4", + "command": "rm -rf build; mkdir build; cd build; export CMAKE_PREFIX_PATH=~/Qt/6.5.3/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/6.5.3/gcc_64 .. ; make -j4 -Wall", "args": [], "group": "build", "problemMatcher": { @@ -113,31 +113,6 @@ }, "label": "Clean & build all 6.5.3" }, - { - "taskName": "Clean & build all 5.15.2", - "type": "shell", - "command": "cd build; make clean; export CMAKE_PREFIX_PATH=~/Qt/5.15.2/gcc_64:$CMAKE_PREFIX_PATH; cmake -DCMAKE_BUILD_TYPE=Debug -DQt6_DIR=~/Qt/5.15.2/gcc_64 .. ; make -j4 -Wall", - "args": [], - "group": { - "kind": "build" - }, - "problemMatcher": { - "owner": "cpp", - "fileLocation": [ - "relative", - "${workspaceFolder}" - ], - "pattern": { - "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "message": 5 - } - }, - "label": "Clean & build all 5.15.2" - }, { "type": "shell", "label": "g++ build active file", diff --git a/images/bootloader_watermark.xcf b/images/bootloader_watermark.xcf new file mode 100644 index 00000000..2f157aba Binary files /dev/null and b/images/bootloader_watermark.xcf differ diff --git a/images/canal_watermark.xcf b/images/canal_watermark.xcf new file mode 100644 index 00000000..e9096ce4 Binary files /dev/null and b/images/canal_watermark.xcf differ diff --git a/src/bootloaderwizard.cpp b/src/bootloaderwizard.cpp index 3aad2a2d..8f64d594 100644 --- a/src/bootloaderwizard.cpp +++ b/src/bootloaderwizard.cpp @@ -82,6 +82,8 @@ CWizardPageNickname::CWizardPageNickname(QWidget* parent, CVscpClient* vscpClien { vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); m_vscpClient = vscpClient; + + m_nickname = 1; } /////////////////////////////////////////////////////////////////////////////// @@ -114,7 +116,8 @@ CWizardPageNickname::initializePage(void) "to set node id\n\n")); label->setWordWrap(true); - QLineEdit* pNodeId = new QLineEdit("0x01"); + QString str = QString::number(m_nickname); + QLineEdit* pNodeId = new QLineEdit(QString("0x%1").arg(m_nickname, 2, 16, QLatin1Char('0'))); QCheckBox* pSetInBootMode = new QCheckBox("Remote device is already in bootmode"); pNodeId->setMaximumWidth(100); // pNodeIdSpinBox->setMinimum(1); @@ -670,6 +673,7 @@ CWizardPageLoadMdf::validatePage(void) str += " Model: "; str += mdf.getModuleModel().c_str(); setField("boot.firmware.devicename", str); + QApplication::restoreOverrideCursor(); } } break; #endif @@ -726,7 +730,7 @@ void CWizardPageFirmware::initializePage(void) { QString str; - setTitle("Select firmare to upload to device"); + setTitle("Select firmware to upload to device"); QLabel* label = new QLabel("Select the firmware you want to upload to the remote device. " "You can use a local file or you can use one of the files listed " @@ -747,6 +751,7 @@ CWizardPageFirmware::initializePage(void) QLabel* labelBootloadDeviceCode = new QLabel("Current firmware device code: " + field("boot.firmware.device.code").toString()); m_chkLocalFile = new QCheckBox("Use local firmware file"); + m_chkLocalFile->setStyleSheet("color: rgb(129, 61, 156);"); m_btnSelectFirmware = new QPushButton("Select firmware file"); m_editFirmwareFile = new QLineEdit("No firmware file selected"); @@ -757,6 +762,7 @@ CWizardPageFirmware::initializePage(void) layout->addWidget(labelVer); layout->addWidget(labelBootloadAlgorithm); layout->addWidget(labelBootloadDeviceCode); + layout->addSpacing(30); layout->addWidget(m_chkLocalFile); layout->addWidget(m_btnSelectFirmware); layout->addWidget(m_editFirmwareFile); @@ -841,6 +847,10 @@ CWizardPageFirmware::isComplete(void) const return true; } +/////////////////////////////////////////////////////////////////////////////// +// write_data +// + static size_t write_data(void* ptr, size_t size, size_t nmemb, FILE* stream) { @@ -862,8 +872,8 @@ CWizardPageFirmware::validatePage(void) } /*! - Open file selction dialog if local file is checked - and filname is nill + Open file selection dialog if local file is checked + and filename is nill */ if (m_chkLocalFile->isChecked() && !m_editFirmwareFile->text().trimmed().size()) { QString path = QFileDialog::getOpenFileName(this, @@ -1109,7 +1119,7 @@ CWizardPageFlash::flashDevice(void) guid.setNicknameID(vscp_readStringValue(field("boot.nickname").toString().toStdString())); using namespace std::placeholders; // auto callback = std::bind(&CWizardPageLoadMdf::statusCallback, this, _1, _2); - // lambda version for reference + // lambda version for reference auto callback = [this](auto a, auto b) { this->statusCallback(a, b); }; CBootDevice_PIC1 boot(m_vscpClient, vscp_readStringValue(field("boot.nickname").toString().toStdString()), callback); addStatusMessage("Hex file path: " + field("boot.firmware.path").toString()); diff --git a/src/bootloaderwizard.h b/src/bootloaderwizard.h index de887114..652d8b4a 100644 --- a/src/bootloaderwizard.h +++ b/src/bootloaderwizard.h @@ -86,9 +86,15 @@ class CWizardPageNickname : public QWizardPage { */ int nextId(void) const; + /// Set initial nickname + void setNickname(uint16_t nickname) { m_nickname = nickname; } + private: /// A pointer to a VSCP Client CVscpClient* m_vscpClient; + + // Default + uint16_t m_nickname; }; // ---------------------------------------------------------------------------- @@ -343,7 +349,7 @@ class CWizardPageFlash : public QWizardPage { /*! Add a status message - @param str Statusmessage to add. Not added if zero length + @param str Status message to add. Not added if zero length */ void addStatusMessage(const QString& str); diff --git a/src/cfrmnodescan.cpp b/src/cfrmnodescan.cpp index b8c4ae67..c1540fb4 100644 --- a/src/cfrmnodescan.cpp +++ b/src/cfrmnodescan.cpp @@ -60,6 +60,8 @@ #include "cfrmnodescan.h" #include "ui_cfrmnodescan.h" + +#include "bootloaderwizard.h" // #include "cdlgmainsettings.h" // #include "cdlgtxedit.h" @@ -130,7 +132,7 @@ CFrmNodeScan::CFrmNodeScan(QWidget* parent, QJsonObject* pconn) , ui(new Ui::CFrmNodeScan) { ui->setupUi(this); - + ui->treeFound->setContextMenuPolicy(Qt::CustomContextMenu); ui->treeFound->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -532,7 +534,8 @@ CFrmNodeScan::doDisconnectFromRemoteHost(void) if (VSCP_ERROR_SUCCESS != (rv = m_vscpClient->disconnect())) { QString str = tr("Node Scan: Unable to disconnect from the " - "SOCKETCAN driver. rv={}").arg(rv); + "SOCKETCAN driver. rv={}") + .arg(rv); spdlog::error(str.toStdString()); QMessageBox::information(this, tr(APPNAME), @@ -711,7 +714,7 @@ CFrmNodeScan::doScan(void) } QApplication::setOverrideCursor(Qt::WaitCursor); - //QApplication::processEvents(); + // QApplication::processEvents(); std::string interface = m_connObject["selected-interface"].toString().toStdString(); cguid guidInterface(interface); @@ -793,7 +796,7 @@ CFrmNodeScan::doScan(void) // Load mdf and standard registers if requested to do so if (ui->chkFetchInfo->isChecked()) { doLoadMdf(item); - //QApplication::setOverrideCursor(Qt::WaitCursor); + // QApplication::setOverrideCursor(Qt::WaitCursor); ui->progressBarScan->setValue(ui->progressBarScan->value() + (int)additem); } } @@ -849,6 +852,7 @@ CFrmNodeScan::showFindNodesContextMenu(const QPoint& pos) menu->addSeparator(); menu->addAction(QString(tr("Configure")), this, SLOT(goConfig())); menu->addAction(QString(tr("Session")), this, SLOT(goSession())); + menu->addAction(QString(tr("Load/update firmware")), this, SLOT(goFirmwareUpdate())); menu->popup(ui->treeFound->viewport()->mapToGlobal(pos)); } @@ -1113,4 +1117,52 @@ CFrmNodeScan::goConfig(void) w->raise(); // https://wiki.qt.io/Technical_FAQ#QWidget_::activateWindow.28.29_-_behavior_under_windows w->activateWindow(); +} + +/////////////////////////////////////////////////////////////////////////////// +// goFirmwareUpdate +// + +void +CFrmNodeScan::goFirmwareUpdate(void) +{ + int rv; + + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + QList selected = ui->treeFound->selectedItems(); + // Must be selected items + if (!selected.size()) { + QMessageBox::information(this, + tr(APPNAME), + tr("Must select a node to use operation."), + QMessageBox::Ok); + return; + } + + CFoundNodeWidgetItem* pitem = (CFoundNodeWidgetItem*)selected.at(0); + if (nullptr == pitem) { + QMessageBox::information(this, + tr(APPNAME), + tr("Failed to get node."), + QMessageBox::Ok); + return; + } + + CBootLoadWizard wiz(parentWidget(), &m_connObject); + + if (VSCP_ERROR_SUCCESS != (rv = wiz.initBootLoaderWizard())) { + spdlog::error("Aborting bootloader wizard (initBootLoaderWizard) rv={}", rv); + return; + } + + + CWizardPageNickname *pageNickname = (CWizardPageNickname *)wiz.page(CBootLoadWizard::Page_Nickname); + pageNickname->setNickname(pitem->m_nodeid); + + // Select 'set nickname' page + //wiz.setCurrentId(CBootLoadWizard::Page_Nickname); + + wiz.exec(); + } \ No newline at end of file diff --git a/src/cfrmnodescan.h b/src/cfrmnodescan.h index 9e397fc5..d6ae0916 100644 --- a/src/cfrmnodescan.h +++ b/src/cfrmnodescan.h @@ -207,12 +207,15 @@ public slots: /// Find nodes item clicked -> Display device info void onFindNodesTreeWidgetItemClicked(QTreeWidgetItem* item, int column); - /// Open session window fron selected found node + /// Open session window from selected found node void goSession(void); - /// Open config window fron selected found node + /// Open config window from selected found node void goConfig(void); + /// Open firmware update window from selected node found + void goFirmwareUpdate(void); + signals: /// Data received from callback @@ -223,7 +226,7 @@ public slots: CVscpClient::connType m_vscpConnType; /// Configuration data for the session - QJsonObject m_connObject; + QJsonObject m_connObject; /// A pointer to a VSCP Client CVscpClient* m_vscpClient; diff --git a/third_party/maddy b/third_party/maddy index 1f12bc15..8aa290cd 160000 --- a/third_party/maddy +++ b/third_party/maddy @@ -1 +1 @@ -Subproject commit 1f12bc15b6b1c66e7fadf54367780488b9ffcf31 +Subproject commit 8aa290cd38f4353eb7eb20d275cb169bc0a48b7b diff --git a/third_party/mongoose b/third_party/mongoose index 85414cfe..2df53c3d 160000 --- a/third_party/mongoose +++ b/third_party/mongoose @@ -1 +1 @@ -Subproject commit 85414cfec2219e4e4fe9cf93685f11ad4cdecd50 +Subproject commit 2df53c3d27b9ae54b1c08b6c3c3cc660a49fa4a2 diff --git a/third_party/nlohmann b/third_party/nlohmann index 4a602df3..378e0917 160000 --- a/third_party/nlohmann +++ b/third_party/nlohmann @@ -1 +1 @@ -Subproject commit 4a602df34e71afca2242b34c743d4cc2486cd071 +Subproject commit 378e091795a70fced276cd882bd8a6a428668fe5 diff --git a/third_party/spdlog b/third_party/spdlog index 51a0deca..1245bf8e 160000 --- a/third_party/spdlog +++ b/third_party/spdlog @@ -1 +1 @@ -Subproject commit 51a0deca2c825f1d4461655a18bb37d6df76646d +Subproject commit 1245bf8e8a19d914271df03124da9593f3634a9c diff --git a/third_party/vscp b/third_party/vscp index 24d846ef..bcfae7d4 160000 --- a/third_party/vscp +++ b/third_party/vscp @@ -1 +1 @@ -Subproject commit 24d846ef38276697c325f637640beefbae23f379 +Subproject commit bcfae7d4e508975027ef0dbc6542d37cd93b9c20