From 8169a6d04b958d96812859d1149ee10443307194 Mon Sep 17 00:00:00 2001 From: heyuanjie87 <943313837@qq.com> Date: Fri, 7 May 2021 19:17:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96modem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modem/Ymodem.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Modem/Ymodem.cpp b/Modem/Ymodem.cpp index 9219bfc..135e6b2 100644 --- a/Modem/Ymodem.cpp +++ b/Modem/Ymodem.cpp @@ -40,6 +40,9 @@ float Ymodem::speed_clc(int total, int remain) void Ymodem::put(const QByteArray &data) { + if (!isrun) + return; + for (int i = 0; i < data.size(); i ++) msgq_push(data.at(i)); } @@ -121,6 +124,7 @@ void Ymodem::msgq_push(int msg) bool Ymodem::msgq_get(int &msg) { + msg = 0; if (msgq.empty()) return false; @@ -185,6 +189,7 @@ void Ymodem::run() string stext; int remain = 0; int fmsize; + int msg = 0; showStatus("已启动Ymodem"); ui->getFile(filename); @@ -202,16 +207,17 @@ void Ymodem::run() } Stage = msFirst; - isrun = true; + if (mMode == 'x') fmsize = 128; else fmsize = 1024; + while (msgq_get(msg)); + isrun = true; + while (isrun) { - int msg = 0; - msgq_get(msg); switch (Stage) @@ -330,4 +336,5 @@ void Ymodem::run() err: showStatus("退出Ymodem"); + isrun = false; }