I.MX6 Android can-utils 移植

/*******************************************************************
 *                  I.MX6 Android can-utils 移植
 * 说明:
 *     由于最近要用到CAN,于是先移植一下can-tuils来看一下情况。
 *
 *                                  2016-8-1 深圳 南山平山村 曾剑锋
 ******************************************************************/

一、获取源码:
    https://github.com/linux-can/can-utils

二、错误现象:
    target thumb C: slcan_attach <= /home/myzr/myandroid/packages/apps/can-utils/slcan_attach.c
    /home/myzr/myandroid/packages/apps/can-utils/slcan_attach.c: In function 'main':
    /home/myzr/myandroid/packages/apps/can-utils/slcan_attach.c:81:14: error: 'N_SLCAN' undeclared (first use in this function)
    /home/myzr/myandroid/packages/apps/can-utils/slcan_attach.c:81:14: note: each undeclared identifier is reported only once for each function it appears in
    make: *** [out/target/product/sabresd_6dq/obj/EXECUTABLES/slcan_attach_intermediates/slcan_attach.o] Error 1
    make: Leaving directory `/home/myzr/myandroid'

三、查看N_SLCAN情况:
    1. 直接查看:
        myzr@myzr:~/myandroid/packages/apps/can-utils$ grep N_SLCAN * -R
        configure.ac:AC_CHECK_DECL(N_SLCAN,,
        configure.ac:    [AC_DEFINE([N_SLCAN], [17], [N_SLCAN])]
        slcan_attach.c:    int ldisc = N_SLCAN;
        slcand.c:    int ldisc = N_SLCAN;
    2. 执行autogen.sh再查看:
        myzr@myzr:~/myandroid/packages/apps/can-utils$ ./autogen.sh 

        ----------
        autoreconf
        ----------

        Can't exec "libtoolize": No such file or directory at /usr/bin/autoreconf line 196.
        Use of uninitialized value in pattern match (m//) at /usr/bin/autoreconf line 196.
        configure.ac:9: installing `config/autoconf/config.guess'
        configure.ac:9: installing `config/autoconf/config.sub'
        configure.ac:22: installing `config/autoconf/install-sh'
        configure.ac:22: installing `config/autoconf/missing'
        GNUmakefile.am:25: Libtool library used but `LIBTOOL' is undefined
        GNUmakefile.am:25:   The usual way to define `LIBTOOL' is to add `LT_INIT'
        GNUmakefile.am:25:   to `configure.ac' and run `aclocal' and `autoconf' again.
        GNUmakefile.am:25:   If `LT_INIT' is in `configure.ac', make sure
        GNUmakefile.am:25:   its definition is in aclocal's search path.
        GNUmakefile.am: installing `config/autoconf/depcomp'
        autoreconf: automake failed with exit status: 1
        myzr@myzr:~/myandroid/packages/apps/can-utils$ grep N_SLCAN * -R
        autom4te.cache/output.1:ac_fn_c_check_decl "$LINENO" "N_SLCAN" "ac_cv_have_decl_N_SLCAN" "$ac_includes_default"
        autom4te.cache/output.1:if test "x$ac_cv_have_decl_N_SLCAN" = xyes; then :
        autom4te.cache/output.1:$as_echo "@%:@define N_SLCAN 17" >>confdefs.h
        autom4te.cache/output.0:ac_fn_c_check_decl "$LINENO" "N_SLCAN" "ac_cv_have_decl_N_SLCAN" "$ac_includes_default"
        autom4te.cache/output.0:if test "x$ac_cv_have_decl_N_SLCAN" = xyes; then :
        autom4te.cache/output.0:$as_echo "@%:@define N_SLCAN 17" >>confdefs.h
        autom4te.cache/traces.0:m4trace:configure.ac:86: -1- m4_pattern_allow([^N_SLCAN$])
        autom4te.cache/traces.1:m4trace:configure.ac:86: -1- AC_DEFINE_TRACE_LITERAL([N_SLCAN])
        autom4te.cache/traces.1:m4trace:configure.ac:86: -1- m4_pattern_allow([^N_SLCAN$])
        autom4te.cache/traces.1:m4trace:configure.ac:86: -1- AH_OUTPUT([N_SLCAN], [/* N_SLCAN */
        autom4te.cache/traces.1:@%:@undef N_SLCAN])
        configure:ac_fn_c_check_decl "$LINENO" "N_SLCAN" "ac_cv_have_decl_N_SLCAN" "$ac_includes_default"
        configure:if test "x$ac_cv_have_decl_N_SLCAN" = xyes; then :
        configure:$as_echo "#define N_SLCAN 17" >>confdefs.h
        configure.ac:AC_CHECK_DECL(N_SLCAN,,
        configure.ac:    [AC_DEFINE([N_SLCAN], [17], [N_SLCAN])]
        slcan_attach.c:    int ldisc = N_SLCAN;
        slcand.c:    int ldisc = N_SLCAN;
        myzr@myzr:~/myandroid/packages/apps/can-utils$ 

四、解决办法:
    slcan_attach.c slcand.c 中添加 #define N_SLCAN 17 宏定义。

五、测试命令:
    root@android:/data/local # ./cangen                                            

    cangen: generate CAN frames

    Usage: cangen [options] <CAN interface>
    Options: -g <ms>       (gap in milli seconds - default: 200 ms)
             -e            (generate extended frame mode (EFF) CAN frames)
             -f            (generate CAN FD CAN frames)
             -b            (generate CAN FD CAN frames with bitrate switch (BRS))
             -R            (send RTR frame)
             -m            (mix -e -f -b -R frames)
             -I <mode>     (CAN ID generation mode - see below)
             -L <mode>     (CAN data length code (dlc) generation mode - see below)
             -D <mode>     (CAN data (payload) generation mode - see below)
             -p <timeout>  (poll on -ENOBUFS to write frames with <timeout> ms)
             -n <count>    (terminate after <count> CAN frames - default infinite)
             -i            (ignore -ENOBUFS return values on write() syscalls)
             -x            (disable local loopback of generated CAN frames)
             -v            (increment verbose level for printing sent CAN frames)

    Generation modes:
    'r'        => random values (default)
    'i'        => increment values
    <hexvalue> => fix value using <hexvalue>

    When incrementing the CAN data the data length code minimum is set to 1.
    CAN IDs and data content are given and expected in hexadecimal values.

    Examples:
    cangen vcan0 -g 4 -I 42A -L 1 -D i -v -v   (fixed CAN ID and length, inc. data)
    cangen vcan0 -e -L i -v -v -v              (generate EFF frames, incr. length)
    cangen vcan0 -D 11223344DEADBEEF -L 8      (fixed CAN data payload and length)
    cangen vcan0 -g 0 -i -x                    (full load test ignoring -ENOBUFS)
    cangen vcan0 -g 0 -p 10 -x                 (full load test with polling, 10ms timeout)
    cangen vcan0                               (my favourite default :)

    root@android:/data/local # 

 

时间: 2024-09-20 10:46:21

I.MX6 Android can-utils 移植的相关文章

I.MX6 Android frameworks services 文件架构

/******************************************************************************* * I.MX6 Android frameworks services 文件架构 * 说明: * 这部分内容后续可能需要多给一点注意力了,因为这部分在做系统移植的时候经常 * 需要通过这部分来进行调试. * 2016-3-19 深圳 南山平山村 曾剑锋 ******************************************

I.MX6 Android stlport 使用

/****************************************************************** * I.MX6 Android stlport 使用 * 说明: * 在移植JNI过程中使用了C++ stlport lib,而在Android源码中编译 * 和在NDK中使用,其配置方式是不一样. * * 2016-8-11 深圳 南山平山村 曾剑锋 *******************************************************

I.MX6 Android 移除 Settings wifi功能

/********************************************************************* * I.MX6 Android 移除 Settings wifi功能 * 说明: * 本文主要记录如何修改Android Settings中的主选项,初衷是有些 * 设置并不是我们需要,隐藏掉还是比较好的. * * 2016-3-5 深圳 南山平山村 曾剑锋 *************************************************

I.MX6 Android i2c-tools porting

/************************************************************************** * I.MX6 Android i2c-tools porting * 说明: * 判断I2C总线设备是否存在,每次都去查dmesg,实在是烦了,于是还是移植 * 一个i2c-tools比较好,不用翻那长长内核信息. * * 2016-3-31 深圳 南山平山村 曾剑锋 **************************************

I.MX6 Android netperf

/***************************************************************************** * I.MX6 Android netperf * 说明: * 之前移植iperf3网络测试工具不成功,本来想再移植一个iperf2来试一下,但是 * 在检查Android源码系统的时候不小心看到netperf文件夹,查了点资料,貌似可以实 * 现iperf的功能,于是又省了点事. * * 2016-4-18 深圳 南山平山村 曾剑锋 **

I.MX6 Android iperf3 porting failed

/***************************************************************************** * I.MX6 Android iperf3 porting failed * 说明: * 本来想移植一下iperf3到Android系统上测试一下网卡,可能是版本高了点,最后 * 运行客户端的时候会报错,也找了一些解决办法,但还是未能解决. * * 2016-4-5 深圳 南山平山村 曾剑锋 ***********************

I.MX6 AW-NB177NF WIFI 驱动移植问题

/******************************************************************************** * I.MX6 AW-NB177NF WIFI 驱动移植问题 * 说明: * 之前驱动移植,但看不到有wlan设备产生,于是感觉是wifi驱动出了问题,于是开始 * 分析厂家提供的wifi驱动,发现id对应的信息不对,经过与FAE确认之后并验证,确实是 * 这个问题导致的. * * 2016-6-20 深圳 南山平山村 曾剑锋 ***

I.MX6 android BatteryService jni hacking

/**************************************************************************** * I.MX6 android BatteryService jni hacking * 声明: * 本文主要是为了知道Android的获取的电源管理的数据的jni是从Linux系统的 * 什么位置获取的,获取的机制是什么. * * 2016-2-22 深圳 南山平山村 曾剑锋 ********************************

I.MX6 Android USB Touch eGTouchA.ini文件存放

/******************************************************************** * I.MX6 Android USB Touch eGTouchA.ini文件存放 * 声明: * 本文主要记录徐远志在移植eGTouch USB Touch Android驱动过程中遇到的 * eGTouchA.ini文件存放问题如何解决. * * 2016-2-25 深圳 南山平山村 曾剑锋 ******************************