Ahh, ok. In which case then have a look at both the guide on P18, as that will tell you what the data structure is for the serial data, and the Arduino code in the link. The Arduino code you will need to integrate into your app, but basically the main loop looks for 3 bytes of data:
- The area, i.e. Engine, Brakes, Session, etc.
- The category, i.e. for engine that would be "R" for revs
- The measure, i.e. for the engine revs, that would be "C" for current revs or "M" for max revs
Code:
while (Serial.available() > 0)
{
readArea = '!';
readCategory = '!';
readMeasure = '!';
if (Serial.available() > 3)
{
//the command as such is split into 3 sections. Area, Category and Measure
//read the first 3 bytes
readArea = Serial.read();
readCategory = Serial.read();
readMeasure = Serial.read();
//read the rest of the data and keep trying until we see an end of line
ReadToEndOfCommand();
//process first byte
ProcessArea();
}
}
...
Then the "ProcessArea" routine interrogates the Area byte.
Code:
void ProcessArea()
{
switch (readArea)
{
case 'E':
//Engine
ProcessEngine();
break;
case 'V':
//Vehicle
ProcessVehicle();
break;
...
Then the process code would look at the category and measure to then decide what to do.
Code:
void ProcessEngine()
{
//first byte was "E" to get us here
switch (readCategory)
{
case 'R':
//Revs
switch (readMeasure)
{
case 'C':
{
//Current Revs
longData = StringToNumber(receiveBuffer);
DisplayRevs(longData);
break;
}
case 'M':
{
//Max
//do something with max revs
break;
}
}
...
I've split these out and put a few switch statements together, but you could just as easily have a few "if" statements.
Obviously the Arduino code is set up for my config, but you should be able to take out the bits you need. And in the case of the "Current Revs" from above, just replace the
Code:
longData = StringToNumber(receiveBuffer);
DisplayRevs(longData);
with
Code:
rndRPM= StringToNumber(receiveBuffer);
Let me know if you need any more help...