Skip to contentSkip to conversation

add virtual CAN bus driver

PATCH In review Jan Kiszka 2 participants 2 messages Aug 30, 2006 – Sep 3, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 add virtual CAN bus driver

For review:

Here comes a tiny but fairly useful new CAN driver: a virtual CAN bus consisting of 2..n devices (see module parameter). Transmission takes places from the sender to all other devices on the bus, just like in real life.

This driver was already helpful for me while adapting CanFestival, a LGPL CANopen library, to our CAN API -- inside qemu, i.e. without any real hardware around.

Jan

Modules.frag +1 -0
Index: scripts/Modules.frag
===================================================================
@@ -12,6 +12,7 @@ DRIVERS-$(CONFIG_XENO_DRIVERS_TIMERBENCH
 DRIVERS-$(CONFIG_XENO_DRIVERS_IRQBENCH) += drivers/xenomai/testing/xeno_irqbench.o
 DRIVERS-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += drivers/xenomai/testing/xeno_switchtest.o
 DRIVERS-$(CONFIG_XENO_DRIVERS_RTCAN) += drivers/xenomai/can/xeno_rtcan.o
+DRIVERS-$(CONFIG_XENO_DRIVERS_RTCAN_VIRT) += drivers/xenomai/can/xeno_rtcan_virt.o
 DRIVERS-$(CONFIG_XENO_DRIVERS_RTCAN_MSCAN) += drivers/xenomai/can/mscan/xeno_rtcan_mscan.o
 DRIVERS-$(CONFIG_XENO_DRIVERS_RTCAN_SJA1000) += drivers/xenomai/can/sja1000/xeno_rtcan_sja1000.o
 DRIVERS-$(CONFIG_XENO_DRIVERS_RTCAN_SJA1000_PEAK_PCI) += drivers/xenomai/can/sja1000/xeno_rtcan_peak_pci.o
drivers/can/Kconfig +4 -0
Index: ksrc/drivers/can/Kconfig
===================================================================
@@ -26,6 +26,10 @@ config XENO_DRIVERS_RTCAN_MAX_RECEIVERS
        int "Maximum number of receive filters per device"
        default 16
 
+config XENO_DRIVERS_RTCAN_VIRT
+	depends on XENO_DRIVERS_RTCAN
+	tristate "Virtual tunnelling driver"
+
 source drivers/xenomai/can/mscan/Kconfig
 source drivers/xenomai/can/sja1000/Kconfig
 
drivers/can/rtcan_virt.c +195 -0

195 lines not on this page · raw message

drivers/can/Config.in +2 -0
Index: ksrc/drivers/can/Config.in
===================================================================
@@ -13,6 +13,8 @@ if [ "$CONFIG_XENO_DRIVERS_RTCAN" != "n"
    int 'Maximum number of devices' CONFIG_XENO_DRIVERS_RTCAN_MAX_DEVICES 4
    int 'Maximum number of receive filters per device' CONFIG_XENO_DRIVERS_RTCAN_MAX_RECEIVERS 16
 
+   dep_tristate 'Virtual tunnelling driver' CONFIG_XENO_DRIVERS_RTCAN_VIRT $CONFIG_XENO_DRIVERS_RTCAN
+
    source drivers/xenomai/can/mscan/Config.in
    source drivers/xenomai/can/sja1000/Config.in
 
drivers/can/Makefile +8 -1
Index: ksrc/drivers/can/Makefile
===================================================================
@@ -5,8 +5,10 @@ ifeq ($(PATCHLEVEL),6)
 EXTRA_CFLAGS += -Iinclude/xenomai -Idrivers/xenomai/can
 
 obj-$(CONFIG_XENO_DRIVERS_RTCAN) += xeno_rtcan.o mscan/ sja1000/
+obj-$(CONFIG_XENO_DRIVERS_RTCAN_VIRT) += xeno_rtcan_virt.o
 
 xeno_rtcan-y := rtcan_dev.o rtcan_socket.o rtcan_module.o rtcan_raw.o rtcan_raw_dev.o rtcan_raw_filter.o
+xeno_rtcan_virt-y := rtcan_virt.o
 
 else
 
@@ -19,11 +21,13 @@ subdir-$(CONFIG_XENO_DRIVERS_RTCAN_SJA10
 
 O_TARGET := built-in.o
 
-obj-$(CONFIG_XENO_DRIVERS_RTCAN) := xeno_rtcan.o
+obj-$(CONFIG_XENO_DRIVERS_RTCAN) += xeno_rtcan.o
+obj-$(CONFIG_XENO_DRIVERS_RTCAN_VIRT) += xeno_rtcan_virt.o
 
 list-multi := xeno_rtcan.o
 
 xeno_rtcan-objs := rtcan_dev.o rtcan_socket.o rtcan_module.o rtcan_raw.o rtcan_raw_dev.o rtcan_raw_filter.o
+xeno_rtcan_virt-objs := rtcan_virt.o
 
 export-objs := $(xeno_rtcan-objs)
 
@@ -34,4 +38,7 @@ include $(TOPDIR)/Rules.make
 xeno_rtcan.o: $(xeno_rtcan-objs)
 	$(LD) -r -o $@ $(xeno_rtcan-objs)
 
+xeno_rtcan_virt.o: $(xeno_rtcan_virt-objs)
+	$(LD) -r -o $@ $(xeno_rtcan_virt-objs)
+
 endif
#1 lore raw

Hi Jan,

Quoted 10 lines · Jan Kiszka

For review:

Here comes a tiny but fairly useful new CAN driver: a virtual CAN bus consisting of 2..n devices (see module parameter). Transmission takes places from the sender to all other devices on the bus, just like in real life.

This driver was already helpful for me while adapting CanFestival, a LGPL CANopen library, to our CAN API -- inside qemu, i.e. without any real hardware around.

I have tested it on my setup (MPC5200 with MSCAN and PEAK-PCI card under Linux 2.4) and it works fine.

Wolfgang.