-
Notifications
You must be signed in to change notification settings - Fork 18
Peak pc 104 plus quad with socketcan
( For Peak PCI Can Cards: http://www.peak-system.com/PCAN-PC-104-Plus-Quad.286.0.html?&L=1 )
The instructions here are command terminal based. It is assumed that you are interacting with hubo through ssh. Everything following a dollar sign ($) is the command which should go into the terminal. A tilde () refers to the home directory. Everything between tilde-slash (/) and dollar sign ($) refers to the directory you should be in.
-
- First make sure you have all the prerequisites installed:
~$ sudo apt-get update ~$ sudo apt-get install gcc ~$ sudo apt-get install g++ ~$ sudo apt-get install libpopt-dev
-
- If it doesn't exist already, create a "Downloads" folder:
~$ mkdir Downloads
and then go to it:
~$ cd Downloads
-
- Download the pcan driver from Peak (http://www.peak-system.com/fileadmin/media/linux/index.htm) using the following command. In this tutorial, the latest driver was 7.7. If a newer driver has been released, replace the 7.7 below with the numbers for the new version:
~/Downloads$ wget http://www.peak-system.com/fileadmin/media/linux/files/peak-linux-driver-7.7.tar.gz
-
- Extract the downloaded file (7.7 may need to be replaced if you downloaded a newer version):
~/Downloads$ tar -xzf peak-linux-driver-7.7.tar.gz
-
- Check to make sure that Linux headers are installed.
First, find out what kernel you are running:
~/Downloads$ uname -r
Then copy/paste that into the following command where 'uname -r' is currently located (and remove the quotes):
~/Downloads$ cat /lib/modules/'uname -r'/build/include/linux/version.h
If you do NOT receive a line saying "No such file or directory", then your headers are installed and you should move onto the next step. Otherwise, run the following command:
~/Downloads$ sudo apt-get install linux-headers-'uname -r'
Once again, replace 'uname -r' with your kernel version.
-
- Now enter the driver source directory:
~/Downloads$ cd peak-linux-driver.7.7.tar.gz
-
- Make sure everything is clean (it should already be as long as you've been following these steps precisely):
~/Downloads/peak-linux-driver-7.7$ sudo make clean
-
- Instruct everything to build:
~/Downloads/peak-linux-driver-7.7$ sudo make
Watch carefully for errors. You should see "Entering Directory User:Dlofaro" followed by "Leaving Directoy User:Dlofaro" several times. Make sure that the word "error" never shows up in between any of these pairs. If it does, try to see what caused the error (most likely a missing library) and see if you're able to install that library using "sudo apt-get install ~" (Step 0). Then repeat steps 6 and 7.
-
- If everything built without an error, install the driver to the system:
~/Downloads/peak-linux-driver-7.7$ sudo make install
-
- Then probe your system for pcan devices:
~/Downloads/peak-linux-driver-7.7$ sudo /sbin/modprobe pcan
-
- And check your system to make sure that your card is being recognized:
~/Downloads/peak-linux-driver-7.7$ ifconfig -a
If the command above displays a list which includes can0, can1, can2, and can3, then everything should be operational. If not, make sure you followed the steps above correctly. If you did, then you will need to check that your physical Peak CAN Card was put in the stack correctly.
-
- You can also look at statistics for the four devices:
~$ cat /proc/pcan
will print out a chart giving some basic information for can0-3. You can also watch it in real-time with the following command:
~$ watch cat /proc/pcan
-
- You can change the bit rate of the devices using the echo command as follows:
~$ sudo echo "i 0x0014 e" > /dev/pcan0
This sets the bit rate of pcan0 to 1Mbit/s. Change "pcan0" to "pcanX" for any of the other devices. Change "0x0014" to a different value (these are enumerated below) for a different bit rate.
0x0014 :: 1 Mbit/s 0x001C :: 500 kbit/s 0x011C :: 250 kbit/s 0x031C :: 125 kbit/s 0x432F :: 100 kbit/s 0x472F :: 50 kbit/s 0x532F :: 20 kbit/s 0x672F :: 10 kbit/s 0x7F7F :: 5 kbit/s