添加ota cdc串口打开失败后继续尝试。

This commit is contained in:
luocai 2024-08-14 19:51:37 +08:00
parent 219c68ea45
commit a2a79ac084
5 changed files with 32 additions and 4 deletions

View File

@ -217,7 +217,7 @@ void Application::uploadImage(const QString &path, int operation) {
m_uploadImageSendedSize = 0;
ModuleCommunication::UploadImageInformation request;
if (path.endsWith(".jpg")) {
auto image = ImageDecoder::extractJpegYComponent(path.toStdString());
auto image = ImageDecoder::extractJpegYComponent(Amass::StringUtility::UTF8ToGBK(path.toStdString()));
if (!image) {
LOG(error) << "decode failed.";
return;
@ -252,10 +252,18 @@ void Application::uploadImage(const QString &path, int operation) {
m_communication->uploadImageInfo(request);
LOG(info) << "upload image, md5: "
<< ModuleCommunication::protocolDataFormatString(request.md5, sizeof(request.md5));
m_imageUploadling = true;
m_startUploadTime = std::chrono::system_clock::now();
}
void Application::timerEvent(QTimerEvent *event) {
static int i = 0;
if (i <= 4000 && !m_imageUploadling) {
uploadImage("./1722829247678.jpg", 0);
LOG(info) << "register times: " << i++;
}
}
ModuleCommunication *Application::module() const {
return m_communication.get();
}
@ -374,9 +382,11 @@ void Application::onCommandFinished(ModuleCommunication::MessageId messageId,
m_communication->uploadImageData(m_uploadImageSendedSize,
(const uint8_t *)m_uploadBuffer.data() + m_uploadImageSendedSize,
remainSize < ImageSliceSize ? remainSize : ImageSliceSize);
m_imageUploadling = true;
} else {
LOG(info) << "upload finished, elapsed: "
<< duration_cast<milliseconds>(system_clock::now() - m_startUploadTime);
m_imageUploadling = false;
}
}
@ -440,4 +450,7 @@ bool Application::startOta(const QString &path) {
void Application::onCdcDeviceDiscovered(const QSerialPortInfo &info) {
auto status = m_updater->open(info);
LOG(info) << "open cdc port: " << info.portName().toStdString() << ", status: " << status;
if (!status) {
QTimer::singleShot(0, this, [this]() { m_updater->startSearchDevice(); });
}
}

View File

@ -77,6 +77,7 @@ signals:
protected:
Application(int &argc, char **argv);
void timerEvent(QTimerEvent *event) final;
void onNewEnrollResult(uint16_t userid);
void onNewVerifyResult(uint16_t userid, const QString &username, uint16_t elapsed);
void onNewPalmFeature(const PalmFeature &feature);
@ -110,6 +111,7 @@ private:
uint32_t m_uploadImageSendedSize;
std::vector<uint8_t> m_uploadBuffer;
bool m_imageUploadling = false;
std::shared_ptr<VideoPlayer> m_videoPlayer;
VideoFrameProvider *m_videoFrameProvider;

View File

@ -151,12 +151,19 @@ Item {
TextField {
id: imagePath
Layout.columnSpan: 2
implicitWidth: 180
implicitWidth: 200
placeholderText: "请选择图片"
onPressed: {
fileDialog.open()
}
}
Text {
text: qsTr("用户姓名")
}
TextField {
id: imageEnrollName
implicitWidth: 100
}
Button {
text: "注册"
onClicked: App.uploadImage(imagePath.text, 0)

View File

@ -5,7 +5,7 @@ import Analyser
Window {
width: 1120
height: 680
height: 700
visible: true
title: qsTr(Qt.application.name + " " + Qt.application.version)

View File

@ -75,3 +75,9 @@ cv181x_alios/boards/cv181xc_qfn/configs/partition_alios_spinor.xml
cv181x_alios/solutions/smart_doorbell/face_lock_app/flash-part.h
```
修改`cv181x_alios/pack-ota.sh`,以支持将boot打进ota升级文件中。有升级变砖风险
```
# $ota_pack_tool $OTA_PKG imtb yoc.bin algo.bin.1 boot $@
```