简体   繁体   中英

SocketCAN C# using mono

I am really new to mono and C# but I want to use sockets to open a communication via CAN. The problem is that a lot of protocol an adress families are implemented but CAN ist not supported by mono so far. The system kernel supports it but it is not possible for me to patch the files in this way to get down to the SystemCall Level. So if someone reads this who is part of the really nice mono developing community please help me and a lot of other guys out there who needs this function. Since three weeks I googled anything and tried to find my own workaround to get it on but until now no success. Even if my problem won't be solved with this question here at stackvoerflow I hope to motivate someone who is better in improving mono and hard code than me, so that other guys will be able to work easy with CAN and mono. SI think the base problem is, that the Variables AF_CAN and PF_CAN are not implemented in mono. I tried my best by adjusting these files by adding PF_CAN and AF_CAN with Value 29 but it does not work for me

.../mono-3.2.8/mono/metadata/socket-io.c
.../mono-3.2.8/mcs/class/System/System.Net.Sockets/AddressFamily.cs
.../mono-3.2.8/mcs/class/System/System.Net.Sockets/ProtocolFamily.cs

I hope for help because its all there but I am not able to put it all together. With C it is easy to open a socket this way and the CAN bus works fine but with mono a small stone is missing to get it all to work.

best regards Ben

The easiest workaround would be to write a library in C, that handles SocketCAN stuff and then just invoke the library calls from C# code. See this tutorial .

Alternative you can take a look at socketcand and implement its TCP based API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM