From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Michal Sojka <sojkam1@fel.cvut.cz>, linux-can@vger.kernel.org
Subject: Re: [PATCH] can-utils: Add exact CAN frame length calculation (including bitstuffing)
Date: Sat, 25 Jan 2014 16:19:53 +0100 [thread overview]
Message-ID: <52E3D619.4070702@hartkopp.net> (raw)
In-Reply-To: <1390571983-16040-1-git-send-email-sojkam1@fel.cvut.cz>
Hello Michal,
On 24.01.2014 14:59, Michal Sojka wrote:
> This adds an algorithm for calculating the exact number of bits a CAN
> frame occupies on the bus and uses this algorithm in canbusload.
> +++ b/canframelen.h
> @@ -0,0 +1,8 @@
> +#ifndef CANFRAMELEN_H
> +#define CANFRAMELEN_H
> +
> +#include <linux/can.h>
> +
> +unsigned can_frame_length(struct can_frame *frame);
> +
> +#endif
>
I would suggest two things:
1. Add some comment about the function (e.g. that it returns the length in
bits with/without inter frame gap).
2. I would prefer to add some calculation mode identifier here and provide all
calculation modes in canframelen.c
Including this stuff and it's comments:
https://gitorious.org/linux-can/can-utils/source/canbusload.c#L375
E.g. some
enum {
NO_BITSTUFFING, /* plain bit calculation without bitstuffing */
BITSTUFFING, /* with bitstuffing following Tindle estimation */
PRECISE, /* precise calculation including bitstuffing in CRC */
}
To be future proof with CAN I would suggest to add some CAN / CAN FD switch.
E.g.
unsigned can_frame_length(struct canfd_frame *cfd, int mode, int mtu);
Where mtu is CAN_MTU or CANFD_MTU to distinguish the frame types.
In the first step supporting CAN_MTU would be sufficient.
As a return value of zero always shows a problem this can be used to indicated
unsupported calculation modes/frame types.
Regards,
Oliver
next prev parent reply other threads:[~2014-01-25 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 13:59 [PATCH] can-utils: Add exact CAN frame length calculation (including bitstuffing) Michal Sojka
2014-01-25 15:19 ` Oliver Hartkopp [this message]
2014-01-27 9:26 ` Marc Kleine-Budde
2014-01-30 10:01 ` Michal Sojka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52E3D619.4070702@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=sojkam1@fel.cvut.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).