Linux-CAN / SocketCAN user space applications
 
 
 
 
Go to file
Oliver Hartkopp f7307b8290 can-utils: check for return values of if_nametoindex()
if_nametoindex() returns zero and a specific errno in the case the network
interface does not exist. The missing check leads to the use of the 'any'
CAN device but leaves the user alone as the user gets no error message.

Reported-by: Lothar Rubusch <lotophagon@protonmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-18 09:37:46 +02:00
.github/workflows add github actions 2019-11-25 15:29:47 +01:00
LICENSES Add license texts as files 2019-09-26 15:45:43 +02:00
cmake CMake first pass (#90) 2018-08-17 09:50:30 +02:00
config/m4 add autotools infrastructure 2010-04-19 12:12:18 +00:00
include/linux include: import j1939.h from kernel v5.14-rc5+netdev-next 2021-08-20 10:21:20 +02:00
mcp251xfd mcp251xfd: add sample dev-coredump udev rule 2021-02-13 23:36:43 +01:00
.gitignore mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd 2021-02-13 23:36:43 +01:00
.travis.yml travis: fix env for ppc64le 2020-10-19 14:37:30 +02:00
Android.mk Android.mk: remove duplicated cansequence definition 2020-11-04 14:12:47 +01:00
CMakeLists.txt mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd 2021-02-13 23:36:43 +01:00
GNUmakefile.am mcp251xfd: add sample dev-coredump udev rule 2021-02-13 23:36:43 +01:00
Makefile mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd 2021-02-13 23:36:43 +01:00
README.md Merge branch 'cansequence' of github.com:marckleinebudde/can-utils into master 2020-10-19 13:44:16 +02:00
asc2log.c asc2log: Correct usec overflow handling 2021-04-16 14:30:50 +02:00
autogen.sh do not use --symlink for autoreconf 2014-07-02 16:03:34 +02:00
bcmserver.c custom if statement reordering 2020-10-12 23:48:38 -07:00
can-calc-bit-timing.c can-calc-bit-timing: can_fixup_bittiming(): change type of tseg1 and alltseg to unsigned int 2021-10-13 15:21:56 +02:00
can-j1939-install-kernel-module.md can utils [can-j1939-install-kernel-module.md]: better explanation for adding backports, fixed typos and grammar (#247) 2020-10-06 15:33:57 +02:00
can-j1939-kickstart.md can-j1939-kickstart.md: fix example in documentation 2020-05-30 19:32:32 +02:00
can-j1939.md Fix spelling in various files 2019-11-11 14:21:49 +01:00
canbusload.c canbusload: count databitrate seperately 2021-06-24 14:44:50 +02:00
candump.c candump: fix epoll_wait() returning -1, errno == -EINTR 2021-05-28 11:57:38 +02:00
canfdtest.c canfdtest: main(): sort switch/case in cmd line parser alphabetically 2021-05-04 12:00:39 +02:00
canframelen.c canbusload: count databitrate seperately 2021-06-24 14:44:50 +02:00
canframelen.h canbusload: count databitrate seperately 2021-06-24 14:44:50 +02:00
cangen.c cangen: fix help text for burst send option 2021-04-07 13:42:28 +02:00
cangw.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
canlogserver.c docs: fix simple typo, cought -> caught 2020-12-06 17:31:33 +11:00
canplayer.c canplayer: add interactive single-step frame processing mode 2021-04-17 13:01:29 +02:00
cansend.c can: rename CAN FD related can_len2dlc and can_dlc2len helpers 2020-11-22 19:54:58 +01:00
cansequence.c cansequence: do_send(): remove unneeded cast 2020-11-04 14:58:10 +01:00
cansniffer.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
configure.ac mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd 2021-02-13 23:36:43 +01:00
isotpdump.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotpperf.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotprecv.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotpsend.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotpserver.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotpsniffer.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
isotptun.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
j1939acd.c make struct initialization C99 compatible again 2020-10-14 13:29:13 +02:00
j1939cat.c j1939cat: fix comparison signs issue 2021-10-13 16:32:32 +02:00
j1939spy.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
j1939sr.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
lib.c can: rename CAN FD related can_len2dlc and can_dlc2len helpers 2020-11-22 19:54:58 +01:00
lib.h can: rename CAN FD related can_len2dlc and can_dlc2len helpers 2020-11-22 19:54:58 +01:00
libj1939.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
libj1939.h libj1939.h: add missing license and copyright header 2019-09-26 15:46:20 +02:00
log2asc.c can: rename CAN FD related can_len2dlc and can_dlc2len helpers 2020-11-22 19:54:58 +01:00
log2long.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
page.theme import sample program & help page 2013-11-20 11:14:44 +01:00
slcan_attach.c slcan_attach: add bit rate table for -s parameter 2021-05-06 15:56:07 +02:00
slcand.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
slcanpty.c can-utils: check for return values of if_nametoindex() 2021-10-18 09:37:46 +02:00
style.css import sample program & help page 2013-11-20 11:14:44 +01:00
terminal.h Add SPDX identifiers 2019-06-19 12:24:24 +02:00
testj1939.c make struct initialization C99 compatible again 2020-10-14 13:29:13 +02:00

README.md

SocketCAN logo

SocketCAN userspace utilities and tools

This repository contains some userspace utilities for Linux CAN subsystem (aka SocketCAN):

Basic tools to display, record, generate and replay CAN traffic

  • candump : display, filter and log CAN data to files
  • canplayer : replay CAN logfiles
  • cansend : send a single frame
  • cangen : generate (random) CAN traffic
  • cansequence : send and check sequence of CAN frames with incrementing payload
  • cansniffer : display CAN data content differences

CAN access via IP sockets

  • canlogserver : log CAN frames from a remote/local host
  • bcmserver : interactive BCM configuration (remote/local)
  • socketcand : use RAW/BCM/ISO-TP sockets via TCP/IP sockets
  • cannelloni : UDP/SCTP based SocketCAN tunnel

CAN in-kernel gateway configuration

  • cangw : CAN gateway userspace tool for netlink configuration

CAN bus measurement and testing

  • canbusload : calculate and display the CAN busload
  • can-calc-bit-timing : userspace version of in-kernel bitrate calculation
  • canfdtest : Full-duplex test program (DUT and host part)

ISO-TP tools ISO15765-2:2016 for Linux

  • isotpsend : send a single ISO-TP PDU
  • isotprecv : receive ISO-TP PDU(s)
  • isotpsniffer : 'wiretap' ISO-TP PDU(s)
  • isotpdump : 'wiretap' and interpret CAN messages (CAN_RAW)
  • isotpserver : IP server for simple TCP/IP <-> ISO 15765-2 bridging (ASCII HEX)
  • isotpperf : ISO15765-2 protocol performance visualisation
  • isotptun : create a bi-directional IP tunnel on CAN via ISO-TP

J1939/ISOBus tools

  • j1939acd : address claim daemon
  • j1939cat : take a file and send and receive it over CAN
  • j1939spy : spy on J1939 messages using SOC_J1939
  • j1939sr : send/recv from stdin or to stdout
  • testj1939 : send/receive test packet

Follow the link to see examples on how this tools can be used: Kickstart guide to can-j1939 on linux

Log file converters

  • asc2log : convert ASC logfile to compact CAN frame logfile
  • log2asc : convert compact CAN frame logfile to ASC logfile
  • log2long : convert compact CAN frame representation into user readable

Serial Line Discipline configuration (for slcan driver)

  • slcan_attach : userspace tool for serial line CAN interface configuration
  • slcand : daemon for serial line CAN interface configuration
  • slcanpty : creates a pty for applications using the slcan ASCII protocol

CMake Project Generator

  • Place your build folder anywhere, passing CMake the path. Relative or absolute.
  • Some examples using a build folder under the source tree root:
  • Android : cmake -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-21 -DANDROID_ABI=armeabi-v7a .. && make
  • Android Studio : Copy repo under your project's app folder, add add_subdirectory(can-utils) to your CMakeLists.txt file after cmake_minimum_required(). Generating project will build Debug/Release for all supported EABI types. ie. arm64-v8a, armeabi-v7a, x86, x86_64.
  • Raspberry Pi : cmake -DCMAKE_TOOLCHAIN_FILE=~/rpi/tools/build/cmake/rpi.toolchain.cmake .. && make
  • Linux : cmake -GNinja .. && ninja
  • Linux Eclipse Photon (Debug) : CC=clang cmake -G"Eclipse CDT4 - Unix Makefiles" ../can-utils/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_VERSION=4.8.0
  • To override the base installation directory use: CMAKE_INSTALL_PREFIX ie. CC=clang cmake -DCMAKE_INSTALL_PREFIX=./out .. && make install

Additional Information: