@@ -322,7 +322,7 @@ def read_until(self, min_num_bytes, ending, timeout=10, data_consumer=None):
322
322
time .sleep (0.01 )
323
323
return data
324
324
325
- def enter_raw_repl (self ):
325
+ def enter_raw_repl (self , soft_reset = True ):
326
326
self .serial .write (b"\r \x03 \x03 " ) # ctrl-C twice: interrupt any running program
327
327
328
328
# flush input (without relying on serial.flushInput())
@@ -332,18 +332,23 @@ def enter_raw_repl(self):
332
332
n = self .serial .inWaiting ()
333
333
334
334
self .serial .write (b"\r \x01 " ) # ctrl-A: enter raw REPL
335
- data = self .read_until (1 , b"raw REPL; CTRL-B to exit\r \n >" )
336
- if not data .endswith (b"raw REPL; CTRL-B to exit\r \n >" ):
337
- print (data )
338
- raise PyboardError ("could not enter raw repl" )
339
335
340
- self .serial .write (b"\x04 " ) # ctrl-D: soft reset
341
- data = self .read_until (1 , b"soft reboot\r \n " )
342
- if not data .endswith (b"soft reboot\r \n " ):
343
- print (data )
344
- raise PyboardError ("could not enter raw repl" )
345
- # By splitting this into 2 reads, it allows boot.py to print stuff,
346
- # which will show up after the soft reboot and before the raw REPL.
336
+ if soft_reset :
337
+ data = self .read_until (1 , b"raw REPL; CTRL-B to exit\r \n >" )
338
+ if not data .endswith (b"raw REPL; CTRL-B to exit\r \n >" ):
339
+ print (data )
340
+ raise PyboardError ("could not enter raw repl" )
341
+
342
+ self .serial .write (b"\x04 " ) # ctrl-D: soft reset
343
+
344
+ # Waiting for "soft reboot" independently to "raw REPL" (done below)
345
+ # allows boot.py to print, which will show up after "soft reboot"
346
+ # and before "raw REPL".
347
+ data = self .read_until (1 , b"soft reboot\r \n " )
348
+ if not data .endswith (b"soft reboot\r \n " ):
349
+ print (data )
350
+ raise PyboardError ("could not enter raw repl" )
351
+
347
352
data = self .read_until (1 , b"raw REPL; CTRL-B to exit\r \n " )
348
353
if not data .endswith (b"raw REPL; CTRL-B to exit\r \n " ):
349
354
print (data )
0 commit comments