Hi everyone,
I am a bit new to micropython and python is general.
So i have successfully call python functions in C code using micropython library.
Now i want to do the other way around, calling C function in python code using micropython library.
How would i do that ? Can someone give me an extremely simple example on that ? I am aware that i can use Ctypes in python and load cdll file but it wont work when I load it on a MCU chip since the chip wont have any system file.
thanks
How to call C function in python code
Re: How to call C function in python code
You need to create a C module which exports functions which are callable from python.
See this thread here: viewtopic.php?f=16&t=2861&p=19206#p19206
See this thread here: viewtopic.php?f=16&t=2861&p=19206#p19206
Re: How to call C function in python code
so for the c_sample.c, do i need to flash it onto a chip before i can run it on terminal ?
if so, is there a way just to test it on console output without flashing it on chip ?
if so, is there a way just to test it on console output without flashing it on chip ?
Re: How to call C function in python code
Currently, you'll need to build and flash custom firmware. The unix port is the only port which supports dynamic linking of code (via FFI).