]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Flush serial line output after reset
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 9 Dec 2014 09:17:53 +0000 (10:17 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 9 Dec 2014 09:17:53 +0000 (10:17 +0100)
This caused some problems when novaboot was used in other scripts and
those scripts looked for certain strings in novaboot output. It happened
that the string was found in the output before reset and therefore, the
whole thing didn't work correctly.

novaboot

index bd81271a8bfd31194b537f8b98307be742c1c138..e3e084e2f61b1b54ab88e614ea670ccbb49fb449 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -1023,6 +1023,20 @@ if (defined $target_reset && $reset) {
     print STDERR "novaboot: Reseting the test box... ";
     &$target_reset();
     print STDERR "done\n";
+    if (defined $exp) {
+       # We don't want to output anything printed by the target
+       # before reset so we clear the buffers now. This is, however,
+       # not ideal because we may loose some data that were sent
+       # after the reset. If this is a problem, one should reset and
+       # connect to serial line in atomic manner. For example, if
+       # supported by hardware, use --remote-cmd 'sterm -d ...' and
+       # do not use separate --reset-cmd.
+       my $log = $exp->log_stdout;
+       $exp->log_stdout(0);
+       $exp->expect(0); # Read data from target
+       $exp->clear_accum();    # Clear the read data
+       $exp->log_stdout($log);
+    }
 }
 
 ### U-boot conversation