RE: [PATCH can-gw] add support for counter byte

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marc,
Thanks for your feedback.  I'll update the patch to address your formatting concerns and better separate them.  As you may have guessed, this is my first attempt at making a contribution to Linux.

The index of the counter byte is used inside the cgw_count function in the line:
cf->data[msgcounter->result_idx] = count;

To implement this feature I followed the lead of some of the existing features, so it should work in a similar way.  cgw_chk_result_idx_parm is pretty much the same as cgw_chk_csum_parms, except instead of checking the validity of 3 indexes (from, to, and result), it checks only one (the result index where the counter goes).

Regards,

Brad Drehmer

Software Developer
D&V Electronics Ltd.
130 Zenway Boulevard Woodbridge, ON L4H 2Y7 Canada
T: 905-264-7646 x274.
F: 905-264-0502
email: b.drehmer@xxxxxxxxxxxxxxxxx


TESTING THE FUTURE for OVER 20 YEARS


NOTICE: This e-mail and any attachments may contain confidential, privileged and proprietary information of D & V Electronics Ltd. and all such material is subject to copyright protection in favor of D & V Electronics Ltd. Any unauthorized disclosure or other use of this e-mail or the information contained herein or in any documents attached hereto may be unlawful and is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately and delete this e-mail without reading, printing, copying or forwarding it to anyone. This email was sent from D & V Electronics Ltd. To receive no further email communications, you can send an email to unsubscribe@xxxxxxxxxxxxxxxxx. D & V Electronics is located at 130 Zenway Blvd. Woodbridge, Ontario, Canada.

-----Original Message-----
From: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
Sent: August 29, 2018 12:24 PM
To: Brad Drehmer <b.drehmer@xxxxxxxxxxxxxxxxx>; Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
Cc: linux-can@xxxxxxxxxxxxxxx
Subject: Re: [PATCH can-gw] add support for counter byte

On 08/29/2018 05:35 PM, Brad Drehmer wrote:
> Some devices that we communicate with require that a byte be incremented every time that a message is sent.  The patches below implement this functionality, with modifications made to both the can-gw kernel module and the cangw can-utils application.  The user specifies which byte of the message should be incremented and the maximum value that the counter should go up to before resetting and beginning to count again from 0.
>
>
> can-gw
> (https://github.com/DV-Electronics/linux/tree/fbd509a7c1373157ade87b14
> 5823bfa4a0662cf6)
>
> --- net/can/gw.c.orig   2018-08-29 10:07:59.255121361 -0400
> +++ net/can/gw.c        2018-08-29 10:10:30.631121361 -0400
> @@ -101,6 +101,14 @@ struct cf_mod {
>         void (*modfunc[MAX_MODFUNCTIONS])(struct can_frame *cf,
>                                           struct cf_mod *mod);
>
> +       /* CAN frame counter increment after CAN frame modifications */
> +       struct {
> +               struct cgw_counter msgcounter;
> +       } counter;
> +       struct {
> +               void (*msgcounter)(struct can_frame *cf, struct cgw_counter *msgcounter);
> +       } counterfunc;
> +
>         /* CAN frame checksum calculation after CAN frame modifications */
>         struct {
>                 struct cgw_csum_xor xor; @@ -201,6 +209,23 @@ static
> int cgw_chk_csum_parms(s8 fr, s8
>                 return -EINVAL;
>  }
>
> +static int cgw_chk_result_idx_parm(s8 re) {
> +       /*
> +        * absolute dlc values 0 .. 7 => 0 .. 7, e.g. data [0]
> +        * relative to received dlc -1 .. -8 :
> +        * e.g. for received dlc = 8
> +        * -1 => index = 7 (data[7])
> +        * -3 => index = 5 (data[5])
> +        * -8 => index = 0 (data[0])
> +        */

Where does the magic happen that calculates the index relative to the dlc?

Marc

--
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |





[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux