diff --git a/tests/conn_can/README.md b/tests/conn_can/README.md index cd1e552492..82ef815fdb 100644 --- a/tests/conn_can/README.md +++ b/tests/conn_can/README.md @@ -3,6 +3,59 @@ tests/conn_can Demo application for the CAN stack with conn_can interface. +Native prerequisites +============ +For using the can stack on top of socketCAN, available for linux, you need: +- socketCAN (part of kernel starting from 2.6.25) +- install the 32bit version of libsocketcan: + +if you're on a 64bit system: +``` +sudo dpkg --add-architecture i386 +sudo apt-get update +sudo apt-get install libsocketcan-dev:i386 +``` +On 32 bit you can just do the following: +``` +sudo apt-get install libsocketcan-dev +``` + +Alternatively, you can compile from source: +``` +wget http://www.pengutronix.de/software/libsocketcan/download/libsocketcan-0.0.11.tar.bz2 + +$ tar xvjf libsocketcan-0.0.11.tar.bz2 + +$ rm -rf libsocketcan-0.0.11.tar.bz2 + +$ cd libsocketcan-0.0.11 + +$ ./configure + +compile in 32bits + +./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAG + +$ make + +$ sudo make install + + +sudo ldconfig +/usr/local/lib +``` + +The default native configuration defines two virtual can ifaces to be used. +Before running this test on native, you should create those: + +``` +sudo modprobe vcan +sudo ip link add dev vcan0 type vcan +sudo ip link add dev vcan1 type vcan +sudo ip link set vcan0 up +sudo ip link set vcan1 up +``` + Usage ===== @@ -84,3 +137,36 @@ sampling point 87.5%: ``` test_can set_bitrate 250000 875 ``` + +Linux CAN basic commands +======================== + +Once the interfaces are set up, can-utils commands provide a way to send and receive +raw CAN frames and ISO-TP datagrams. + +For ISO-TP, an experimental module for linux can be found [here](https://github.com/hartkopp/can-isotp). +It needs to be loaded before trying to use ISO-TP protocol. + +Here are some basics examples. + +Send a raw CAN frame, id 0x100, data 00 11 22: +``` +cansend vcan0 100#001122 +``` + +Dump the traffic on a CAN interface: +``` +candump vcan0 +``` + +Send an ISO-TP datagram, source id 700, dest id 708, data 00 11 22 33 aa bb cc dd: +``` +echo 00 11 22 33 aa bb cc dd | isotpsend -s 700 -d 708 vcan0 +``` + +Receive ISO-TP datagram: +``` +isotprecv -s 708 -d 700 vcan0 +``` + +Please read commands help for more details on usage. \ No newline at end of file