Counter

Support forum for users of the M1 Build

Counter

Postby gtihk on Mon Mar 11, 2019 1:55 pm

Hi,
I want to duplicate a counter at the last byte of a CAN message.
I think I know how to do it if the counter increment a fixed amount.
However, I am stuck on this one.
The following is the sequence : 3,79,139,199 and so on.

Could someone please help me out on this?
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm

Re: Counter

Postby rntechnologies on Mon Mar 11, 2019 6:43 pm

Hi Githk,
Is the loop just the 4 messages and then loop again?

If so, there are a few ways you could do this (here is one):

static local something = 1;
if (something eq 1)
{
//3
}
else if (something eq 2)
{
//79
}

ETC ETC

//Send the message here

if (something eq 4)
{
something = 1;
}
else
{
something += 1;
}
Regards,
Ryan
User avatar
rntechnologies
Pro User
 
Posts: 90
Joined: Tue Aug 07, 2018 9:45 am
Location: Australia

Re: Counter

Postby David Ferguson on Tue Mar 12, 2019 2:13 am

If you are reverse engineering the protocol, are you sure the value is not actually a value that naturally increments, such as a timer or a distance value? If so, I would calculate the time, or increment the distance (based on speed & time)
David Ferguson
Veracity Racing Data
David Ferguson
Pro User
 
Posts: 1362
Joined: Fri Nov 07, 2008 2:45 am
Location: Paso Robles, California

Re: Counter

Postby gtihk on Tue Mar 12, 2019 1:54 pm

I do not think it is time or distance dependent.
Yes, there are just four values that loop.
Thanks for the help, Ryan!
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm

Re: Counter

Postby gtihk on Tue Mar 12, 2019 5:44 pm

I have the project validated now. Will need to test on a car to see if things work out.
Thanks again!
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm


Return to M1 Build

Who is online

Users browsing this forum: Google [Bot] and 22 guests