include: can.h: add typedef for __kernel_sa_family_t to make headers self-contained
This patch adds the typedef for __kernel_sa_family_t that was introduced in
Linux v3.1-rc2 (commit 6602a4b net: Make userland include of netlink.h more sane)
in <linux/socket.h>. It must be duplicated here to make the CAN headers
self-contained.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Uwe Kleine-König [Mon, 13 Jan 2014 21:57:13 +0000 (22:57 +0100)]
include: Remove two unused header files
These seem to have never been used. They entered can-utils in commit 77de10356fe0 (include: import kernel header files into tree) and already
back then only consisted in an #include of a non-existing file.
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Yegor Yefremov [Mon, 13 Jan 2014 08:54:05 +0000 (09:54 +0100)]
slcand: reimplement daemonize routine
Replace daemonize() routine with daemone() system call, because of
conflicting licenses. daemonize() routine was derived from under
GNU Free Documentation License licensed code. This license is
incompatible with GPL-2+.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Yegor Yefremov [Mon, 13 Jan 2014 13:29:16 +0000 (14:29 +0100)]
slcanpty: declare command buffer static
ASCII command buffer char buf[200] must be declared as static,
because it holds incomplete commands between pty2can() calls.
Without static it is not guaranteed, that buf retains the same
data between calls.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Oliver Hartkopp [Mon, 16 Sep 2013 07:08:56 +0000 (09:08 +0200)]
slcand: silence warning about set but unused variable
The dummyFile pointer was only needed to redirect stdxxx streams but it's
content was never used. Re-use the pFile pointer for this reason which is
unused at that point to silent the compiler warning about the set and unused
dummyFile variable.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Sun, 15 Sep 2013 19:54:37 +0000 (21:54 +0200)]
slcand: fix whitespace issues and unify coding style
Fixed coding style inspired by Linux checkpatch.pl
Additionally removed a comment in the write() result check in the 'if (speed)'
statement to make sure the write() is not optimized away as the executed code
was empty.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Wed, 4 Sep 2013 18:30:34 +0000 (20:30 +0200)]
cangw: add an option for the per rule limitation of frame hops
Usually the received CAN frames can be processed/routed as much as 'max_hops'
times (which is given at module load time of the can-gw module).
Introduce a new configuration option ( -l <hops> ) to reduce the number of
possible hops for a specific gateway rule to a value smaller then max_hops.
Uwe Kleine-König [Sat, 17 Aug 2013 19:28:10 +0000 (21:28 +0200)]
can-utils: Don't overwrite PREFIX and DESTDIR when provided via the environment
For creating a Debian package providing PREFIX and DESTDIR via the
environment is the easiest option. So use ?= to assign these two
variables to honor the values in the environment.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Tue, 11 Jun 2013 20:21:38 +0000 (22:21 +0200)]
slcanpty: probe stdin capabilities at startup
/dev/null returns EOF therefore select() finishes immediately.
Now EOF is probed on start.
Other /dev/null as stdin workarounds:
- lscanpty ... < /dev/ptmx (dirty but works)
- cat </dev/null | slcanpty ... (doesn't work for me and even the patch
is "disabled" then)
Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Fri, 7 Jun 2013 18:02:57 +0000 (20:02 +0200)]
slcanpty: detect that master PTY descriptor closed
Terminate slcanpty when the pty file descriptor is closed instead of performing
an endless loop in the select() statement.
Reported-by: Janusz Uzycki <j.uzycki@elproma.com.pl> Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Thu, 20 Dec 2012 10:37:43 +0000 (11:37 +0100)]
slcanpty: Add support for the Unix 98 pseudo-terminal interface
Most Linux distributions do not configure their kernels to use the BSD
pseudo-terminal interface (/dev/pty* and /dev/tty*) anymore; they uses the
Unix 98 pseudo-terminal interface instead (/dev/ptmx and /dev/pts/*).
Oliver Hartkopp [Mon, 26 Nov 2012 20:44:22 +0000 (21:44 +0100)]
slcanpty: fix wrong usage of nbytes variable
nbytes is used after writing the CAN frame to check for an additional command
in the string buffer. Therefore using nbytes while writing the CAN frame is
wrong. Replace it with 'tmp' which can be used here without problems.
Signed-off-by: ulrich escher<git@myvdr.de> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Wed, 14 Nov 2012 19:06:50 +0000 (20:06 +0100)]
candump: new option to print extra message information
Added -x option to print extra message infos per frame:
RX/TX : Indicates whether the frame was sent or received from the local host
BRS : bit rate setting enabled (CAN FD only)
ESI : error state indicator (CAN FD only)
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
asc2log.c / log2asc.c
- updates for new lib functions
- still can only handle CAN2.0 frames (no new info about ASC file layout)
log2long.c / canlogserver.c / canplayer.c
- updates for new lib functions to handle CAN FD
lib.h / lib.c
- reworked lib functions to handle CAN FD
- parse_canframe() now returns CAN_MTU and CANFD_MTU on success, 0 at failure
- added can_dlc2len() and can_len2dlc() helpers
- moved hexstring2candata to hexstring2data to support simple byte buffers
- in the long CAN frame representation use %03X/%08X instead of %3X/%8X
- introduced unified buffer size definitions for ASCII CAN frames
- updated documentation
cangen.c
- support CAN FD frames (added -f option to create CAN FD frames)
- added -m option ('mix') to create random extended / RTR / CAN FD frames
- fixed the 'fixed data' option which was zero'ing the payload by the time
- updated help text
candump.c
- support CAN FD frames (print, bridge, log)
- distinguish frame types by length info: [0] = CAN2.0 [00] = CAN FD frame
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Wed, 14 Nov 2012 17:52:01 +0000 (18:52 +0100)]
Update includes to Linux 3.6 with CAN FD support.
There has been a change with __kernel_sa_family_t in Linux 3.1 which was not
adopted in this update so far to be backward compatible with old environments.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Fri, 13 Jul 2012 05:36:52 +0000 (07:36 +0200)]
cangen: allow double value for gap
This way a user can specify a gap below 1ms. This is somehwat similar
to setting the gap to 0, but the ENOBUFS are greatly reduced, so a given
amount of CAN messages by -n is still usefull and useable.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Oliver Hartkopp [Sun, 14 Nov 2010 08:55:06 +0000 (08:55 +0000)]
Added new socketoptions to force the isotp protocol to intentionally
misbehave for regression tests.
CAN_ISOTP_TX_STMIN:
Set a value in nano secs that's used as minimum CF gap by the sender.
This value is used instead of the value provided by the receiver inside the FC.
CAN_ISOTP_RX_STMIN:
Ignores received CF frames which timestamps differ less than this value in nano
secs. This is used to test the receivers misbehaviour when the receiver
provides a lower stmin value that he's able to cope with. Received CF frames
are silently dropped when they come faster than specified by this value.
Oliver Hartkopp [Sat, 25 Sep 2010 10:24:37 +0000 (10:24 +0000)]
Fix datatype issue in sscanf() on 64bit systems.
On 64bit systems a 'long' is a 64bit value but the target values of scanf()
are always 32bit in the affected code - which means just an 'unsigned int'.
Unsigned int is fine on 32 and 64 bit systems.
Oliver Hartkopp [Fri, 24 Sep 2010 17:56:53 +0000 (17:56 +0000)]
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%.
can-calc-bit-timing: calculate bit timings for all known controllers by default
When testing or improving the bit timing algorithm, you're probably
interested in the values of all can controllers. Further you might not
know the all reference clocks of the controllers.
This patch add a "ref_clock" member to the "struct can_bittiming_const"
that holds the reference clock of the controller in Hz.
By default now the bit timing is calculated for all known can
controllers with the default ref_clock defined in "can_bittiming_const".
It's still possible to overwrite the ref clock with the command line
option "-c".
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
can-calc-bit-timing: improve printing of bit timing parameters
This patch adds additional fields when printing the bit timing
parameters. Now the real bitrate the nominal and the real sample point
as well as the error of the sample point is displayed.
can-calc-bit-timing: use algorithm from the kernel
This patch copies the algorithm functions (can_update_spt and
can_calc_bittiming) from the kernel. Then some glue code is added that
these functions compile in userspace.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>