Skip to content

Commit

Permalink
优化modem
Browse files Browse the repository at this point in the history
  • Loading branch information
heyuanjie87 committed May 7, 2021
1 parent 3227e9c commit 8169a6d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Modem/Ymodem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -121,6 +124,7 @@ void Ymodem::msgq_push(int msg)

bool Ymodem::msgq_get(int &msg)
{
msg = 0;
if (msgq.empty())
return false;

Expand Down Expand Up @@ -185,6 +189,7 @@ void Ymodem::run()
string stext;
int remain = 0;
int fmsize;
int msg = 0;

showStatus("已启动Ymodem");
ui->getFile(filename);
Expand All @@ -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)
Expand Down Expand Up @@ -330,4 +336,5 @@ void Ymodem::run()

err:
showStatus("退出Ymodem");
isrun = false;
}

0 comments on commit 8169a6d

Please sign in to comment.