Linux-CAN / SocketCAN user space applications
 
 
 
 
Go to file
Oleksij Rempel 8012b3b23d isobusfs: address snprintf truncation warning with explicit limits
Modify the isobusfs_log function in isobusfs_cmn.c to explicitly limit
the lengths of the time_buffer, level_str, and log_entry strings in
the snprintf format string to 40, 10, and 150 characters respectively.
This change acknowledges that truncation may still occur, but it is now
explicit and controlled.

This change silences the following warning:
cmake -DCMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=gcc -B build
cmake --build build

/home/isobusfs/isobusfs_cmn.c: In function 'isobusfs_log':
/home/isobusfs/isobusfs_cmn.c:104:30: warning: '%s' directive output
may be truncated writing up to 191 bytes into a region of size between
182 and 245 [-Wformat-truncation=]
  104 |                  "[%s] [%s]: %s", time_buffer, level_str, log_entry);
      |                              ^~                           ~~~~~~~~~
/home/isobusfs/isobusfs_cmn.c:103:9: note: 'snprintf' output 12 or more
bytes (assuming 266) into a destination of size 256
  103 |         snprintf(complete_log_entry, sizeof(complete_log_entry),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104 |                  "[%s] [%s]: %s", time_buffer, level_str, log_entry);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2024-05-29 10:54:18 +02:00
.github/workflows Create codeql-analysis.yml 2022-06-13 17:42:33 +02:00
LICENSES Add license texts as files 2019-09-26 15:45:43 +02:00
calc-bit-timing can-calc-bit-timing: in case of invalid option exit with error 2024-05-07 15:21:39 +02:00
cmake CMake: resolve linting issues 2024-05-27 11:48:25 +02:00
config/m4 add autotools infrastructure 2010-04-19 12:12:18 +00:00
include/linux include: update includes to Linux v6.9 upstream 2024-02-14 20:18:29 +01:00
isobusfs isobusfs: address snprintf truncation warning with explicit limits 2024-05-29 10:54:18 +02:00
mcp251xfd mcp251xfd-regmap: do_mcp251xfd_regmap_read(): fix compiler warning in a more straight forward way 2024-03-19 13:01:46 +01:00
.clang-format Add .clang-format 2023-09-05 10:50:54 +02:00
.editorconfig Add configuration file for EditorConfig 2024-05-26 17:42:43 +02:00
.gitignore Ignore ctags generated tags file 2024-05-26 12:51:33 +02:00
.travis.yml travis: fix env for ppc64le 2020-10-19 14:37:30 +02:00
Android.mk [fix] Adding lib.c to rule of slcanpty build 2023-03-22 14:51:39 +01:00
CMakeLists.txt CMake: resolve linting issues 2024-05-27 11:48:25 +02:00
GNUmakefile.am GNUmakefile: isobus: include scripts in tarball 2024-02-19 09:44:32 +01:00
Makefile can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
README.md canlogserver: Update the description 2023-05-13 17:25:17 +02:00
asc2log.c can-utils: make local functions static 2024-03-12 20:10:00 +01:00
autogen.sh do not use --symlink for autoreconf 2014-07-02 16:03:34 +02:00
bcmserver.c bcmserver: use pragma to silence gnu-variable-sized-type-not-at-end warning 2024-05-26 16:57:25 +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
can-tc-init-etf.sh can-tc-init-etf: document required kernel config options 2022-12-13 22:13:37 +01:00
canbusload.c can-utils: make local functions static 2024-03-12 20:10:00 +01:00
candump.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
canfdtest.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +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 can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
cangw.c can-utils: make local functions static 2024-03-12 20:10:00 +01:00
canlogserver.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
canplayer.c Refactor the help/usage message for canplayer 2024-05-14 19:19:35 +02:00
cansend.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
cansequence.c cansequence: add missing "--strict" to long_options 2023-12-05 10:38:23 +01:00
cansniffer.c cansniffer: Follow Bash exit status when signaled 2023-03-20 10:22:21 +09:00
check_cc.sh Don't compile programs using fork() on MMU-less systems 2023-05-08 18:30:50 +02:00
configure.ac Don't compile programs using fork() on MMU-less systems 2023-05-08 18:30:50 +02:00
fork_test.c Don't compile programs using fork() on MMU-less systems 2023-05-08 18:30:50 +02:00
isotpdump.c timestamp formatting: always use 64-bit for timesstamp formatting. 2023-11-28 08:30:27 +08:00
isotpperf.c timestamp formatting: always use 64-bit for timesstamp formatting. 2023-11-28 08:30:27 +08:00
isotprecv.c isotprecv: add option to enable dynamic flow control parameters 2024-02-14 21:18:58 +01:00
isotpsend.c isotpsend: add support for transmission without flow control 2022-05-13 20:00:45 +02:00
isotpserver.c remove obsolete char pointer casts 2022-03-14 18:21:45 +01:00
isotpsniffer.c isotpsniffer: simplify option for CAN FD link layer 2023-12-08 17:29:04 +01:00
isotptun.c isotptun: Follow Bash exit status when signaled 2023-03-20 10:22:30 +09:00
j1939acd.c j1939acd: Follow Bash exit status when signaled 2023-03-20 10:23:10 +09:00
j1939cat.c timestamp formatting: always use 64-bit for timesstamp formatting. 2023-11-28 08:30:27 +08:00
j1939spy.c timestamp formatting: always use 64-bit for timesstamp formatting. 2023-11-28 08:30:27 +08:00
j1939sr.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
lib.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +02:00
lib.h lib: make sprint_canframe the buffer size aware snprintf_canframe 2024-03-12 19:11:58 +01:00
libj1939.c clang-tidy: sort includes alphabetically 2020-10-12 23:28:58 -07:00
libj1939.h libj1939.h: fix typo 2022-01-03 10:58:05 +01:00
log2asc.c can-utils: make local functions static 2024-03-12 20:10:00 +01:00
log2long.c lib: make sprint_canframe the buffer size aware snprintf_canframe 2024-03-12 19:11:58 +01:00
page.theme import sample program & help page 2013-11-20 11:14:44 +01:00
slcan_attach.c slcan: increase BTR char limit to 8 for 32bit BTR 2023-02-23 16:36:33 +01:00
slcand.c slcand: Follow Bash exit status when signaled 2023-03-20 10:23:18 +09:00
slcanpty.c can-utils: fix sign-compare warnings (#513) 2024-04-24 20:02:02 +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 Update testj1939.c, correct verbose information. (#503) 2024-03-04 14:54:41 +01: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 and serves them
  • 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: