在Python仿真中使用嵌入式C库
简短问题
从现有的嵌入式 C 库(在 Python 中)模拟复杂的 (SAE J1939) 通信堆栈会更容易:
1) 完整移植 - 意味着手动将所有 C 函数转换为 python 模块
2)将堆栈包装在Python包装器中 - 意思是在Python中调用真正的c代码
背景信息
我已经用 Python 编写了该堆栈的一小部分,但是以 100% 覆盖率实现它们并不简单。正是因为这个原因,我们最近为我们的嵌入式平台购买了现成的 SAE J1939 堆栈。为了澄清,我知道涉及硬件层的部分必须重新创建并映射到 PC 的 CAN 驱动程序。
我希望在这里找到有人已经或什至研究过将 5k LOC C 库移植到 Python。如果有任何运行良好的 C 到 Python 工具,对我的研究也会有帮助。
Short Question
Which would be easier to emulate (in Python) a complex (SAE J1939) communication stack from an existing embedded C library:
1) Full port - meaning manually convert all of the C functions to python modules
2) Wrap the stack in a Python wrapper - meaning call the real c code in Python
Background Information
I have already written small portions of this stack in Python, however they are very non-trival to implement with 100% coverage. Because of this very reason, we have recently purchased an off the shelf SAE J1939 stack for our embedded platforms. To clarify, I know that portions touching the hardware layer will have to be re-created and mapped to the PC's CAN drivers.
I am hoping to find someone here on SO that has or even looked into porting a 5k LOC C library to Python. If there are any C to Python tools that work well that would be helpful for me to look into as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的建议是把它包裹起来。
原因是:
但是,您需要
My advice would be to wrap it.
Reasons for that:
However, you need to
一定要包起来。运行 ctypesgen.py 然后使用它可能很简单。查看这篇关于使用 ctypesgen 为 libreadline 创建包装器的博客文章 http:// wavetossed.blogspot.com/2011/07/asynchronous-gnu-readline.html 以便访问完整的 API。
Definitely wrap it. It might be as easy are running ctypesgen.py and then using it. Check this blog article about using ctypesgen to create a wrapper for libreadline http://wavetossed.blogspot.com/2011/07/asynchronous-gnu-readline.html in order to get access to the full API.