使用C#操作ARM CAN总线驱动程序 [英] Operating ARM CAN Bus Drivers Using C#

查看:406
本文介绍了使用C#操作ARM CAN总线驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在做我的MSc项目,我在使用C#驾驶我的CAN总线时遇到问题。



我正在使用这个基于ARM的HMI和来自制造商网页的Windows CE 6.0支持的BSP源文件:

http://www.technexion.com/index.php/products/hmi/th-0735w [ ^ ]



有一个用C ++编写的CAN总线示例,我已成功测试过。我使用C#设计了我的应用程序,我希望在我的应用程序中包含CAN总线。我不知道如何将C#与CAN总线驱动程序联系起来。我有几个.dll文件,我认为omap_can.dll是与CAN总线驱动程序相关的文件。



我指的是本手册(CAN驱动程序部分)用于调用CAN驱动程序,因为TechNexion不提供任何文档:

http://processors.wiki.ti.com/index.php/WinCE-BSP_ARM-A8_User_Guide#CAN_Setup_and_Demo [ ^ ]



我搜索了如何使用在线调用但是我在代码中做错了。生成代码的应用程序p / invoke不会打开omap_can.dll,所以我必须自己键入它。



我的Dependency Walker应用程序用于查看omap_can.dll的内容会显示消息错误:由于隐式依赖模块中缺少导出功能,至少有一个模块具有未解析的导入。并允许我查看功能(与ARM指南相反略有不同的名称):

CAN_Close

CAN_Deinit

CAN_Init

CAN_IOControl

CAN_Open

CAN_PowerDown

CAN_PowerUp



我可以还看到omap_can.dll与cedk.dll,coredll.dll和fpcrt.dll链接。



我真的需要了解我在做什么,因为我几乎尝试随机解决方案。



我试图使用C#调用函数CAN_Init。这是我的代码(它在Visual Studio 2005中编译,但在设备上使用时崩溃):



Hello,

I am doing my MSc project and I am having a problem driving my CAN bus using C#.

I am using this ARM based HMI and the supported BSP source files for Windows CE 6.0 coming from the manufacturer's webpage:
http://www.technexion.com/index.php/products/hmi/th-0735w[^]

There is a CAN bus example written in C++ which I have successfully tested. I have designed my application using C# and I want to include CAN bus in my application. I don't know how to link C# with CAN bus drivers. I have several .dll files and I think the omap_can.dll is the one associated with the CAN bus drivers.

I am referring to this manual (CAN Driver section) for invoking the CAN driver because TechNexion does not provide any documentation:
http://processors.wiki.ti.com/index.php/WinCE-BSP_ARM-A8_User_Guide#CAN_Setup_and_Demo[^]

I searched how to use invoke online but I am doing something wrong in my code. The application p/invoke which generates the code does not open the omap_can.dll, so I have to type it properly on my own.

The Dependency Walker application that I used to see the contents of omap_can.dll gives the message "Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module." and allows me to view the functions (slightly different names as opposed to the ARM guide):
CAN_Close
CAN_Deinit
CAN_Init
CAN_IOControl
CAN_Open
CAN_PowerDown
CAN_PowerUp

I can also see that the omap_can.dll is linked with the cedk.dll, coredll.dll and fpcrt.dll.

I really need to understand what I am doing because I almost try random solutions.

I was attempt to call a function "CAN_Init" using C#. Here is my code (it compiles in Visual Studio 2005, but crashes when used on the device):

namespace HMIShell
{
    public partial class HMIShell : Form
    {
        [DllImport("\\Storage Card\\omap_can.dll")]
        public static extern void CAN_Init(); // I am not sure about this line

        public HMIShell()
        {
            InitializeComponent(); // Automatically generated method for windows forms
            CAN_Init(); // This part fails
        }





提前谢谢。



Thank you in advance.

推荐答案

这篇关于使用C#操作ARM CAN总线驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆