Commit Graph

26 Commits (95fe6522c63025a4fcfa464806b45dcc17aed42c)

Author SHA1 Message Date
Oliver Hartkopp dd16f2603b can-utils: make local functions static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 20:10:00 +01:00
Marc Kleine-Budde 8e2caa8f8a canbusload: main(): switch from pselect() to select()
We don't need to block any signals, so a select() is sufficient. This
also fixes the problem that sigmask is uninitialized and may block the
sig ARLM, which make canbusload hang until a CAN frame is recieved.

Closes: https://github.com/linux-can/can-utils/issues/465
2023-10-06 12:32:42 +02:00
Marc Kleine-Budde 84919edbaa canbusload: redraw mode: use less screen estate
Use less screen estate by not printing unneeded newlines in redraw
mode.
2023-09-27 12:40:38 +02:00
Marc Kleine-Budde 92adbda471 canbusload: convert towards kernel coding style 2023-09-27 12:38:48 +02:00
Yasushi SHOJI 1d43b3c6f3 canbusload: Enhance error message for missing bitrate
When canbusload is executed without bit rate, it exits with an exit
code of 1 and prints help, but without explaining why.  Users cannot
know what was wrong.  When other errors occur, though, canbusload
prints an error message along with the help.

Print an error message when bit rate is not given or "@" is not found.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-06-02 20:59:39 +09:00
Yasushi SHOJI 16a717c81e canbusload: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

canbusload.c was using a non-safe function, exit(3), in the signal
handler.  This commit replaces it with the way other programs in
can-utils are using; set running = 0 to exit from the while loop.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:41 +09:00
Vincent Mailhol 0cfd56d613 lib: add pr_debug() macro
Add the pr_debug() macro so that:

  #ifdef DEBUG
  	printf("foo");
  #endif

can be replaced by:

  	pr_debug("foo");

Apply the pr_debug() macro wherever relevant.

Currently, there is no consensus whether debug messages should be
printed on stdout or stderr. Most of the modules: canbusload.c,
candump.c and canlogserver.c use stdout but
mcp251xfd/mcp251xfd-dev-coredump.c uses stderr. Harmonize the behavior
by following the major trend and make
mcp251xfd/mcp251xfd-dev-coredump.c also output to stdout.

slcanpty.c does a #define DEBUG, meaning that debug is always turned
on for this file. Remove this and make debug an option like every
other files.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221114163848.3398-5-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-11-15 09:49:52 +01:00
Kurt Van Dijck 6382765bf6 canbusload: count databitrate seperately
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
2021-06-24 14:44:50 +02:00
Kurt Van Dijck e319afb10f canbusload: count full payload for CANFD frames
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
2021-06-24 12:47:37 +02:00
Rosen Penev b153fe3f35
clang-tidy: sort includes alphabetically
Found with llvm-include-order

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-12 23:28:58 -07:00
Gary Bisson 46895a41c5 Fix comparison type mismatch warnings
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-05-28 20:54:37 +02:00
Alexander Gerasiov 69865c8247 canbusload.c: Reformat help/usage output to be compatible with help2man.
Signed-off-by: Alexander Gerasiov <gq@debian.org>

Gbp-Pq: Name 0002-canbusload.c-Reformat-help-usage-output-to-be-compat.patch
2020-04-27 08:20:08 +03:00
Yegor Yefremov 14ccc06eba Fix spelling in various files
codespell parameters:

codespell -q 3 --skip="*.in,*.sh,*.m4,config,configure,autom4te.cache"

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-11-11 14:21:49 +01:00
Yegor Yefremov 7b7331976a Add SPDX identifiers
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-06-19 12:24:24 +02:00
Frank Theile f51c897d68
Consistent arguments to sizeof().
In calls to functions taking a pointer 'p' and a length 'l':
if a struct variable v is passed in for p, then also pass sizeof(v) for
l.
2018-04-03 11:56:28 +02:00
Oliver Hartkopp 110af11db1 canbusload: print bitstuffing mode when showing current time is enabled
When printing the current time on the first line the bitstuffing mode is
displayed depending on the command line settings.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-02-01 21:30:12 +01:00
Michal Sojka 2206f92de7 canbusload: Add exact CAN frame length calculation (including bitstuffing)
This adds an algorithm for calculating the exact number of bits a CAN
frame occupies on the bus and uses this algorithm in canbusload. It
also moves the other methods for CAN frame length calculation, already
present in canbusload, to the new file.

The added algorithm calculates the exact number of stuffed bit in a
CAN frame. Note that in order to calculate that correctly, we must
also know the frame's CRC. Hence, the algorithm also includes CRC
calculation routine.

The correctness of the algorithm was verified on an oscilloscope for
several different SFF and EFF frames.

Currently only CAN frames are supported. For CANFD frames, a different
algorithm is needed. CANFD uses different CRC polynomials and
calculates the CRC from the staffed bit-stream (CAN calculates CRC
from de-stuffed bit-stream).

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-30 16:23:25 +01:00
Uwe Kleine-König 4ddde7b966 trivial: fix typo concerning "bandwidth"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 21:25:15 +01:00
Oliver Hartkopp 836d3cc012 remove obsolete SVN ID tags
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:57:16 +01:00
Oliver Hartkopp 5077515927 adapt column width format for high busload values 2012-03-08 19:32:45 +01:00
Marc Kleine-Budde 722a09116d treewide: replace berlios contact email by linux-can@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-01-11 12:14:15 +01:00
Kurt Van Dijck a4c200efe6 canbusload: flush output at the end of each cycle
When canbusload is piped to another program, the output
is queued for several cycles. This patch will flush the output
explicitely.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
2012-01-10 17:41:07 +01:00
Oliver Hartkopp d7fe33eb4b Fixed calculation of needed bits on the physical wire according Ken Tindells
*worst* case calculation for stuff-bits.
(see "Guaranteeing Message Latencies on Controller Area Network" 1st ICC'94)
Due to the bitstuffing estimation the calculated busload may exceed 100%.
2010-09-24 17:56:53 +00:00
Oliver Hartkopp 5655d53acb Remove compiler warning :
warning: suggest explicit braces to avoid ambiguous ‘else’
2010-05-14 12:50:17 +00:00
Oliver Hartkopp adbe6f9bee Whitespace fixes. Indented the code following Linux styleguide to fix
the mess between tabs and spaces.
2008-06-03 08:46:57 +00:00
Oliver Hartkopp 789a021bb9 Added tiny tool to measure CAN busload. 2008-05-27 13:47:20 +00:00