===== CAN ===== ==== CAN configuration STKa8Xx ==== DIP switch SW1 and SW2 are used to configure the CAN interfaces CAN1 and CAN2. \\ {{:intern:general_information:tutorial:mba8xx-can.png?400|{{:intern:general_information:tutorial:mba8xx-can.png?400|}} \\ ==== List available CAN Interfaces ==== root@MBaXXX:~ ip link show output: 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: can0: mtu 16 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 10 link/can 3: can1: mtu 16 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 10 link/can \\ ==== Activate CAN Interface ==== root@MBaXXX:~ ip link set can0 up root@MBaXXX:~ ip link set can1 up \\ ==== Change Default CAN Bitrate ==== root@MBaXXX:~ ip link set can0 down root@MBaXXX:~ ip link set can1 down root@MBaXXX:~ ip link set can0 type can bitrate root@MBaXXX:~ ip link set can1 type can bitrate \\ ==== Loopback Test CAN Interface ==== * Connect wires to the provided PHOENIX connectors from the Starterkit as shown below.\\ {{:intern:general_information:tutorial:mba8xx-can-loop.png?400|}} \\ * Following command examples shows how to test the CAN interface root@MBaXXX:~ ip link set can0 down root@MBaXXX:~ ip link set can1 down root@MBaXXX:~ ip link set can0 type can bitrate 500000 root@MBaXXX:~ ip link set can1 type can bitrate 500000 root@MBaXXX:~ ip link set can0 up root@MBaXXX:~ ip link set can1 up root@MBaXXX:~ candump can1& root@MBaXXX:~ cansend can0 5A1#11.2233.44556677.88 output: root@tqma8xqp-mba8xx:~# can1 5A1 [8] 11 22 33 44 55 66 77 88 root@MBaXXX:~ killall candump root@MBaXXX:~ candump can0& root@MBaXXX:~ cansend can1 5A1#11.2233.44556677.88 output: root@tqma8xqp-mba8xx:~# can0 5A1 [8] 11 22 33 44 55 66 77 88 ==== setting CAN bautrate ==== root@MBaXXX:~ canconfig can bitrate ++++ example | root@MBAXXX:~ canconfig can0 bitrate 500000 ++++ ==== Activate CAN Interface ==== root@MBaXXX:~ ifconfig can up ++++ example | root@MBaXXX:~ ifconfig can0 up ++++ ==== CAN Test CAN0 to CAN1 ==== root@MBaXXX:~ candump can1& root@MBaXXX:~ cansend can0 ++++ example | root@MBaXXX:~ candump can1& root@MBaXXX:~ cansend can0 0x01 0x10 ++++