* Socketcan code - http://svn.berlios.de/wsvn/socketcan/trunk
Main info site for SocketCAN http://developer.berlios.de/projects/socketcan/
$ modprobe can $ modprobe can_raw $ modprobe can_bcm $ modprobe vcan $ sudo ip link add dev vcan0 type vcan $ sudo ip link set up vcan0 $ ip link show vcan0 3: vcan0: <NOARP,UP,LOWER_UP> mtu 16 qdisc noqueue state UNKNOWN link/can "candump vcan0" tool can be used to get info.
If you need to build the kernal on Debian info is here
pcan socket CAN and charcter driver -
Hint from other hardware
Setup interface =============== modprobe can_raw modprobe can_dev insmod usb_8dev.ko (on newer kernel's (>3.2) use isnmod usb_8dev.ko ) The "8 devices" USB2CAN converter is supported by mainline linux since version 3.9. You must build it yourself on older kernels. ip link set can0 up type can bitrate 125000 sample-point 0.875 The adapter must be connected of course. Shutdown interface ================== ip link set can0 down rmmod usb_8dev Use candump can0 to view incoming traffic
If your system has a kernel < 3.9 you must download the kernel driver from here https://github.com/krumboeck/usb2can Then make sure that uou have the lnux jheaders installed apt-get install linux-headers-$(uname -r) And then issue make which should build the driver for you.
If you want to read register 0xe0 of node 1 you can issue
./cansend can0 00000900#01e0
this will return
can0 0C000A01  E0 77
in candump, if the 0xe0 register position contains 0x77 = “w”.
* Setup in german - [[http://jansblog.org/?p=400]] * [[http://www.peak-system.com/fileadmin/media/linux/files/PCAN%20Driver%20for%20Linux_eng_7.1.pdf]] * [[http://www.peak-system.com/fileadmin/media/linux/index.htm#download]]
On newer kernels the peak module is in the kernel. Use 'peak_usb'
For Lawicel adapters etc use the slcan driver. sudo slcand -s4 -S 57600 -t hw -o /dev/ttyUSB0 sudo ip link set up slcan0 * Comparison between serial adapters - http://surfnet.dl.sourceforge.net/project/socketcan.berlios/SLCAN-API.pdf
Once the driver installed and the bitrate is set, the CAN interface has to be started like a standard net interface ifconfig can0 up and can be stopped like that: ifconfig can0 down
Get socketcan version cat /proc/net/can/version The socketCAN statistics can be retrieved like that: cat /proc/net/can/stats candump: dump traffic on a CAN network The following command shows the received message from the CAN bus candump can0 cansend: simple command line tool to send CAN-frames via CAN_RAW sockets exemple : The following command sends 3 bytes on the bus (0x1E, 0x10, 0x10) with the identifier 500. cansend can0 500#1E.10.10 The information with the identifier 500 will be available on the bus when the device receive the remote request message cangen: CAN frames generator for testing purpose canplayer: send CAN frames from a file to a CAN interface These tools can be compiled and installed on the target by means of the Buildroot menuconfig: $ make menuconfig Package Selection for the target ---> Networking ---> [*] Socket CAN $ make then, reflash your rootfs.
* http://lnxpps.de/can2udpe/smallest-rocrail-server-ever/ * http://lnxpps.de/can2udpe/openwrt/