Correct byte order for Haltech CAN messages
This commit is contained in:
parent
190192b061
commit
b26027705a
|
@ -110,6 +110,8 @@ void sendCANBroadcast(uint8_t frequency)
|
|||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_TRIGGER);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_VSS);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
else if(frequency == 10)
|
||||
{
|
||||
|
@ -185,6 +187,9 @@ void DashMessage(uint16_t DashMessageID)
|
|||
uint16_t temp_Baro;
|
||||
uint16_t temp_CLT;
|
||||
uint16_t temp_IAT;
|
||||
uint16_t temp_VSS;
|
||||
uint16_t temp_VVT1;
|
||||
uint16_t temp_VVT2;
|
||||
uint16_t temp_fuelLoad;
|
||||
uint16_t temp_fuelTemp;
|
||||
int16_t temp_Advance;
|
||||
|
@ -251,7 +256,6 @@ void DashMessage(uint16_t DashMessageID)
|
|||
break;
|
||||
|
||||
case CAN_VAG_VSS: //VSS for VW instrument cluster
|
||||
uint16_t temp_VSS;
|
||||
temp_VSS = currentStatus.vss * 133U; //VSS conversion
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0xFF;
|
||||
|
@ -268,12 +272,12 @@ void DashMessage(uint16_t DashMessageID)
|
|||
temp_MAP = currentStatus.MAP * 10U;
|
||||
temp_TPS = currentStatus.TPS * 5U; //TPS value to 0.1. TPS is already in 0.5 increments, so multiply by 5
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(currentStatus.RPM);
|
||||
outMsg.buf[1] = highByte(currentStatus.RPM);
|
||||
outMsg.buf[2] = lowByte(temp_MAP);
|
||||
outMsg.buf[3] = highByte(temp_MAP);
|
||||
outMsg.buf[4] = lowByte(temp_TPS);
|
||||
outMsg.buf[5] = highByte(temp_TPS);
|
||||
outMsg.buf[0] = highByte(currentStatus.RPM);
|
||||
outMsg.buf[1] = lowByte(currentStatus.RPM);
|
||||
outMsg.buf[2] = highByte(temp_MAP);
|
||||
outMsg.buf[3] = lowByte(temp_MAP);
|
||||
outMsg.buf[4] = highByte(temp_TPS);
|
||||
outMsg.buf[5] = lowByte(temp_TPS);
|
||||
//Next 2 bytes are coolant pressure, not supported
|
||||
outMsg.buf[6] = 0x00;
|
||||
outMsg.buf[7] = 0x00;
|
||||
|
@ -286,8 +290,8 @@ void DashMessage(uint16_t DashMessageID)
|
|||
outMsg.buf[1] = 0x00;
|
||||
outMsg.buf[2] = 0x00; //Oil Pressure
|
||||
outMsg.buf[3] = 0x00;
|
||||
outMsg.buf[4] = lowByte(temp_fuelLoad);
|
||||
outMsg.buf[5] = highByte(temp_fuelLoad);
|
||||
outMsg.buf[4] = highByte(temp_fuelLoad);
|
||||
outMsg.buf[5] = lowByte(temp_fuelLoad);
|
||||
outMsg.buf[6] = 0x00; //Wastegate pressure
|
||||
outMsg.buf[7] = 0x00;
|
||||
break;
|
||||
|
@ -299,42 +303,57 @@ void DashMessage(uint16_t DashMessageID)
|
|||
if (configPage2.strokes == FOUR_STROKE) { temp_DutyCycle = temp_DutyCycle / 2U; }
|
||||
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_DutyCycle);
|
||||
outMsg.buf[1] = highByte(temp_DutyCycle);
|
||||
outMsg.buf[0] = highByte(temp_DutyCycle);
|
||||
outMsg.buf[1] = lowByte(temp_DutyCycle);
|
||||
outMsg.buf[2] = 0x00; //TODO: Staging Duty Cycle.
|
||||
outMsg.buf[3] = 0x00;
|
||||
outMsg.buf[4] = lowByte(temp_Advance);
|
||||
outMsg.buf[5] = highByte(temp_Advance);
|
||||
outMsg.buf[4] = highByte(temp_Advance);
|
||||
outMsg.buf[5] = lowByte(temp_Advance);
|
||||
outMsg.buf[6] = 0x00; //Unused
|
||||
outMsg.buf[7] = 0x00; //Unused
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_PW:
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(currentStatus.PW1);
|
||||
outMsg.buf[1] = highByte(currentStatus.PW1);
|
||||
outMsg.buf[2] = lowByte(currentStatus.PW2);
|
||||
outMsg.buf[3] = highByte(currentStatus.PW2);
|
||||
outMsg.buf[4] = lowByte(currentStatus.PW3);
|
||||
outMsg.buf[5] = highByte(currentStatus.PW3);
|
||||
outMsg.buf[6] = lowByte(currentStatus.PW4);
|
||||
outMsg.buf[7] = highByte(currentStatus.PW4);
|
||||
outMsg.buf[0] = highByte(currentStatus.PW1);
|
||||
outMsg.buf[1] = lowByte(currentStatus.PW1);
|
||||
outMsg.buf[2] = highByte(currentStatus.PW2);
|
||||
outMsg.buf[3] = lowByte(currentStatus.PW2);
|
||||
outMsg.buf[4] = highByte(currentStatus.PW3);
|
||||
outMsg.buf[5] = lowByte(currentStatus.PW3);
|
||||
outMsg.buf[6] = highByte(currentStatus.PW4);
|
||||
outMsg.buf[7] = lowByte(currentStatus.PW4);
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_LAMBDA:
|
||||
temp_Lambda = (currentStatus.O2 * 1000U) / configPage2.stoich;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_Lambda);
|
||||
outMsg.buf[1] = highByte(temp_Lambda);
|
||||
outMsg.buf[0] = highByte(temp_Lambda);
|
||||
outMsg.buf[1] = lowByte(temp_Lambda);
|
||||
temp_Lambda = (currentStatus.O2_2 * 1000U) / configPage2.stoich;
|
||||
outMsg.buf[2] = lowByte(temp_Lambda);
|
||||
outMsg.buf[3] = highByte(temp_Lambda);
|
||||
outMsg.buf[2] = highByte(temp_Lambda);
|
||||
outMsg.buf[3] = lowByte(temp_Lambda);
|
||||
outMsg.buf[4] = 0x00; //Lambda 3
|
||||
outMsg.buf[5] = 0x00; //Lambda 3
|
||||
outMsg.buf[6] = 0x00; //Lambda 4
|
||||
outMsg.buf[7] = 0x00; //Lambda 4
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_VSS:
|
||||
temp_VSS = currentStatus.vss * 10U;
|
||||
temp_VVT1 = currentStatus.vvt1Angle * 10U;
|
||||
temp_VVT2 = currentStatus.vvt2Angle * 10U;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = highByte(temp_VSS);
|
||||
outMsg.buf[1] = lowByte(temp_VSS);
|
||||
outMsg.buf[2] = 0x00;
|
||||
outMsg.buf[3] = currentStatus.gear;
|
||||
outMsg.buf[4] = highByte(temp_VVT1);
|
||||
outMsg.buf[5] = lowByte(temp_VVT1);
|
||||
outMsg.buf[6] = highByte(temp_VVT2);
|
||||
outMsg.buf[7] = lowByte(temp_VVT2);
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA4:
|
||||
temp_BoostTarget = currentStatus.boostTarget * 10U;
|
||||
temp_Baro = currentStatus.baro * 10U;
|
||||
|
@ -343,10 +362,10 @@ void DashMessage(uint16_t DashMessageID)
|
|||
outMsg.buf[1] = 0x00; //High byte for battery voltage, which is not used (Max battery voltage is 25.5 or 255)
|
||||
outMsg.buf[2] = 0x00; //Unused
|
||||
outMsg.buf[3] = 0x00; //Unused
|
||||
outMsg.buf[4] = lowByte(temp_BoostTarget);
|
||||
outMsg.buf[5] = highByte(temp_BoostTarget);
|
||||
outMsg.buf[6] = lowByte(temp_Baro);
|
||||
outMsg.buf[7] = highByte(temp_Baro);
|
||||
outMsg.buf[4] = highByte(temp_BoostTarget);
|
||||
outMsg.buf[5] = lowByte(temp_BoostTarget);
|
||||
outMsg.buf[6] = highByte(temp_Baro);
|
||||
outMsg.buf[7] = lowByte(temp_Baro);
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA5:
|
||||
|
@ -354,12 +373,12 @@ void DashMessage(uint16_t DashMessageID)
|
|||
temp_IAT = (currentStatus.IAT + 273U) * 10U; //Convert to Kelvin and adjust to 0.1
|
||||
temp_fuelTemp = (currentStatus.fuelTemp + 273U) * 10U; //Convert to Kelvin and adjust to 0.1
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_CLT);
|
||||
outMsg.buf[1] = highByte(temp_CLT);
|
||||
outMsg.buf[2] = lowByte(temp_IAT);
|
||||
outMsg.buf[3] = highByte(temp_IAT);
|
||||
outMsg.buf[4] = lowByte(temp_fuelTemp);
|
||||
outMsg.buf[5] = highByte(temp_fuelTemp);
|
||||
outMsg.buf[0] = highByte(temp_CLT);
|
||||
outMsg.buf[1] = lowByte(temp_CLT);
|
||||
outMsg.buf[2] = highByte(temp_IAT);
|
||||
outMsg.buf[3] = lowByte(temp_IAT);
|
||||
outMsg.buf[4] = highByte(temp_fuelTemp);
|
||||
outMsg.buf[5] = lowByte(temp_fuelTemp);
|
||||
outMsg.buf[6] = 0x00; //Oil Temperature
|
||||
outMsg.buf[7] = 0x00; //Oil Temperature
|
||||
break;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define CAN_HALTECH_PW 0x364 //Pulsewidth 1-4. 50Hz
|
||||
#define CAN_HALTECH_LAMBDA 0x368 //Lambda 1-4. 20Hz
|
||||
#define CAN_HALTECH_TRIGGER 0x369 //Trigger Counter, sync level, sync error count. 20Hz
|
||||
#define CAN_HALTECH_VSS 0x370 //VSS, current gear and inlet cam angles. 20Hz
|
||||
#define CAN_HALTECH_DATA4 0x372 //Baro, BatteryV, Target boost. 10Hz
|
||||
#define CAN_HALTECH_DATA5 0x3E0 //IAT, CLT, Fuel Temp, Oil Temp. 10Hz
|
||||
|
||||
|
|
Loading…
Reference in New Issue