commit 9f3caa6fe376474a1b6e2caef1f30f1c4f008ebd Author: Oliver Hartkopp Date: Sat Apr 22 12:36:05 2017 +0200 Initial commit based on https://github.com/downwith/linux-isotp This repository contains a rework to simplify the build of the former ISO-TP development repository at https://github.com/hartkopp/can-isotp-modules. The build and repository cleanup provided by Nathan L. Conrad was merged from https://github.com/downwith/linux-isotp . Thanks Nathan! Signed-off-by: Oliver Hartkopp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d99b102 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. This program is distributed in the hope that it will be useful, but +# without any warranty; without even the implied warranty of mechantability 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. +# +# Nathan L. Conrad +# + +.*.cmd +*.ko +*.o +*.mod.c +modules.order +/.tmp_versions/ +/Module.symvers diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eaee963 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. This program is distributed in the hope that it will be useful, but +# without any warranty; without even the implied warranty of mechantability 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. +# +# Nathan L. Conrad +# + +ifneq ($(KERNELRELEASE),) + obj-y := net/can/ +else + KERNELDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) +modules: + $(MAKE) -C $(KERNELDIR) M=$(PWD) PROJECT_DIR=$(PWD) modules +modules_install: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install + @depmod +endif +.PHONY: clean +clean: + @find -type f '(' -name '.*.cmd' -o -name '*.ko' -o -name '*.o' -o \ + -name '*.mod.c' -o -name 'modules.order' ')' -delete + @rm -rf .tmp_versions + @rm -f Module.symvers diff --git a/README.isotp b/README.isotp new file mode 100644 index 0000000..31be613 --- /dev/null +++ b/README.isotp @@ -0,0 +1,299 @@ +============================================================================ + +README.isotp + +CREDITS + +This repository contains a rework to simplify the build of the former ISO-TP +development repository at https://github.com/hartkopp/can-isotp-modules. + +The build and repository cleanup provided by Nathan L. Conrad was merged from +https://github.com/downwith/linux-isotp . Thanks Nathan! + +DOWNLOAD and BUILD + +1. Download repository + + git clone https://github.com/hartkopp/can-isotp.git + +2. Build ISO-TP kernel module + + Ensure dependencies are installed. For Debian (or Ubuntu): + + sudo apt-get install build-essential linux-headers-$(uname -r) + + To build: + + make + + To install (optional): + + sudo make modules_install + + +3. When the PF_CAN core module is loaded ('modprobe can') the ISO-TP module + can be loaded into the kernel with + + insmod ./net/can/can-isotp.ko + + When the can-isotp.ko module has been installed into the Linux Kernels + modules directory (e.g. with 'make modules_install') the module should + load automatically when opening a CAN_ISOTP socket. + +---------------------------------------------------------------------------- + +Readme file for ISO 15765-2 CAN transport protocol for protocol family CAN + +* This implementation is already widely used in automotive use-cases, e.g. +* for UDS based OBD diagnosis. Although some small adaptions may be applied +* to make it ready for Linux Mainline. Feedback is welcome. +* +* Current behaviour: +* +* - no ISO-TP specific return values are provided to the userspace +* - when a transfer (tx) is on the run the next write() blocks until it's done +* - no support for sending wait frames to the data source in the rx path + + + 1 What is ISO-TP for CAN + + 2 Tools and Examples + 2.1 isotpsend - send PDUs from stdin to CAN + 2.2 isotprecv - print received PDU on stdout + 2.3 isotpdump - dump CAN frames with PCI decoding (using CAN_RAW socket) + 2.4 isotpsniffer - dump reassembled ISO-TP PDUs (using CAN_ISOTP socket) + 2.5 isotptun - create an IP tunnel over unreliable ISO-TP PDUs + + 3 Remarks + 3.1 tx_queue_len on real CAN busses (!!!) + 3.2 State of the Socket API & Discussion + +1 What is ISO-TP for CAN +------------------------ + + CAN Transport Protocols offer support for segmented Point-to-Point + communication between CAN nodes via two defined CAN Identifiers. + This protocol driver implements data transfers according ISO 15765-2. + + CAN ISO-TP is an unreliable datagram protocol and is implemented like this. + For that reason error indications, like 'dropped PDUs in the receive path due + to wrong SequenceNumbers' are intentionally not supported. + See discussion in section 3.2 + + Code examples of how to use ISO-TP sockets can be found in the source code + of the available tools described below. The API is still a RFC and will be + described in detail later, when it's finalized. + + +2 Tools and Examples +-------------------- + + The source code of these tools can be found in the BerliOS SVN repository + http://developer.berlios.de/svn/?group_id=6475 in trunk/can-utils + + For the examples below we assume a test setup with two hosts: + + _______ _______ + | | | | + | Host1 | | Host2 | + | | | | + | can1 | | can2 | + |_______| |_______| + | | + |------------------------------| CAN bus + + + 2.1 isotpsend - send PDUs from stdin to CAN + + isotpsend gives this help when invoked without any parameters: + + Usage: isotpsend [options] + Options: -s (source can_id. Use 8 digits for extended IDs) + -d (destination can_id. Use 8 digits for extended IDs) + -x (extended addressing mode. Use 'any' for all addresses) + -p (set and enable padding byte) + -P (check padding in FC. (l)ength (c)ontent (a)ll) + -t