For example you read back \x93\x02\x00\x00\x91'
The 93 is just a transmission header. Ignore it.
The 02 indicates that the next 2 bytes are the data.
00 & 00 are the data.
The 91 is the checksum.
Here is the code I use to decode the data coming back from the DCS. The DCS response bytes are in decimal in the array DCSParams. It's a 44 x 7 array.
Each of the 44 DCS responses are stored in a single row in the array as they are read in. DCSParam[0,x] holds the first response, DCSParam[1,x] holds the second response, etc.
Since the number of bytes in each response is fixed I simply hard coded the decode for each DCS parameter.
Ignore the Serial Swap code. I use that for multiplexing the UART port on the 8266 between the DCS and the terminal display (Arduino)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Decode & Print Params Subroutine /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DecodeParams()
{
//Decode parameters
Serial.swap(); // Switch back to diagnostic port
delayMicroseconds(50);
// Row 0
float Pval = DCSParams[0][2]; //
Serial.print("Row 0 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Battery Current Row 1
Pval = DCSParams[1][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[1][2];
Serial.print("Row 1 BatteryCurrent ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Battery Voltage Row 2
Pval = DCSParams[2][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[2][2];
Pval = Pval / 100.0;
Serial.print("Row 2 BatteryVoltage ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Battle Short Status Row 3
Pval = DCSParams[3][2]; //
Serial.print("Row 3 BattleShort0=Off,1=ON ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 4
Pval = DCSParams[4][2]; //
Serial.print("Row 4 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 5
Pval = DCSParams[5][2]; //
Serial.print("Row 5 Battleshort? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Coolant Temp Row 6
Pval = DCSParams[6][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[6][2];
Serial.print("Row 6 CoolantTemp ");
Serial.print(Pval);
Serial.println(" Degrees F");
delay(5); //Time for data to be printed on terminal
//Fault Code Row 7
Pval = DCSParams[7][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[7][2];
Serial.print("Row 7 FaultCode ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Warning Code Number Row 8
Pval = DCSParams[8][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[8][2];
Serial.print("Row 8 WarningCodeNumber ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 9
Pval = DCSParams[9][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[9][2];
Serial.print("Row 9 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 10
Pval = DCSParams[10][2]; //
Serial.print("Row 10 Battleshort ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Fuel Level Row 11
Pval = DCSParams[11][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[11][2];
Pval = Pval / 10.0;
Serial.print("Row 11 FuelLevel ");
Serial.print(Pval);
Serial.println(" %");
delay(5); //Time for data to be printed on terminal
//Bus Frequency Row 12
Pval = DCSParams[12][5];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[12][4];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[12][3];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[12][2];
Pval = Pval / 1000.0;
Serial.print("Row 12 BusFrequency ");
Serial.print(Pval);
Serial.println(" Hz");
delay(5); //Time for data to be printed on terminal
//Bus L1-L2 Row 13
Pval = DCSParams[13][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[13][2];
Serial.print("Row 13 BusL1-L2 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Bus L1-N VAC Row 14
Pval = DCSParams[14][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[14][2];
Serial.print("Row 14 BusL1-N ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Bus L2-L3 Row 15
Pval = DCSParams[15][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[15][2];
Serial.print("Row 15 BusL2-L3 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Bus L2-L3 Row 16
Pval = DCSParams[16][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[16][2];
Serial.print("Row 16 Voltage?? ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Bus L3-L1 Row 17
Pval = DCSParams[17][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[17][2];
Serial.print("Row 17 BusL3-L1 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Bus L3-L1 Row 18
Pval = DCSParams[18][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[18][2];
Serial.print("Row 18 BusL3L1 ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 19
Pval = DCSParams[19][2]; //
Serial.print("Row 19 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//ContactorState Row 20
Pval = DCSParams[20][2]; //
Serial.print("Row 20 ContactorState,0=Open,1=Closed ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Genset Freq Row 21
Pval = DCSParams[21][5];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[21][4];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[21][3];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[21][2];
Pval = Pval / 1000.0;
Serial.print("Row 21 GensetFreq ");
Serial.print(Pval);
Serial.println(" Hz");
delay(5); //Time for data to be printed on terminal
//L1 Current Row 22
Pval = DCSParams[22][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[22][2];
Pval = Pval / 10.0;
Serial.print("Row 22 L1Current ");
Serial.print(Pval);
Serial.println(" Amps");
delay(5); //Time for data to be printed on terminal
//Genset L1-L2 Row 23
Pval = DCSParams[23][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[23][2];
Serial.print("Row 23 GensetL1-L2 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Genset L1-N Row 24
Pval = DCSParams[24][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[24][2];
Serial.print("Row 24 GensetL1-N ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//L2 Current Row 25
Pval = DCSParams[25][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[25][2];
Pval = Pval / 10.0;
Serial.print("Row 25 L2Current ");
Serial.print(Pval);
Serial.println(" Amps");
delay(5); //Time for data to be printed on terminal
//Genset L2-L3 Row 26
Pval = DCSParams[26][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[26][2];
Serial.print("Row 26 GensetL2-L3 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Genset L2-N Row 27
Pval = DCSParams[27][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[27][2];
Serial.print("Row 27 GensetL2-N ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//L3 Current Row 28
Pval = DCSParams[28][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[28][2];
Pval = Pval / 10.0;
Serial.print("Row 28 L3Current ");
Serial.print(Pval);
Serial.println(" Amps");
delay(5); //Time for data to be printed on terminal
//Genset L3-L1 Row 29
Pval = DCSParams[29][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[29][2];
Serial.print("Row 29 GensetL3-L1 ");
Serial.print(Pval);
Serial.println(" Volts");
delay(5); //Time for data to be printed on terminal
//Genset L3-N Row 30
Pval = DCSParams[30][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[30][2];
Serial.print("Row 30 GensetL3-N ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Engine Hours Row 31
Pval = DCSParams[31][5]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[31][4];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[31][3];
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[31][2];
Pval = Pval / 3600.0;
Serial.print("Row 31 EngineHours ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 32
Pval = DCSParams[32][2]; //
Serial.print("Row 32 Battleshort?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//KiloWatts Row 33
Pval = DCSParams[33][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[33][2];
Pval = Pval / 10.0;
Serial.print("Row 33 Power ");
Serial.print(Pval);
Serial.println(" Kw");
delay(5); //Time for data to be printed on terminal
// Row 34
Pval = DCSParams[34][2]; //
Serial.print("Row 34 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 35
Pval = DCSParams[35][2]; //
Serial.print("Row 35 ?? ");
Serial.print(Pval);
Serial.println(" ");
// Row 36
Pval = DCSParams[36][2]; //
Serial.print("Row 36 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
//Oil Pressure Row 37
Pval = DCSParams[37][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[37][2];
Pval = Pval / 10.0;
Serial.print("Row 37 OilPressure ");
Serial.print(Pval);
Serial.println(" PSI");
delay(5); //Time for data to be printed on terminal
//Reconnect0=208, 2=120/240,3=120 Row 38
Pval = DCSParams[38][2]; //
Serial.print("Row 38 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 39
Pval = DCSParams[39][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[39][2];
Serial.print("Row 39 Reconnect0=208,2=120/240,3=120 ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 40
Pval = DCSParams[40][2]; //
Serial.print("Row 40 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 41
Pval = DCSParams[41][2]; //
Serial.print("Row 41 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 42
Pval = DCSParams[42][3]; //
Pval = Pval * 256; //shift value to left 8 bits
Pval = Pval + DCSParams[42][2];
Serial.print("Row 42 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
// Row 43
Pval = DCSParams[43][2]; //
Serial.print("Row 43 ?? ");
Serial.print(Pval);
Serial.println(" ");
delay(5); //Time for data to be printed on terminal
PassCount = PassCount + 1;
Serial.swap(); // Switch back to DCS
delayMicroseconds(50);
return;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////