pikasTech / PikaPython

An ultra-lightweight Python interpreter that runs with only 4KB of RAM, zero dependencies. It is ready to use out of the box without any configuration required and easy to extend with C. Similar project: MicroPython, JerryScript.
http://pikapython.com/
MIT License
1.45k stars 132 forks source link

可以实现C调用Python或Python的函数指针传给C使用 #317

Closed ThinkCodeStudio closed 1 year ago

ThinkCodeStudio commented 1 year ago

我想让C主动调用Python函数, 或是像回调的机制. 比如我预先在C上写了一些中断和通信协议, 当我连接设备时, 设备中断触发, 调用了Python驱动脚本注册设备, 然后当我发送消息时, 设备接收消息然后发给Python处理.

pikasTech commented 1 year ago

可以参考事件回调机制的源码和相关代码:http://pikapython.com/doc/coreapi_event.html