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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>