History of the document
First draft Hi 13.01.2002
Rescue after loss of data Hi 10.02.2002
Format revision, read/write tables Hi 20.02.2002
Removed typos Hi 21.02.2002
PCAN-USB integrated Hi 09.02.2003
Obfuscation of „pcan_usb_kernel.c“ is described Hi 23.02.2003
devfs, kernel-2.5 support, LGPL Hi 04.08.2003
1
st
revision for kernel 2.6.x driver Hi 02.05.2004
Enlarge FAQ, corrections Hi 13.05.2004
Simple correction for RPM make procedure Hi 14.08.2004
Additional compiler switches Hi 19.07.2005
Replaced cat “i ...” with echo “i ...” Hi 30.11.2005
Added a hint from Uwe Bonnes Hi 14.03.2006
Added PCAN-PC Card support, removed devfs Hi 14.05.2006
Corrected serious typographic error Hi 16.05.2006
Removed obfuscation, added realtime support Hi 29.10.2006
Minor improvements Hi 04.11.2006
netdev, message filters and error handling described Hi 27.02.2007
PCAN-driver for Linux page 2 of 29
table of documents
PCAN-driver for Linux............................................................................................................1
History of the document.....................................................................................................2
Features of the 'pcan.o' or 'pcan.ko' driver........................................................................4
Special features of the “chardev driver”........................................................................4
Special features of the “netdev driver”..........................................................................5
Preluding notes..................................................................................................................5
Manual installation ............................................................................................................6
Manual file unpacking ...................................................................................................6
Prerequisites for compilation of the sources.................................................................7
Manual compilation and installation .............................................................................7
Installation with source RPM.............................................................................................7
Loading the driver .............................................................................................................8
Driver loading specifics for chardev..............................................................................9
Driver loading specifics for netdev..............................................................................10
Interface Specifics............................................................................................................12
Specifics with the driver installation for PCAN-USB ..................................................12
Specifics with the driver installation for PCAN-PC Card.............................................12
Customization of 'modules.conf' or 'modprobe.conf'.......................................................13
Interface hardware type...............................................................................................13
IO-port and interrupt settings.......................................................................................13
Initial bitrate.................................................................................................................14
Assign parameter (netdev only)..................................................................................14
Installation test, use of test programs (chardev only)......................................................14
Most important chardev header files...............................................................................16
Manual installation of the chardev header-files...........................................................16
Most important netdev header files.................................................................................17
Compilation of the driver only..........................................................................................17
Use cases ...................................................................................................................17
Support for Cross-Compilation....................................................................................18
Features of the shared library 'libpcan.so' (chardev only)...............................................19
Manual installation of the chardev shared library............................................................19
Message Filters (chardev only)........................................................................................19
Error handling..................................................................................................................20
Socket-CAN introduction and basic installation (netdev only).........................................20
Realtime support with Xenomai.......................................................................................22
Installation....................................................................................................................22
Compilation environment.............................................................................................22
Runtime environment..................................................................................................22
Troubleshooting...........................................................................................................22
FAQ..................................................................................................................................23
Appendix..........................................................................................................................26
Historical parts.................................................................................................................28
devfs............................................................................................................................28
Compilation for kernel greater than 2.5.x....................................................................28
Obfuscation..................................................................................................................29
Epilogue ..........................................................................................................................29
PCAN-driver for Linux page 3 of 29
Disclaimer
Part of this program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License or LGPL Lesser General Public License as
published by the Free Software Foundation version 2 of the License. This program is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this
program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA
It is strictly prohibited to use the intellectual property from the provided source
code for developing or producing a 'compatible' hardware. All rights are reserved by
Peak-System-Technik GmbH.
Features of the 'pcan.o' or 'pcan.ko' driver
The „pcan.o“ or „pcan.ko“ driver is supporting PCAN-PCI, PCAN-ISA, PCAN-PC/104,
PCAN-Dongle, PCAN-PCCARD as well as PCAN-USB hardware. Depending on the type
of hardware (PCI, ISA, Dongle, PC Card, USB) 8 channels for each type can be
supported. For PCAN-ISA, PCAN-PC/104 and PCAN-Dongle the base address and the
used interrupt are settable. If no parameters are provided the driver uses factory defaults.
A user program can communicate with the driver in three different ways:
1. ASCII formatted data can be provided or accepted over a „read()“ or „write()“ interface.
This data contains information from received or transmitted telegrams or about channel
initializing parameters.
2. With a „ioctl()“ interface. Through this interface user programs are able to receive and to
transmit CAN-telegrams as well. However it is possible to get information about the
channel status and to initialize the CAN-channel.
3. As a network device with commonly used network socket calls. This kind of interface is
alternative to the previous kinds. It is called the netdev drivers interface, in contrast to
the chardev drivers interface. To use the netdev drivers interface you have to install the
Socket-CAN support from socketcan.berlios.de .
Most of this manuals content covers the usage of the chardev driver, see chapter “Special
features of the chardev driver”. The netdev driver usage and installation is considered in
depth in the chapter “Special features of the netdev driver”. Parts of the following
chapters are different for chardev or netdev implementations. Exceptions are marked to
pinpoint the difference.
Since version 5.0 of the driver support for the XENOMAI realtime add-on to the Linux
kernel is available. You can get more information in the chapter “Realtime support with
Xenomai”.
Special features of the “chardev driver”
The driver can be used from more than one user program at the same time and the
PCAN-driver for Linux page 4 of 29
simultaneous use of lots of interfaces and/or CAN channels is supported.
The reading or writing of telegrams can block if the receive buffer doesn't contain data any
more or if the write buffer is full. This behaviour can be disabled by opening the path as
non-blocking.
If more than one user program communicates with the same CAN-channel the input or
output is shared. (e.g.: Many user programs are accidentally sharing the received
telegrams.)
The „select“-method is supported.
The interface to the driver (constants and structures) is defined in the header file „pcan.h“.
Special features of the “netdev driver”
The netdev driver interfaces to the kernels network modules via a so called Socket-CAN
framework. Socket-CAN aims to be a standard interface for access of CAN devices. This
kind of interface enhances the features compared to the chardev driver. Especially it
provides:
● Possibility for multiple paths reading/writing from/to the same CAN channel
● Built-in filter capabilities, e.g CAN-ID (range) filters with can-raw sockets
● Built-in broadcast manager for cyclic sending of CAN telegrams and content filtering
in the CAN-data, e.g. updates to userspace only on data change
● Simple user API accessible from mostly all programming languages since normal
network socket calls are used (creating PF_CAN analogue to PF_INET)
● Local loopback of sent CAN frames for network transparent applications
● Socket-CAN is accompanied from lots of useful tools and utilities
The interface to the driver (constants and structures) is defined in the header file “can.h”
and "error.h" as long as Socket-CAN is not part of the mainstream Linux kernel.
Preluding notes
Note: Before installing the software the hardware has to be installed in or at the computer
(Exception: PCAN-Dongle, PCAN-PC Card or PCAN-USB, see at (6*)).
This manual is describing the installation process on a x86-Linux-computer with installed
kernel 2.6.x. and a SuSE 10.1 system. Exceptions for kernel 2.4.x. and x86-RedHat
systems are particularly mentioned.
Since driver version 6.0 support for kernels 2.2.x has ceased. If you need a driver for this
kernels please have a look at the latest 5.x driver version.
During the installation sometimes a console and perhaps an editor as well will be used in
the „root“- mode. If you want to login as „root“ user within a console or xterm-session you
can use the 'su' command or the built in menu „file/root console“.
To start an editor in the „root“ – mode, just invoke from the menu
„system/terminals/terminal (system manager mode)“ in KDE. From the console command
line you might invoke the editor „kwrite“, „kate“ or „emacs“.
For some distributions the standard path doesn't include the „/sbin“ folder. Then installation
commands have to typed in with „/sbin/“ ahead.
Examples:
PCAN-driver for Linux page 5 of 29