2

I have some experience using MCP2515 adapter such as this one and using SocketCAN from Linux / Raspbian to get CAN-BUS data from a vehicle.

I wanted to try something similar from Android and I've found IOIO OTG which has SPI capability. So I think I should be able to connect MCP2515 to IOIO SPI to Android and read CanBus data in my Android app.

However it's unclear if Android kernel has SocketCAN enabled. I have found an Android.mk file in SocketCAN / Linux-Can GitHub, however I've not found any notes on how it's used, and what it would expose from the Android SDK / Application layer.

Any help much appreciated!

Thanks

veggiebenz
  • 389
  • 5
  • 12
  • 1
    Look at my related [blog post](https://libbits.wordpress.com/2012/03/27/controller-area-network-can-support-in-android/), that I've created long time ago. Let me know, if someting crucial has changed. – yegorich Oct 20 '17 at 16:27
  • Thanks, I had seen this (and almost linked it in my question) but it's not clear to me if the patch in Bionic means it's now in the Android kernel. And I'm also trying to figure out how I might read from the socket -- should I just read bytes off the socket? It's also not clear to me if the situation has changed from the last few years -- have you made any progress since? The other one I found that could be interesting is this one: [SocketCanJNI](https://github.com/ZengjfOS/SocketCanJNI) – veggiebenz Oct 20 '17 at 17:33
  • I'm not actively working with this subject right now, so I don't know the state of bionic. Some patches were merged. But it must be checked whether socketcan API is available in NDK. SocketCanJNI looks like this [project](https://github.com/entropia/libsocket-can-java). This is the way to go, but, if NDK still lacks needed kernel symbols, you won't be able to compile these projects. – yegorich Oct 20 '17 at 17:47
  • Well even if there is no abstraction layer to allow CanBus to be seen as a network socket, should it be possible to read bytes from the SPI interface? Could I implement some subset of the SocketCAN in user space? Thanks, – veggiebenz Oct 20 '17 at 18:43
  • I think, yes, as SPI is natively supported in Android SDK. – yegorich Oct 20 '17 at 18:49
  • Found some other information that is helpful. [This conversation on github](https://github.com/entropia/libsocket-can-java/issues/17) informed me that the Android kernel does not currently support SocketCAN but it's possible to build custom android kernel with socketcan support if you're rooted. – veggiebenz Oct 22 '17 at 15:19

0 Answers0