From d06de61a1749d99c4afc19e64887b3599750cb50 Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Thu, 19 Oct 2023 23:51:49 +0800 Subject: [PATCH] add download a10 fw code Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- .github/workflows/linux.yml | 7 ++-- .github/workflows/windows.yml | 9 ++--- src/mainwindow.cpp | 66 +++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a3f7bc8e..618bcc2a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -2,7 +2,7 @@ name: linux on: push: - branches: [ main ] + branches: [ main, download_a10_fw ] paths-ignore: - 'doc/**' - 'docs/**' @@ -46,10 +46,11 @@ jobs: sed -i 's/git_tag.inc/git_tag.ci.inc/g' quardCRT.pro sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.2.0\/gcc_64/g' build_deb.sh ./build_deb.sh + rm ./dpkg/*.deb - name: Upload build asserts uses: actions/upload-artifact@v3.1.3 with: - name: quardCRT_Ubuntu2004 + name: a10_fw_loader path: | - ./dpkg/*.deb + ./dpkg/quardCRT_Linux_*_x86_64 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index dedb44d8..c14241d9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,7 +2,7 @@ name: windows on: push: - branches: [ main ] + branches: [ main, download_a10_fw ] paths-ignore: - 'doc/**' - 'docs/**' @@ -69,14 +69,15 @@ jobs: ./tools/sed/sed.exe -i "s/mingw32-make -j8/mingw32-make -j1/g" ./build_setup.bat ./tools/sed/sed.exe -i "s/WINPTY_DIR=D:\\quardCRT\\depend\\winpty/WINPTY_DIR=D:\\winpty/g" ./lib/ptyqt/ptyqt.pri ./build_setup.bat + mv ./InnoSetup/build/quardCRT.exe ./InnoSetup/build/a10_fw_loader.exe - name: Upload build asserts uses: actions/upload-artifact@v3.1.3 with: - name: quardCRT_windows + name: a10_fw_loader path: | - ./InnoSetup/quardCRT_setup.exe + ./InnoSetup/build - name: Run tests run: | - ./InnoSetup/build/quardCRT.exe --version + ./InnoSetup/build/a10_fw_loader.exe --version diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c4691c8c..101e948c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -54,6 +54,11 @@ #include "globalsetting.h" #include "ui_mainwindow.h" +#include +#include +#include +#include + MainWindow::MainWindow(QString dir, StartupUIMode mode, QLocale::Language lang, bool isDark, QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -378,6 +383,67 @@ MainWindow::MainWindow(QString dir, StartupUIMode mode, QLocale::Language lang, if(!dir.isEmpty()) { startLocalShellSession(mainWidgetGroupList.at(0),QString(),dir); } + + // 此处代码为下载A10固件工具专用定制代码 + QStringList ipaddrList; + QList list = QNetworkInterface::allAddresses(); + foreach(QHostAddress address,list) { + if(address.protocol() == QAbstractSocket::IPv4Protocol) { + if(address.toString() == "127.0.0.1") { + continue; + } + ipaddrList.append(address.toString()); + } + } + QString severip = QInputDialog::getItem(this,"选择IP地址","选择连接相机网卡的IP地址",ipaddrList,0,false); + if(severip.isEmpty()) { + QMessageBox::critical(this, "错误", "未选择IP地址"); + exit(0); + } + QString boardip; + do { + boardip = severip.left(severip.lastIndexOf(".")+1)+QString::number(QRandomGenerator::global()->bounded(50,200)); + }while(boardip == severip); + + QString fwDir = QFileDialog::getExistingDirectory(this, "选择固件路径", QDir::homePath()); + if(fwDir.isEmpty()) { + QMessageBox::critical(this, "错误", "未选择固件路径"); + exit(0); + } + + QTftp *a10fwTftpServer = new QTftp; + int port = 20000+QRandomGenerator::global()->bounded(1000); + a10fwTftpServer->setPort(port); + a10fwTftpServer->setUpDir(fwDir); + a10fwTftpServer->setDownDir(fwDir); + a10fwTftpServer->startServer(); + if(mode != MINIUI_MODE) { + menuBarAction->trigger(); + toolBarAction->trigger(); + statusBarAction->trigger(); + sideWindowAction->trigger(); + } + splitter->setSizes(QList() << 1 << 1); + splitter->setCollapsible(0,false); + splitter->setCollapsible(1,false); + mainWidgetGroupList[0]->splitter->setCollapsible(0,false); + mainWidgetGroupList[0]->splitter->setCollapsible(1,false); + mainWidgetGroupList[1]->splitter->setCollapsible(0,false); + mainWidgetGroupList[1]->splitter->setCollapsible(1,false); + mainWidgetGroupList[1]->splitter->setSizes(QList() << 10000 << 1); + mainWidgetGroupList[0]->splitter->setSizes(QList() << 10000 << 1); +#if defined(Q_OS_WIN) + mainWidgetGroupList[0]->commandWindow->setCmd("./down_uboot_use_jtag.ps1\n"); +#else + mainWidgetGroupList[0]->commandWindow->setCmd("./down_uboot_use_jtag.sh\n"); +#endif + mainWidgetGroupList[1]->commandWindow->setCmd("setenv ipaddr "+boardip+";setenv serverip "+severip+";setenv tftpdstp " + QString::number(port) + ";run percipioload;boot;\n"); + resize(1200,600); + setWindowTitle("A10固件下载工具"); + startLocalShellSession(mainWidgetGroupList[0],QString(),fwDir); + quickConnectMainWidgetGroup = mainWidgetGroupList[1]; + quickConnectWindow->setProtocol(QuickConnectWindow::Serial); + quickConnectWindow->show(); } MainWindow::~MainWindow() {