diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index 2f0327b..422497d 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -125,6 +125,9 @@ bool Application::open(const QString &portName, int baudRate) { auto status = m_communication->open(portName, baudRate); emit newStatusTip(status ? Tip : Error, status ? "串口打开成功" : "串口打开失败"); + if (status) { + QTimer::singleShot(0, this, [this]() { m_communication->requestVersion(); }); + } return status; } diff --git a/Analyser/ModuleCommunication.cpp b/Analyser/ModuleCommunication.cpp index 72b6e47..621f94b 100644 --- a/Analyser/ModuleCommunication.cpp +++ b/Analyser/ModuleCommunication.cpp @@ -171,6 +171,13 @@ void ModuleCommunication::requestUniqueId() { LOG_CAT(info, GUI) << Separator; } +void ModuleCommunication::requestVersion() { + auto [frameData, frameSize] = generateFrame(GetVersion); + m_serialPort->write(reinterpret_cast(frameData), frameSize); + LOG_CAT(info, GUI) << "发送获取版本指令: " << protocolDataFormatString(frameData, frameSize); + LOG_CAT(info, GUI) << Separator; +} + ModuleCommunication::MessageId ModuleCommunication::currentMessageId() const { return m_currentMessageId; } @@ -312,6 +319,22 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { LOG_CAT(info, GUI) << Separator; break; } + case GetVersion: { + LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size); + auto version = reinterpret_cast(data + 7); + int length = std::strlen(version->version); + if (length > sizeof(version->version)) { + length = sizeof(version->version); + } + int ota = ntohl(version->otaVersion); + LOG_CAT(info, GUI) << "模组烧录版本: " << std::string_view(version->version, length) + << ", OTA版本: " << ntohl(version->otaVersion); + LOG_CAT(info, GUI) << Separator; + m_verison = QString::fromLocal8Bit(version->version, length); + m_otaVerison = ota; + emit verisonChanged(); + break; + } case EnableDebug: { LOG(info) << "set moudle debug mode: " << (result == Success); break; diff --git a/Analyser/ModuleCommunication.h b/Analyser/ModuleCommunication.h index b89ef6e..45aa410 100644 --- a/Analyser/ModuleCommunication.h +++ b/Analyser/ModuleCommunication.h @@ -11,8 +11,11 @@ class ModuleCommunication : public QObject { Q_OBJECT QML_ELEMENT static constexpr uint32_t UsernameSize = 32; + static constexpr uint32_t VersionSize = 32; static constexpr const char *Separator = "----------"; Q_PROPERTY(MessageId currentMessageId READ currentMessageId NOTIFY currentMessageIdChanged) + Q_PROPERTY(QString verison MEMBER m_verison NOTIFY verisonChanged) + Q_PROPERTY(int otaVerison MEMBER m_otaVerison NOTIFY verisonChanged) public: constexpr static uint16_t InvalidUserId = std::numeric_limits::max(); @@ -28,6 +31,7 @@ public: GetImage = 0x1F, // 获取图片数据,通过VerifyExtended或EnrollExtended保存的 DeleteUser = 0x20, DeleteAll = 0x21, + GetVersion = 0x30, StartOta = 0x40, // 模组进入boot模式进行ota升级 EnableDebug = 0x82, GetUniqueID = 0xAC, @@ -142,6 +146,11 @@ public: uint8_t data[0]; }; + struct ModuleVersion { + char version[VersionSize]; + uint32_t otaVersion; + }; + struct ModuleId { char id[32]; }; @@ -158,6 +167,7 @@ public: Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteAll(); Q_INVOKABLE void requestUniqueId(); + Q_INVOKABLE void requestVersion(); void requestEnrolledImage(uint32_t offset, uint32_t size); void uploadImageInfo(const UploadImageInformation &info); @@ -184,6 +194,7 @@ signals: void commandStarted(ModuleCommunication::MessageId messageId); void commandFinished(MessageId messageId, MessageStatus status); void currentMessageIdChanged(); + void verisonChanged(); protected: void processPackage(const uint8_t *data, uint16_t size); @@ -195,8 +206,9 @@ protected: private: std::shared_ptr m_serialPort; QByteArray m_receivedBuffer; - MessageId m_currentMessageId = ModuleCommunication::Idle; + QString m_verison; + int m_otaVerison; }; #endif // MODULECOMMUNICATION_H diff --git a/Analyser/qml/OperationItem.qml b/Analyser/qml/OperationItem.qml index 54da041..1bf4b97 100644 --- a/Analyser/qml/OperationItem.qml +++ b/Analyser/qml/OperationItem.qml @@ -10,6 +10,16 @@ Item { ColumnLayout { anchors.fill: parent ConnectionItem {} + Column { + Text{ + width: 50 + text: "烧录版本: "+ (App.module!==null? App.module.verison:"") + } + Text{ + width: 50 + text: "OTA版本: "+(App.module!==null?App.module.otaVerison:"") + } + } GroupBox { id: commandBox diff --git a/Analyser/qml/main.qml b/Analyser/qml/main.qml index 6d5e8f5..e89a4c3 100644 --- a/Analyser/qml/main.qml +++ b/Analyser/qml/main.qml @@ -5,7 +5,7 @@ import Analyser Window { width: 1120 - height: 700 + height: 770 visible: true title: qsTr(Qt.application.name + " " + Qt.application.version) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0cac42..b20ba2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(Projects_ROOT E:/Projects) set(Libraries_ROOT ${Projects_ROOT}/Libraries) -set(BOOST_ROOT ${Libraries_ROOT}/boost_1_85_0_msvc2022_64bit) -set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_85) +set(BOOST_ROOT ${Libraries_ROOT}/boost_1_86_0_msvc2022_64bit) +set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_86) option(Boost_USE_STATIC_LIBS OFF) add_compile_definitions( BOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN10 diff --git a/Readme.md b/Readme.md index edf603e..0695197 100644 --- a/Readme.md +++ b/Readme.md @@ -58,7 +58,10 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin ```shell ./boot-rebuild.sh # 编译boot ./rebuild-app.sh y L015 V200 R002 # 编译烧录固件 -./rebuild-app-ota.sh y L015 V200 R002 14 # 编译OTA固件,11为OTA版本号 + +# 编译OTA固件,11为OTA版本号,这个版本号只做固件文件名显示。 +# 实际的版本设置在 cv181x_alios/solutions/smart_doorbell/package.yaml.L015_V200R002 +./rebuild-app-ota.sh y L015 V200 R002 01 600X800 ```