Groups:Biosystems Engineering SDU:Can4linux HowTo

From FroboMind [www.frobomind.org]
Jump to: navigation, search

Setting up can4linux

This document contain a guide for setting up the PCM3680 CANbus device for linux.

1. Download the source code.

2. Unpack it to /opt/can4linux

3. Setting up device:

cd /opt/can4linux/can4linux/etc
cp 1-PCM3680.conf [computername].conf

Example: If the name of the computer is frobobox the file need to be named frobobox.conf

sudo nano [computername].conf

4. Set following parameters in the configuration file just made:

debug=0

# Can-channel 0
############################
Base_0=0xda00
Irq_0=12
Baud=500

# Can-channel 1
############################
Base_0=0xda20
Irq_0=15
Baud=500

Above parameters might differ from system to system. Please refer to hardware for correct configuration. - Exit editor - Compile source

cd ..
sudo make
sudo make TARGET=PCM3680
sudo make load TARGET=PCM3680

Test the PCM3680 board:

cd ../can4linux-examples
make
sudo ./noiser can0
sudo ./noiser can1


Now we can create the init.d script that loads the can4linux kernel module during boot.

cd /etc/init.d
sudo touch can4linux
sudo chmod +x can4linux

Open the 'can4linux' file with your favorite editor (nano/vi/emacs) and paste the folowing into the file:

#!/bin/sh
# /etc/init.d/can4linux
#
touch /var/lock/can4linux
case "$1" in
 start)
   cd /opt/can4linux/can4linux
   make TARGET=PCM3680 load
   chgrp dialout /dev/can0
   chgrp dialout /dev/can1
   chgrp dialout /dev/can2
   chgrp dialout /dev/can3
   echo "can4linux loaded"
   ;;
 stop)
   cd /opt/can4linux/can4linux
   make TARGET=PCM3680 unload
   echo "can4linux unloaded"
   ;;
 *)
   echo "Usage: /etc/init.d/can4linux {start|stop}"
   exit 1
   ;;
esac
exit 0

update-rc.d can4linux defaults

To test if the service works as expected:

ls /dev/can*