← index #5778PR #4359
Off-topic · high · value 0.131
QUERY · ISSUE

lightsleep results in machine reset on ESP32

openby jdstroyopened 2020-03-20updated 2020-03-23
port-esp32

Hello,

I'm running this version of MicroPython on ESP32:

MicroPython v1.12-262-g19ea30bdd on 2020-03-20; ESP32 module with ESP32

And I'm observing unexpected behavior with machine.lightsleep().

I would expect the following program code:

import machine
import time
while True:
    machine.lightsleep(10)

to behave in the same way as:

import machine
import time
while True:
    time.sleep_ms(10)

However, the prior always results in a WDT reset on my platform:

>>> import machine;
>>> while True:
...     machine.lightsleep(10);
...
...
...
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

This seems like a bug in machine.lightsleep(), as I can reproduce this with any value given to lightsleep, and even performing consecutive machine.lightsleep(100); calls directly without a loop.

CANDIDATE · PULL REQUEST

docs/machine: Change sleep to lightsleep and add timeout arguments.

closedby dpgeorgeopened 2018-12-15updated 2019-01-27
rfcdocs

The machine.sleep() function can be misleading because it clashes with time.sleep() which has quite different semantics. So I propose to change it to machine.lightsleep() which shows that it is closer in behaviour to machine.deepsleep(), and update the wording of these functions in an attempt to make them generic.

Also, add an optional argument to these two sleep functions to specify a maximum time to sleep for. This is a common operation and underlying hardware usually has a special way of performing this operation.

The existing machine.sleep() function will remain for backwards compatibility purposes, and it can simply be an alias for machine.lightsleep() without arguments. The behaviour will be the same.

This PR only changes the docs. If it goes through then I'll follow with implementations on the ports that already have these functions.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied