/********************************************************************* * I.MX6 Android CAN 命令行测试 * 说明: * 这里使用can-utils测试一下CAN驱动。 * * 2016-8-9 深圳 南山平山村 曾剑锋 ********************************************************************/ 一、shell 命令流程: 1. netcfg can0 down 2. ip link set can0 type can bitrate 1000000 triple-sampling on(或者:ip link set can0 up type can bitrate 1000000) 3. ip -details -statistic link show can0 4. netcfg can0 up 5. ./cansend can0 111#1122334455667788 6. ip -details -statistic link show can0 7. ./canfdtest -vv can0 8. ip -details -statistic link show can0 二、运行流程: root@android:/ # netcfg can0 down root@android:/ # ip link set can0 type can bitrate 1000000 triple-sampling on root@android:/ # ip -details -statistic link show can0 2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN qlen 10 link/can can <TRIPLE-SAMPLING> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0 bitrate 1000000 sample-point 0.733 tq 66 prop-seg 5 phase-seg1 5 phase-seg2 4 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 RX: bytes packets errors dropped overrun mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 root@android:/ # netcfg can0 up flexcan imx6q-flexcan.0: writing ctrl=0x01232084 127|root@android:/ # cd /data/local root@android:/data/local # ./cansend can0 111#1122334455667788 root@android:/data/local # ip -details -statistic link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10 link/can can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 bitrate 1000000 sample-point 0.733 tq 66 prop-seg 5 phase-seg1 5 phase-seg2 4 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 RX: bytes packets errors dropped overrun mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 8 1 0 0 0 0 root@android:/data/local # ip -details -statistic link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10 link/can can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 bitrate 1000000 sample-point 0.733 tq 66 prop-seg 5 phase-seg1 5 phase-seg2 4 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 RX: bytes packets errors dropped overrun mcast 8 1 0 0 0 0 TX: bytes packets errors dropped carrier collsns 8 1 0 0 0 0 root@android:/data/local # ./canfdtest -vv can0 interface = can0, family = 29, type = 3, proto = 1 0037: [8] 37 37 37 37 37 70 c9 00 0037: [8] 37 37 37 37 37 70 c9 00 0037: [8] 37 37 37 37 37 70 c9 00 0037: [8] 37 37 37 37 37 70 c9 00 ^Crecv failed: Bad file number Exiting... 255|root@android:/data/local # ip -details -statistic link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10 link/can can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 bitrate 1000000 sample-point 0.733 tq 66 prop-seg 5 phase-seg1 5 phase-seg2 4 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 RX: bytes packets errors dropped overrun mcast 40 5 0 0 0 0 TX: bytes packets errors dropped carrier collsns 40 5 0 0 0 0 root@android:/data/local #