Commit Graph

53 Commits (65e715d56d08a76c22f5ae2665ca0696e2834c89)

Author SHA1 Message Date
Yasushi SHOJI 3ef3d72738 cansniffer: 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.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:21 +09:00
Oliver Hartkopp dfb607c807 remove obsolete char pointer casts
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-14 18:21:45 +01:00
Marc Kleine-Budde 00fbc5d536 cansniffer: main(): fix typo comand -> command
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-02-01 16:13:20 +01:00
Oliver Hartkopp 8ffcc187e9 cansniffer: make ASCII output switchable in CAN FD mode
In CAN FD mode the length of the output line becomes very long.
Therefore disable the ASCII output in CAN FD mode by default but
make it switchable with a new '@' command in interactive input mode.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 14:51:20 +01:00
Oliver Hartkopp c3129b678a cansniffer: add CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 14:48:14 +01:00
Oliver Hartkopp 540dcaa821 cansniffer: convert to struct canfd_frame for FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 13:50:03 +01:00
Oliver Hartkopp fb186ed6c8 cansniffer: add error handling for read/write of sniffsets
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 13:49:23 +01:00
Lothar Rubusch 8bf57429fc cansniffer: simplify conditional cases
refactoring, reduce some levels of indention

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
2021-10-18 22:30:21 +01:00
Lothar Rubusch 93a6cd6dfb cansniffer: simplify, avoiding else case indention
refactoring

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
2021-10-18 22:08:44 +01:00
Lothar Rubusch d9368a6003 cansniffer: simplify logic
refactoring

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
2021-10-18 22:08:05 +01:00
Lothar Rubusch c36bdc743f cansniffer: fix warning on unused variable
make use of former (not really) used "ret" in main()

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
2021-10-18 22:02:21 +01:00
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
Oliver Hartkopp 6a14256323 cansniffer: fix snifftab CAN-ID query
Due to a wrong test to check for existing CAN-IDs in the snifftab
it was not possible to have the CAN-ID '0' in the list and displayed.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-02 13:26:42 +01:00
Oliver Hartkopp 5e713b3ee0 cansniffer: remove obsolete semicolons
Silence compiler warning.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-13 10:16:52 +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
Rosen Penev 3e85fc5422
clang-tidy: fix cmp function usage
Found with bugprone-suspicious-string-compare

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
Oliver Hartkopp 2c87dcf468 can-utils: fix unused variable warnings
As pointed out by Gary Bisson clang complains about unused variables in
some valid cases.

Reported-by: Gary Bisson <gary.bisson@boundarydevices.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-28 19:32:20 +02:00
Oliver Hartkopp becc0fc6cc cansniffer: fix buffer length in readsettings()
The Android build discovered a char buffer overflow in readsettings().

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-07 18:49:20 +02:00
Oliver Hartkopp 2a8867f3cb cansniffer: add short description in help text
Following other can-utils applications.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 19:06:57 +02:00
Oliver Hartkopp ab2e8ffe0e cansniffer: formatting and variable renaming
Some unification of code formatting and rename of a variable in
print_snifline() which does not represent a CAN ID anymore.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 18:56:25 +02:00
Oliver Hartkopp ac55db508a cansniffer: exit after displaying help text
Do not start the application when the user wants to read the help text.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:55:28 +02:00
Oliver Hartkopp 64e33bf9ad cansniffer: add new interactive commands to enable/disable SFF/EFF frames
With the new commands

a<ENTER>        - enable 'a'll SFF CAN-IDs to sniff
n<ENTER>        - enable 'n'one SFF CAN-IDs to sniff
A<ENTER>        - enable 'A'll EFF CAN-IDs to sniff
N<ENTER>        - enable 'N'one EFF CAN-IDs to sniff

the EFF/SFF frames can be added/removed with a single command.
Of course this could be done with the '+' and '-' filters too.
But 'N' is much easier to type then '-0000000000000000' ...

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:52:20 +02:00
Oliver Hartkopp adf29573f4 cansniffer: add interactive command to clear/redraw the screen
For efficiency reasons on slow embedded machines cansniffer usually
does not clear the screen but only writes updates on required lines.
Sometimes the written lines exceed the terminal lines and people
resize the window which is not detected by cansniffer.

With entering <SPACE><ENTER> in interactive mode the screen can be
forced to redraw after resizing the terminal window.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:51:33 +02:00
Oliver Hartkopp bd6ef44321 cansniffer: support EFF frames with 29 bit CAN IDs
Convert cansniffer from CAN_BCM to CAN_RAW sockets and handle the
content filter in user space. Conversion CAN_RAW including slot
concept and sorting contributed by coryjfowler.

Functional changes visible to users:

- New format for settings file
- New command '8' to switch in a compact binary view for 80 columns view
- New head line layout
- The gap time between CAN frames is displayed in milli seconds (ms)
- The interactive filters support 29 bit CAN IDs

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:48:52 +02:00
Oliver Hartkopp 6d112a7209 cansniffer: terminate when settings file is not found
Clean up readsettings() and terminate when the settings file
'sniffset.*' is not found when given on commandline.

The readsettings() status output could not be read anyway due to
instant redraw from CAN frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 07:18:47 +02:00
Oliver Hartkopp 6f44582c19 cansniffer: make use of if_nametoindex()
Simplify the code as in other can-utils applications.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 06:57:16 +02:00
Oliver Hartkopp 507ff82d81 cansniffer: remove CAN_BCM specific functionalities
Remove functionalities that are not supported resp. can not be implemented
after the CAN_BCM to CAN_RAW conversion of cansnifffer.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 06:49:39 +02:00
Alexander Gerasiov 4568d4a180 cansniffer.c: Reformat help/usage output to be compatible with help2man.
Signed-off-by: Alexander Gerasiov <gq@debian.org>

Gbp-Pq: Name 0011-cansniffer.c-Reformat-help-usage-output-to-be-compat.patch
2020-04-27 08:20:09 +03:00
Oliver Hartkopp bceadb8696 cansniffer: fix colorization when notching relevant bits
When notching marked (and colored) bits with the interactive '#' command
the binary output omits colored bits - as intended.

But when switching back to the hex and ASCII output the bytes with
notched bits remained uncolored even when some bits inside the hex bytes
would have needed to be colored.

The check for the colored output was a logical AND operation which is
fine for the binary representation but needed to be a bit-wise operation
in the hex/ASCII byte mode case.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-26 15:56:08 +02:00
Oliver Hartkopp eb639c1b3d cansniffer: fix gap calculation output
The gap between two consecutive frames of a specific has been calculated in
handle_timeo() instead of handle_bcm() which lead to values that where
at minimum the loop time of the display refresh.

The effect can be seen when displaying a 10ms gap CAN frame with a 200ms
display refresh (option -l 20 => default) in opposite to a 10ms display
refresh (option -l 1).

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-26 08:30:55 +02:00
Fabrice Fontaine e9590b1ca7 fix include to find SIOCGSTAMP with latest kernel
In linux kernel commit 0768e17073dc527ccd18ed5f96ce85f9985e9115
the asm-generic/sockios.h header no longer defines SIOCGSTAMP.
Instead it provides only SIOCGSTAMP_OLD.

The linux/sockios.h header now defines SIOCGSTAMP using either
SIOCGSTAMP_OLD or SIOCGSTAMP_NEW as appropriate. This linux only
header file is not pulled so we get a build failure.

canlogserver.c: In function 'main':
canlogserver.c:404:21: error: 'SIOCGSTAMP' undeclared (first use in this function); did you mean 'SIOCGRARP'?
     if (ioctl(s[i], SIOCGSTAMP, &tv) < 0)
                     ^~~~~~~~~~
                     SIOCGRARP
canlogserver.c:404:21: note: each undeclared identifier is reported only once for each function it appears in

Fixes:
 - http://autobuild.buildroot.org/results/363de7d9bf433be8bc47ba4ee52ae0bb80fa9021

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-07-14 22:14:10 +02:00
Yegor Yefremov 7b7331976a Add SPDX identifiers
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-06-19 12:24:24 +02:00
Yegor Yefremov 1ce4dc7b39 Add missing return value checks
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2018-09-18 13:43:29 +02:00
Heydar Elahi c45ee0cdbe omit extra sets and clears
old code does extra sets and clears in case of quiet==1 so I've changed if statement orders and used else if
2017-08-09 18:53:35 +04:30
Oliver Hartkopp 4c8fb05cb4 can-utils: remove strict-aliasing compiler warning
GitHub user 'crossband' raised an issue regarding the strict-aliasing compiler
warning in his specific setup: https://github.com/linux-can/can-utils/issues/42

In fact memcpy() and memset() are a better solution than the former pointer
magics, so remove the issues and the compiler warning flag too.

Reported-by: crossband (https://github.com/crossband)
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-07-01 19:01:01 +02:00
Marc Kleine-Budde 18f8416a40 cansniffer: increase resolution for timeout values
As requested by Felix Seitz the timeout for screen updates should be
configurable to values smaller than 100ms. Marc Kleine-Budde provided the
original patch to increase the resolution of the timing relevant variables.

The rotating animation was replaced by a rolling screen update counter.
Additionally the CAN-ID is now printed in the same ASCII hex representation
as the CAN data.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-06-24 21:36:55 +02:00
Uwe Kleine-König cc82fd9737 cansniffer: fix file name in header
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-08-17 19:04:48 +02: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
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
Oliver Hartkopp 4369ac1c55 Consistencely allow '-?' to get a help text. 2009-01-13 09:32:45 +00:00
Oliver Hartkopp e7046e7fca Added interface name to parameter list in first line. 2008-11-17 10:23:42 +00:00
Oliver Hartkopp 5621884558 Added missing help test. 2008-07-10 11:01:37 +00:00
Oliver Hartkopp f33075946d Added -f option to filter only on the CAN-ID and not on the content.
This can be useful when the timestamp cyle needs to be displayed.
2008-07-10 10:59:37 +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 5f164d3414 - allow timout to be zero, which means timeout is off. 2007-12-10 15:47:01 +00:00
Oliver Hartkopp 12f9170338 Fixed checking of CAN interface name commandline parameter.
Cosmetics.
2007-10-07 14:39:52 +00:00
Oliver Hartkopp d0b24ffc10 Fixed contradiction in Sourcecode discalimer.
See details at
http://marc.info/?l=linux-netdev&m=119074747913703&w=2
2007-09-27 12:29:32 +00:00
Oliver Hartkopp 44fb4089c3 Update outdated comment. 2007-09-21 07:21:24 +00:00
Oliver Hartkopp 8d365bc5b0 Added the blanking of 'old' data when the can_dlc decreases between two
receiptions of the same can_id.
Thanks to Andre Naujoks for the bug report.
2007-07-16 09:52:43 +00:00