CAN interface missing in NDK platforms

495 views
Skip to first unread message

Palsson

unread,
Aug 31, 2011, 4:01:20 AM8/31/11
to android-ndk
Hello,

Hardware: TI's AM3517 evaluation kit.
OS Release: Android Froyo

The socketCAN (berlios) interface is included in the Android Linux
kernel (Froyo release).
But when browsing the kernel header files for the NDK platforms it is
missing and following includes in my native code creates errors:
#include <linux/can.h>
#include <linux/can/raw.h>

The error is simply, file not found.
I need to be able to access the canbus interface on my platform.
It would be nice to be able to use some of the can-utils within the
socketcan project.
Therefore I would like to test it, by compiling the utilities with
NDK.

Is it possible to add the socketCAN interface to a custom NDK
platform?

Regards
Palsson

David Turner

unread,
Aug 31, 2011, 5:04:30 AM8/31/11
to andro...@googlegroups.com
Hello,

On Wed, Aug 31, 2011 at 10:01 AM, Palsson <palss...@gmail.com> wrote:
Hello,

Hardware: TI's AM3517 evaluation kit.
OS Release: Android Froyo

The socketCAN (berlios) interface is included in the Android Linux
kernel (Froyo release).
But when browsing the kernel header files for the NDK platforms it is
missing and following includes in my native code creates errors:
#include <linux/can.h>
#include <linux/can/raw.h>

The error is simply, file not found.

As stated in the NDK documentation (see docs/STABLE-APIS.html), the kernel interface headers
are not considered part of the stable APIs provided by the NDK. This also mean there is no guarantee
at all that the type of socket interface you're interested in will be supported by each Android device's kernel,
or even that you can access it from an application (due to lack of adequate permissions).
 
I need to be able to access the canbus interface on my platform.
It would be nice to be able to use some of the can-utils within the
socketcan project.
Therefore I would like to test it, by compiling the utilities with
NDK.

Is it possible to add the socketCAN interface to a custom NDK
platform?

If you're building your own platform, and still want to use the NDK to build your utilities, simply copy the relevant kernel headers files to the appropriate location (e.g. $NDK/platforms/android-8/arch-arm/usr/include if you're targetting Froyo).

 
Regards
Palsson

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Palsson

unread,
Aug 31, 2011, 6:07:20 AM8/31/11
to android-ndk
Thanks David,

Is it that simple :-)
I'll try that..

Regards
Palsson

On Aug 31, 11:04 am, David Turner <di...@android.com> wrote:
> Hello,
>

Palsson

unread,
Aug 31, 2011, 9:07:46 AM8/31/11
to android-ndk
Hello again,

Well not working.
If I copy my missing header files to what I think is the proper
location.. $NDK/platforms/android-8/arch-arm/usr/include/linux
the build system is still not finding them.
I might be missing something, but do I have to make some sort of ndk-
build clean, for the build-system to search "again" for header files
from that location?
Sorry if I'm lacking some basics here.

/Palsson

David Turner

unread,
Aug 31, 2011, 9:10:56 AM8/31/11
to andro...@googlegroups.com
On Wed, Aug 31, 2011 at 3:07 PM, Palsson <palss...@gmail.com> wrote:
Hello again,

Well not working.
If I copy my missing header files to what I think is the proper
location.. $NDK/platforms/android-8/arch-arm/usr/include/linux
the build system is still not finding them.
I might be missing something, but do I have to make some sort of ndk-
build clean, for the build-system to search "again" for header files
from that location?
Sorry if I'm lacking some basics here.

No, are you targetting API level 8, i.e. do you use APP_PLATFORM := android-8 in your Application.mk, or does your manifest states a minimum SDK version of 8?
If not, you're targetting android-3 by default (which is 1.5 a.k.a. Cupcake).

Palsson

unread,
Sep 1, 2011, 11:20:09 AM9/1/11
to android-ndk
Hello David,

Thanks man.
Its my bad.. android-3 and android-8 got mixed up.
Now it compiles.

Would you know, how to include the ip tool for net interface config.
It seems like the netcfg tool is only available, and the problem is
that the bitrate for the can0 interface can't be configured using
netcfg.
When you enter netcfg can0 up, it complains that the bitrate is not
set.
This can be done very smoothly using the ip tool, ...
# ip link set can0 type can bitrate 125000
# ip link set can0 up

It comes with the linux distribution for my AM3517 nut kind of
frustrating that it is not in Android.

Regards
Palsson

On Aug 31, 3:10 pm, David Turner <di...@android.com> wrote:

David Turner

unread,
Sep 1, 2011, 5:59:39 PM9/1/11
to android...@googlegroups.com
I'm redirecting this thread to android-porting because it no longer has anything to do with the NDK.
Maybe some folks here will better be able to help you.
Reply all
Reply to author
Forward
0 new messages