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/fbd509a7c1373157ade87b145823bfa4a0662cf6) > > --- 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 |
Attachment:
signature.asc
Description: OpenPGP digital signature