micropython / micropython-esp32

Old port of MicroPython to the ESP32 -- new port is at https://github.com/micropython/micropython
MIT License
669 stars 216 forks source link

Uasyncio not working properly on ESP32 #240

Closed Lisa999 closed 6 years ago

Lisa999 commented 6 years ago

Exact same python code running on ubuntu:

2017-12-15T21:41:22.004 [debug] uPyEasy: Protocols: Init protocol records, run async loop Scheduling %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocols: Init controller 192.168.178.115-Domoticz HTTP-2 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocol: domoticz http contruction 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: uPyEasy Name 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocol Domoticz HTTP: Init 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocols: Init controller 192.168.178.115-Domoticz MQTT-1 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocol: domoticz mqtt contruction 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: uPyEasy Name 2017-12-15T21:41:22.004 [debug] uPyEasy: Protocol Domoticz MQTT: Init 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Load 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: init plugin records 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Load frozen plugin gpio 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugin: gpio contruction 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Create frozen plugin Record: gpio 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Load frozen plugin ds18 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugin: ds18 contruction 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Create frozen plugin Record: ds18 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Init plugin records, run async loop Scheduling %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ()) 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugins: Init device GPIO Test 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugin: gpio contruction 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: uPyEasy Name 2017-12-15T21:41:22.004 [debug] uPyEasy: Plugin: gpio init 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: Sys hostname 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: uPyEasy Name 2017-12-15T21:41:22.004 [debug] uPyEasy: Utils: Sys hostname Set syslog hostname 192.168.178.72 reloaded sink syslog 2017-12-15T21:41:22.004 [debug] uPyEasy-Ubuntu: Main: Pre-loading home page 2017-12-15T21:41:22.004 [debug] uPyEasy-Ubuntu: Main: get_ip_address AttributeError 2017-12-15T21:41:22.004 [debug] uPyEasy-Ubuntu: Main: uPyEasy Main Async Loop Running on http://0.0.0.0:2000/ Scheduling %s (1513370482485, <generator object 'start_server' at fec7d360>, ()) Next coroutine to run: %s (1513370482485, <generator object 'start_server' at fec7d360>, ()) Coroutine %s send args: %s <generator object 'start_server' at fec7d360> () start_server(%s, %s) 0.0.0.0 2000 start_server: Before accept Coroutine %s yield result: %s <generator object 'start_server' at fec7d360> add_reader%s (<_socket 23>, <generator object 'start_server' at fec7d360>, ()) Next coroutine to run: %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) Coroutine %s send args: %s <generator object 'asynccontrollers' at fec9ede0> () 2017-12-15T21:41:23.004 [debug] uPyEasy-Ubuntu: Protocols: Async processing protocols Coroutine %s yield result: %s <generator object 'asynccontrollers' at fec9ede0> 0 Scheduling %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) Next coroutine to run: %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) Coroutine %s send args: %s <generator object 'asynccontrollers' at fec9ede0> () Coroutine %s yield result: %s <generator object 'asynccontrollers' at fec9ede0> 0 Scheduling %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) Next coroutine to run: %s (1513370483463, <generator object 'asynccontrollers' at fec9ede0>, ()) Coroutine %s send args: %s <generator object 'asynccontrollers' at fec9ede0> () Coroutine %s yield result: %s <generator object 'asynccontrollers' at fec9ede0> 1000 Scheduling %s (1513370484464, <generator object 'asynccontrollers' at fec9ede0>, ()) Next coroutine to run: %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ()) Coroutine %s send args: %s <generator object 'asyncdevices' at fecae500> () 2017-12-15T21:41:23.004 [debug] uPyEasy-Ubuntu: Plugins: Async processing plugins 2017-12-15T21:41:23.004 [debug] uPyEasy-Ubuntu: Plugins: Scheduling Async processing plugin: GPIO Control Scheduling %s (1513370493468, <generator object 'asyncprocess' at fec9fe40>, ()) Coroutine %s yield result: %s <generator object 'asyncdevices' at fecae500> 0 Scheduling %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ()) Next coroutine to run: %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ()) Coroutine %s send args: %s <generator object 'asyncdevices' at fecae500> () Coroutine %s yield result: %s <generator object 'asyncdevices' at fecae500> 0 Scheduling %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ()) Next coroutine to run: %s (1513370483468, <generator object 'asyncdevices' at fecae500>, ())

En now the same on an ESP32:

2000-01-01T00:00:03.005 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_http 2000-01-01T00:00:03.005 [debug] uPyEasy: Protocols: Init protocol records, run async loop Scheduling %s (4764, <generator object 'asynccontrollers' at 3ffc26d0>, ()) 2000-01-01T00:00:03.005 [debug] uPyEasy: Plugins: Load 2000-01-01T00:00:03.005 [debug] uPyEasy: Plugins: init plugin records 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Load frozen plugin gpio 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugin: gpio contruction 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Create frozen plugin Record: gpio 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Load frozen plugin ds18 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugin: ds18 contruction 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Create frozen plugin Record: ds18 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Init plugin records, run async loop Scheduling %s (5790, <generator object 'asyncdevices' at 3ffc60d0>, ()) 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugins: Init device GPIO Test 2000-01-01T00:00:04.005 [debug] uPyEasy: Plugin: gpio contruction 2000-01-01T00:00:05.005 [debug] uPyEasy: Utils: uPyEasy Name 2000-01-01T00:00:05.005 [debug] uPyEasy: Plugin: gpio init 2000-01-01T00:00:05.005 [debug] uPyEasy: Utils: Sys hostname 2000-01-01T00:00:05.005 [debug] uPyEasy: Utils: uPyEasy Name Set syslog hostname 0.0.0.0 reloaded sink syslog 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Entering SetTime 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Entering GetNtpTime 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: network Table 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Using NTP Hostname: pool.ntp.org 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: TimeZome offset: 60 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Received UTC NTP Time: 566689219 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Timezone corrected NTP Time: 566692819 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: DST corrected NTP Time: 566692819 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: Received NTP Time: 566692819 2000-01-01T00:00:05.005 [debug] uPyEasy-ESP32: Hal: StartTime: 566692819 2017-12-15T22:40:19.004 [debug] uPyEasy-ESP32: Main: Pre-loading home page 2017-12-15T22:40:19.004 [debug] uPyEasy-ESP32: Main: get_ip_address AttributeError 2017-12-15T22:40:19.004 [debug] uPyEasy-ESP32: Main: uPyEasy Main Async Loop Running on http://0.0.0.0:80/ Scheduling %s (830877930, <generator object 'start_server' at 3ffb8b40>, ()) Next coroutine to run: %s (830877930, <generator object 'start_server' at 3ffb8b40>, ()) Coroutine %s send args: %s <generator object 'start_server' at 3ffb8b40> () start_server(%s, %s) 0.0.0.0 80 start_server: Before accept Coroutine %s yield result: %s <generator object 'start_server' at 3ffb8b40> <IORead object at 3ffb7800> add_reader%s (, <generator object 'start_server' at 3ffb8b40>, ())

The ESP32 is not running the two async tasks, only the run_server task, i can't find out why. Is there a uasyncio test is can run to see if this problem is structural? Is this a timing issue? Is the queue emptied when starting up?

MrSurly commented 6 years ago

@Lisa999 This repo is deprecated -- it has been merged into https://github.com/micropython/micropython; new PRs should be filed there. Also would help if you posted your code.