Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

FFI support #230

Closed
nucflash opened this issue Nov 28, 2017 · 8 comments
Closed

FFI support #230

nucflash opened this issue Nov 28, 2017 · 8 comments

Comments

@nucflash
Copy link

Hi, I need FFI support in ports/esp32 because I want to use the micropython-schedule package. I tried to build commit 292816a but it seems that the FFI library, which is an external dependency for ports/unix is not linked in ports/esp32. Can you confirm if this is the case, and if it is if there is a plan to support it in the future?

@MrSurly
Copy link
Contributor

MrSurly commented Nov 29, 2017

It appears the ffi module in the Unix port is a "Foreign Function Interface" library, correct?

And I'm assuming you mean this micropython-schedule library?

@nucflash
Copy link
Author

Yes and yes. In my understanding, micropython-schedule is internally using functools for building function partials which depends on FFI functionality.

@MrSurly
Copy link
Contributor

MrSurly commented Nov 29, 2017

Well, the functools in micropython/micropython-lib doesn't appear to need FFI.

@nucflash
Copy link
Author

You're right, my bad. Below is the error I'm getting. It seems that the time module is choking. Have you seen this before?

import schedule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/schedule/__init__.py", line 39, in <module>
  File "/lib/time.py", line 4, in <module>
ImportError: no module named 'ffi'

@MrSurly
Copy link
Contributor

MrSurly commented Nov 29, 2017

The time module in micropython/micropython-lib will only work on the Unix port, because it's using FFI to access libc for the time functions.

There's a built-in µPy time module in the ESP32 firmware. It appears that that time module will probably work with the micropython-schedule; seems to have all the necessary functions. Should just be a matter of deleting time.py from your ESP32 filesystem.

@MrSurly
Copy link
Contributor

MrSurly commented Nov 29, 2017

@dpgeorge Why do we have a "pure" Python time library that will only work on Unix (i.e. not at all pure)? Why not a built-in C time library?

@dpgeorge
Copy link
Member

Why do we have a "pure" Python time library that will only work on Unix

Good question! The history of the micropython-lib repo is that it was intended to be individual add-on modules for the unix port of uPy. But over time some of the modules there have been written to target all ports of uPy (eg uasyncio, umqtt), and some other modules might work on any port because they are "pure".

@dpgeorge
Copy link
Member

ffi is not supported on esp32. To get micropython-schedule working on the esp32 would require modifying it to not rely on ffi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants