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

esp32 uasyncio issue #246

Closed Sunrise17 closed 6 years ago

Sunrise17 commented 6 years ago

Dear @dpgeorge , i have successfully installed 'micropython-uasyncio' lib to my ESP32 board with pip method but now i am receiving following error below as soon as i have called loop = asyncio.get_event_loop() method, Why can it caused by? i am using latest build. (sysname='esp32', nodename='esp32', release='1.9.3', version='v1.9.3-286-gbbb08431 on 2018-02-09', machine='ESP32 module with ESP32')

Traceback (most recent call last):
  File "main.py", line 151, in <module>
  File "/lib/uasyncio/core.py", line 224, in get_event_loop
  File "/lib/uasyncio/__init__.py", line 21, in __init__
  File "/lib/uasyncio/core.py", line 30, in __init__
AttributeError: 'module' object has no attribute 'deque'
MicroPython v1.9.3-286-gbbb08431 on 2018-02-09; ESP32 module with ESP32
MrSurly commented 6 years ago

Looks like asyncio isn't actually implemented for MP, and only exists to prevent import errors, per the setup.py

robert-hh commented 6 years ago

@Sunrise17 You have to install uasyncio.queues too. That pulls in collections.

Sunrise17 commented 6 years ago

Dear @robert-hh , I have already installed with pip method upip.install('micropython-uasyncio.queues') still i am getting errors in same line. You can see the folder path in ESP32 board in below;

Kor-MBP:7219_MATRIX kor$ ampy ls /lib/uasyncio
__init__.py
core.py
queues.py
robert-hh commented 6 years ago

Do you also see lib/collections?

robert-hh commented 6 years ago

It seems as if the uasyncio files you download with upip are incompatible now with the micropython branch. Older copies of uasyncio file I have here work. So what you can do, is: clone https://github.com/micropython/micropython-lib from microypython-lib, copy the files from

uasyncio/uasyncio
uasyncio.core/uasyncio
uasyncio.queues/uasyncio
uasyncio.synchro/uasyncio

to a directory called uasyncio on your device (could a well be lib/uasyncio). After that, the local uasyncio directory should contains the files:

__init__.py
core.py
queues.py
synchro.py
Sunrise17 commented 6 years ago

Dear @robert-hh , thanks for your solution, and it works well now without an issue.