The LINUX CAN driver can be used to control the CAN bus connected with the AT-CAN-MINI PC interface card. This project was done in cooperation with the LINUX LLP Project to control laboratory or automation devices via CAN.
The full featured can4linux supports many different interface boards. It is possible to use different kinds of boards at the same time. Up to four boards can be placed in one computer. With this feature it is possible to use /dev/can0 and /dev/can2 for two boards AT-CAN-MINI with SJA1000 and /dev/can1 and /dev/can3 with two CPC-XT equipped with Intel 82527. In all these configurations the programmer sees the same driver interface with open(), close(), read(), write() and ioctl() calls ( can_open(), can_close(), can_read(), can_write(), can_ioctl() ).
The driver itself is highly configurable using the /proc interface of the LINUX kernel.
The following listing shows a typical configuration with three boards:
$ grep . /proc/sys/Can/\* /proc/sys/Can/AccCode: -1 -1 -1 -1 /proc/sys/Can/AccMask: -1 -1 -1 -1 /proc/sys/Can/Base: 800 672 832 896 /proc/sys/Can/Baud: 125 125 125 250 /proc/sys/Can/Chipset: 82c200 82c200 82c200 none /proc/sys/Can/ExtID: nnnn /proc/sys/Can/IOModel: pppp /proc/sys/Can/IRQ: 5 7 3 5 /proc/sys/Can/Outc: 0 0 250 0 /proc/sys/Can/Overrun: 0 0 0 0 /proc/sys/Can/RxErr: 0 0 0 0 /proc/sys/Can/Timeout: 100 100 100 100 /proc/sys/Can/TxErr: 0 0 0 0 /proc/sys/Can/TxSpeed: ffff /proc/sys/Can/VendOpt: nnnn /proc/sys/Can/dbgMask: 0 /proc/sys/Can/version: 2.3
This above mentioned full flexibility is not needed in embedded applications. For this applications, a stripped-down version exists. It uses the same programming interface but does the most configurations at compile time. That means especially that only one CAN controller support with a special register access method is compiled into the driver. Actually the only CAN controller supported by this version is the Philips SJA 1000 in both the compatibility mode BasicCAN and the Philips \PeliCAN mode (compile time selectable).
The following sections are describing the sysctl entries.
For initially writing these sysctl entries after loading the driver (or at any time) a shell script utility does exist. It uses a board configuration file that is written over /proc/sys/Can .
utils/cansetup port.conf
CONFIG := $(shell uname -n) # load host specific CAN configuration load: @echo "Loading etc/$(CONFIG).conf CAN configuration" utils/cansetup etc/$(CONFIG).conf echo 0 >/proc/sys/Can/dbgMask