MicroPython imports a binary format class library through the import
directive?
#14481
Replies: 2 comments
-
CPython does this via ctypes. The equivalent library in MicroPython is uctypes. Unfortunately this does not have |
Beta Was this translation helpful? Give feedback.
-
If you have access to the C/C++ code, you can build a dynamic native module. This can be built separately from main firmware, copied to device and loaded at runtime. See the documentation https://docs.micropython.org/en/latest/develop/natmod.html#supported-features-and-limitations and the examples https://github.com/micropython/micropython/tree/master/examples/natmod |
Beta Was this translation helpful? Give feedback.
-
MicroPython imports a binary format class library through the
import
directive? Just like Python, the class library file (mylib.so) that uses C/C++ extension can be used directly after importing it throughimport mylib
, but MicroPython can only import files in .py or .mpy format. I don’t know if it can Import files in so format?Or, where should I start modifying the source code?
PS: This class library is loaded dynamically, and I don’t want to compile it into MicroPython’s firmware.
MicroPython 通过
import
指令导入一个二进制格式的类库?就像Python 一样,使用C/C++ 扩展的类库文件(mylib.so) 通过import mylib
导入后就可以直接使用了,但是 MicroPython只能导入 .py或者.mpy 格式的文件,不知道是否能导入 so 格式的文件?或者,我应该从哪里入手修改源代码?
PS:这个类库是动态化加载进去的,我不想将它编译到 MicroPython的固件中。
Beta Was this translation helpful? Give feedback.
All reactions