Code: Select all
MicroPython v1.8.7 on 2017-02-07; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> def test():
... pyb.RTC().wakeup(1000)
... print("Before")
... pyb.stop()
... print("after")
... pyb.RTC().wakeup(None)
...
>>> test()
<REPL hangs>
This is the minimal case; the code I'm actually writing is sleeping (pyb.stop()) between calling uart1.any() to check if there are any bytes to process, but this always seems to return 0.
The reasoning given at viewtopic.php?t=2388 indicates what I'm doing should be possible and has been tried before. I don't mind so much about the REPL not working (although it's a bit strange to me); but would be good if the UART would work.
Code: Select all
...
self._rtc = pyb.RTC()
self._uart = pyb.UART(1, 9600, read_buf_len=1024)
self._rtc.wakeup(2000)
...
while 1:
self._led(1).on()
if self._uart.any() < 512:
pass # Execution always flows through here (tested with LEDs)
else:
self._data += self._uart.read(self._uart.any())
gprmc_start_loc = self._data.find(b"$GPRMC")
gprmc_end_loc = self._data.find(b"\r\n", gprmc_start_loc)
if gprmc_end_loc == -1:
self._data = b""
else:
self._led(2).on()
with self._file() as f:
f.write(
self._data[gprmc_start_loc: gprmc_end_loc + 2])
self._data = self._data[gprmc_end_loc + 2:]
self._sync()
self._led(2).off()
self._led(1).off()
self._stop()