Counter

Support forum for users of the M1 Build

Counter

Postby gtihk on Mon Mar 11, 2019 12: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: 72
Joined: Thu Jul 19, 2018 12:37 pm

Re: Counter

Postby rntechnologies on Mon Mar 11, 2019 5: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: 84
Joined: Tue Aug 07, 2018 8:45 am
Location: Australia

Re: Counter

Postby David Ferguson on Tue Mar 12, 2019 1: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
Check out Shift RPM - https://shiftrpm.veracitydata.com
David Ferguson
Pro User
 
Posts: 991
Joined: Fri Nov 07, 2008 1:45 am
Location: Paso Robles, California

Re: Counter

Postby gtihk on Tue Mar 12, 2019 12: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: 72
Joined: Thu Jul 19, 2018 12:37 pm

Re: Counter

Postby gtihk on Tue Mar 12, 2019 4: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: 72
Joined: Thu Jul 19, 2018 12:37 pm


Return to M1 Build

Who is online

Users browsing this forum: No registered users and 4 guests