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>
Oliver Hartkopp [Sat, 10 Apr 2010 16:38:48 +0000 (16:38 +0000)]
Complete rework of CAN netlink gateway.
Major changes:
- rework internal structures to prepare routings and modifications of CAN traffic also to non-CAN interfaces
- fix reading of netlink messages in cangw.c (added RTCAN_RTA / RTCAN_PAYLOAD macros)
- rework reading of gw-job lists in cgw_dump_jobs()
- rename of functions and API definitions to have a common namespace cgw_
- added infrastructure to perform crc8 and xor checksums in CAN frame data[]
TODO:
- add and test functionality for crc8 and xor checksums in CAN frame data[]
- add help text for crc8 and xor checksums in CAN frame data[]
Oliver Hartkopp [Wed, 17 Mar 2010 19:21:38 +0000 (19:21 +0000)]
Some binaries in can-utils depend on features in the socket-can svn
repository. Building with exported headers from an unpatched kernel will
fail due to missing symbols or headers.
This patch adds two make variables to optionally disable building such
binaries, like this:
make PROGRAMS_ISOTP= PROGRAMS_CANGW= PROGRAMS_SLCAN= all
Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
Oliver Hartkopp [Fri, 19 Feb 2010 13:33:59 +0000 (13:33 +0000)]
Added cangw netlink gateway configuration tool.
TODO (in both cangw and can-gw.ko) : Support removal and listing of rules.
So far the gateway jobs are only removed on can-gw.ko module unload or when
the used CAN netdevices disappear.
Oliver Hartkopp [Fri, 15 Jan 2010 18:35:37 +0000 (18:35 +0000)]
Added '-d' option to support the receive packet drop counting introduced in
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=3b885787ea4112eaa80945999ea0901bf742707f
This is done by using recvmsg() instead of recvfrom() to allow the timestamp
and the dropcounter to be received within one syscall.
When the application (here 'candump') ist not fast enough to process the
incomming CAN frames the frames are dropped in the socket receive queue.
When this happens and '-d' is set, we get this info now:
DROPCOUNT: dropped 1 CAN frame on 'xxx' socket (total drops 1)
Oliver Hartkopp [Wed, 25 Nov 2009 16:43:17 +0000 (16:43 +0000)]
Remove feature to quit the isotptun by keypress (from stdin) as it was not possible to run it from a start-script.
Added a signal handler to gracefully leave the isotptun.
can-utils: canfdtest, a full duplex test to find out-of-order messages
This patch is a pepped up version of Valdislav's canecho_gen and
canecho_dut test programs, which have prooved to be useful for
detecting out-of-order message transmisson and reception. Here
is a list of the changes and improvements:
- Both programs have been merged into on test program named
canfdtest. Message generation can be selected via the command
line option '-g'.
- The test loop count can be specified.
- A low and high verbosity level has been added.
- send/recv is used instead of write/read.
- The return code of send/recv is checked properly.
- Use Linux coding style.
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Oliver Hartkopp [Sun, 15 Feb 2009 17:40:32 +0000 (17:40 +0000)]
Spagetti code cleanup:
Moved conversions into separate functions can2pty() and pty2can().
Updated and enhanced some comments.
Variable name cleanups inside the separate functions.
Fix handling on wrong pty commands (was a wrong 'continue' statement).
Oliver Hartkopp [Tue, 20 Jan 2009 23:06:01 +0000 (23:06 +0000)]
Added a proof of concept tool 'slcanpty' which
creates a pty for applications using the slcan ASCII protocol and
converts the data to a CAN network interface (and vice versa).
This can be used for existing applications to run on SocketCAN.
Oliver Hartkopp [Mon, 1 Dec 2008 07:24:18 +0000 (07:24 +0000)]
Fix sloppy CAN_(EFF|RTR)_FLAG handling in can_filter.can_mask .
Due to a wrong safety check in af_can.c it was not possible to filter
for SFF frames with a specific CAN identifier without getting the
same selected CAN identifier from a received EFF frame also.
This fix has a minimum impact on the CAN filter API as the 'sloppy'
handling is still a correct (and possibly wanted?) use-case.
Please update the can-utils (especially candump) whose filter definition
on the commandline made assumptions to correct the user input that are
probably unwanted now.
Thanks to Kurt van Dijck for pointing at this issue!
Signed-Off-by: Oliver Hartkopp <oliver@hartkopp.net>
Oliver Hartkopp [Fri, 28 Nov 2008 21:50:24 +0000 (21:50 +0000)]
Fixed parse_canframe() with reordering the checks for the can_id
delimiter. Before this fix the function may have found delimiters in the
string behind the terminating zero.