Skip to content

Commit bc752c1

Browse files
improve 'write' command transaction.
1 parent a204240 commit bc752c1

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

mrbwrite.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
mruby/c irep file writer.
44
55
<pre>
6-
Copyright (C) 2017-2022 Kyushu Institute of Technology.
7-
Copyright (C) 2017-2022 Shimane IT Open-Innovation Center.
6+
Copyright (C) 2017-2023 Kyushu Institute of Technology.
7+
Copyright (C) 2017-2023 Shimane IT Open-Innovation Center.
88
99
This file is distributed under BSD 3-Clause License.
1010
1111
</pre>
1212
*/
1313

14-
#define VERSION_NUMBER "1.03"
14+
#define VERSION_NUMBER "1.04"
1515

1616
#include <stdio.h>
1717
#include <stdlib.h>
@@ -330,14 +330,23 @@ int MrbWrite::write_file( QIODevice &file )
330330
serial_port_.waitForBytesWritten();
331331
}
332332
VERBOSE(tr("Send %1 bytes done.").arg(filesize));
333-
r = get_line();
334-
VERBOSE(tr("<== '%1'").arg(r.trimmed()));
335-
if( !r.startsWith("+DONE")) {
336-
qout_ << tr("transfer error. '%1'").arg(r.trimmed()) << endl;
337-
return 1;
333+
334+
while(1) {
335+
r = get_line();
336+
VERBOSE(tr("<== '%1'").arg(r.trimmed()));
337+
338+
if( r.isEmpty() ) {
339+
qout_ << tr("transfer timeout") << endl;
340+
return 1;
341+
}
342+
if( r.startsWith("+DONE")) break;
343+
if( r.startsWith("-")) {
344+
qout_ << tr("transfer error. '%1'").arg(r.trimmed()) << endl;
345+
return 1;
346+
}
338347
}
339-
qout_ << tr("OK.") << endl;
340348

349+
qout_ << tr("OK.") << endl;
341350
return 0;
342351
}
343352

0 commit comments

Comments
 (0)