linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Sojka <sojkam1@fel.cvut.cz>
To: Oliver Hartkopp <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Subject: Re: [PATCH] can-utils: Add exact CAN frame length calculation (including bitstuffing)
Date: Thu, 30 Jan 2014 11:01:51 +0100	[thread overview]
Message-ID: <87ob2tkcts.fsf@steelpick.2x.cz> (raw)
In-Reply-To: <52E3D619.4070702@hartkopp.net>

Hello all,

On Sat, Jan 25 2014, Oliver Hartkopp wrote:
> 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.

The updated patch will follow this email.

Best regards,
-Michal

      parent reply	other threads:[~2014-01-30 10:01 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
2014-01-27  9:26   ` Marc Kleine-Budde
2014-01-30 10:01   ` Michal Sojka [this message]

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=87ob2tkcts.fsf@steelpick.2x.cz \
    --to=sojkam1@fel.cvut.cz \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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).