code formatting
This commit is contained in:
parent
c7efe77c7a
commit
03df014ff9
|
@ -27,16 +27,16 @@ MOTOR_INFO = 0x580
|
|||
MOTOR_7 = 0x588
|
||||
|
||||
motor1Data = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
motorBreData={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
motorBreData = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
motor2Data = { 0x8A, 0x8D, 0x10, 0x04, 0x00, 0x4C, 0xDC, 0x87 }
|
||||
motor2mux = {0x8A, 0xE8, 0x2C, 0x64}
|
||||
motor2mux = { 0x8A, 0xE8, 0x2C, 0x64 }
|
||||
canMotor3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
motor5Data = { 0x1C, 0x08, 0xF3, 0x55, 0x19, 0x00, 0x00, 0xAD }
|
||||
motor6Data = { 0x00, 0x00, 0x00, 0x7E, 0xFE, 0xFF, 0xFF, 0x00 }
|
||||
accGraData = { 0x00, 0x00, 0x08, 0x00, 0x1A, 0x00, 0x02, 0x01 }
|
||||
canMotorInfo = { 0x00, 0x00, 0x00, 0x14, 0x1C, 0x93, 0x48, 0x14 }
|
||||
canMotorInfo1= { 0x99, 0x14, 0x00, 0x7F, 0x00, 0xF0, 0x47, 0x01 }
|
||||
canMotorInfo3= { 0x9B, 0x14, 0x00, 0x11, 0x1F, 0xE0, 0x0C, 0x46 }
|
||||
canMotorInfo1 = { 0x99, 0x14, 0x00, 0x7F, 0x00, 0xF0, 0x47, 0x01 }
|
||||
canMotorInfo3 = { 0x9B, 0x14, 0x00, 0x11, 0x1F, 0xE0, 0x0C, 0x46 }
|
||||
motor7Data = { 0x1A, 0x66, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
||||
canMotorInfoTotalCounter = 0
|
||||
|
@ -89,25 +89,25 @@ function setBitRange(data, totalBitIndex, bitWidth, value)
|
|||
end
|
||||
|
||||
function relayFromECU(bus, id, dlc, data)
|
||||
totalEcuMessages = totalEcuMessages + 1
|
||||
-- print("Relaying to TCU " .. id)
|
||||
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||
totalEcuMessages = totalEcuMessages + 1
|
||||
-- print("Relaying to TCU " .. id)
|
||||
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||
end
|
||||
|
||||
function sendMotor1()
|
||||
engineTorque = fakeTorque * 0.9
|
||||
innerTorqWithoutExt = fakeTorque
|
||||
torqueLoss = 20
|
||||
requestedTorque = fakeTorque
|
||||
engineTorque = fakeTorque * 0.9
|
||||
innerTorqWithoutExt = fakeTorque
|
||||
torqueLoss = 20
|
||||
requestedTorque = fakeTorque
|
||||
|
||||
motor1Data[2] = engineTorque / 0.39
|
||||
setTwoBytes(motor1Data, 2, rpm / 0.25)
|
||||
motor1Data[5] = innerTorqWithoutExt / 0.4
|
||||
motor1Data[6] = tps / 0.4
|
||||
motor1Data[7] = torqueLoss / 0.39
|
||||
motor1Data[8] = requestedTorque / 0.39
|
||||
motor1Data[2] = engineTorque / 0.39
|
||||
setTwoBytes(motor1Data, 2, rpm / 0.25)
|
||||
motor1Data[5] = innerTorqWithoutExt / 0.4
|
||||
motor1Data[6] = tps / 0.4
|
||||
motor1Data[7] = torqueLoss / 0.39
|
||||
motor1Data[8] = requestedTorque / 0.39
|
||||
|
||||
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
|
||||
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
|
||||
end
|
||||
|
||||
function getBitRange(data, bitIndex, bitWidth)
|
||||
|
@ -136,7 +136,7 @@ function onMotor3(bus, id, dlc, data)
|
|||
iat = getBitRange(data, 8, 8) * 0.75 - 48
|
||||
pps = getBitRange(data, 16, 8) * 0.40
|
||||
tps = getBitRange(data, 56, 8) * 0.40
|
||||
-- print ('MOTOR_1 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
|
||||
-- print ('MOTOR_1 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
|
||||
|
||||
sendMotor3()
|
||||
end
|
||||
|
@ -152,13 +152,13 @@ function onMotor1(bus, id, dlc, data)
|
|||
|
||||
fakeTorque = interpolate(0, 6, 100, 60, tps)
|
||||
|
||||
-- sendMotor1()
|
||||
relayFromECU(bus, id, dlc, data)
|
||||
-- sendMotor1()
|
||||
relayFromECU(bus, id, dlc, data)
|
||||
end
|
||||
|
||||
function relayFromECUAndEcho(bus, id, dlc, data)
|
||||
totalEcuMessages = totalEcuMessages + 1
|
||||
print("Relaying to TCU " .. id)
|
||||
print("Relaying to TCU " ..id)
|
||||
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||
end
|
||||
|
||||
|
@ -166,14 +166,14 @@ totalTcuMessages = 0
|
|||
|
||||
function relayFromTCU(bus, id, dlc, data)
|
||||
totalTcuMessages = totalTcuMessages + 1
|
||||
-- print("Relaying to ECU " .. id)
|
||||
-- print("Relaying to ECU " .. id)
|
||||
txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU
|
||||
end
|
||||
|
||||
function relayTcuDiagHelloFromTCU(bus, id, dlc, data)
|
||||
totalTcuMessages = totalTcuMessages + 1
|
||||
print("Relaying TcuDiagHello to ECU " .. id .. arrayToString(data))
|
||||
txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU
|
||||
totalTcuMessages = totalTcuMessages + 1
|
||||
print("Relaying TcuDiagHello to ECU " ..id ..arrayToString(data))
|
||||
txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU
|
||||
end
|
||||
|
||||
|
||||
|
@ -181,12 +181,12 @@ local payLoadIndex = 0
|
|||
|
||||
function relayTpPayloadFromTCU(bus, id, dlc, data)
|
||||
totalTcuMessages = totalTcuMessages + 1
|
||||
-- print("Relaying TP ECU " ..id ..arrayToString(data))
|
||||
-- print("Relaying TP ECU " ..id ..arrayToString(data))
|
||||
txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU
|
||||
|
||||
|
||||
if data[1] == 0xA3 then
|
||||
-- print ("Keep-alive")
|
||||
-- print ("Keep-alive")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -217,7 +217,7 @@ function relayTpPayloadFromTCU(bus, id, dlc, data)
|
|||
H4 = data[4]
|
||||
H7 = data[7] or -1
|
||||
|
||||
-- print("h5/h7 " ..H4 .." " ..H7)
|
||||
-- print("h5/h7 " ..H4 .." " ..H7)
|
||||
|
||||
if H7 == 0 then
|
||||
print("I sniff diag: TCU is happy!")
|
||||
|
@ -253,12 +253,12 @@ end
|
|||
|
||||
motorBreCounter = 0
|
||||
function sendMotorBre()
|
||||
motorBreCounter = (motorBreCounter + 1) % 16
|
||||
motorBreCounter = (motorBreCounter + 1) % 16
|
||||
|
||||
setBitRange(motorBreData, 8, 4, motorBreCounter)
|
||||
xorChecksum(motorBreData, 1)
|
||||
|
||||
txCan(TCU_BUS, MOTOR_BRE, 0, motorBreData)
|
||||
txCan(TCU_BUS, MOTOR_BRE, 0, motorBreData)
|
||||
end
|
||||
|
||||
|
||||
|
@ -340,7 +340,7 @@ end
|
|||
totalEcuMessages = 0
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_7, drop)
|
||||
--canRxAdd(ECU_BUS, ACC_GRA, drop)
|
||||
-- canRxAdd(ECU_BUS, ACC_GRA, drop)
|
||||
|
||||
-- REQUIRED kombi 3
|
||||
canRxAdd(ECU_BUS, 1312, relayFromECU)
|
||||
|
@ -366,20 +366,20 @@ canRxAdd(ECU_BUS, 1488, relayFromECU)
|
|||
canRxAdd(ECU_BUS, 2000, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_1, onMotor1)
|
||||
--canRxAdd(ECU_BUS, MOTOR_BRE, relayFromECU)
|
||||
-- canRxAdd(ECU_BUS, MOTOR_BRE, relayFromECU)
|
||||
canRxAdd(ECU_BUS, MOTOR_2, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_3, onMotor3)
|
||||
--canRxAdd(ECU_BUS, MOTOR_3, relayFromECU)
|
||||
-- canRxAdd(ECU_BUS, MOTOR_3, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_5, onMotor5)
|
||||
--canRxAdd(ECU_BUS, MOTOR_5, relayFromECU)
|
||||
-- canRxAdd(ECU_BUS, MOTOR_5, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_6, sendMotor6)
|
||||
--canRxAdd(ECU_BUS, MOTOR_6, relayFromECU)
|
||||
-- canRxAdd(ECU_BUS, MOTOR_6, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, ACC_GRA, relayFromECU)
|
||||
--canRxAdd(ECU_BUS, MOTOR_INFO, relayFromECU)
|
||||
-- canRxAdd(ECU_BUS, MOTOR_INFO, relayFromECU)
|
||||
|
||||
canRxAdd(ECU_BUS, VWTP_OUT, relayFromECU)
|
||||
canRxAdd(ECU_BUS, 0x760, relayFromECU)
|
||||
|
@ -388,7 +388,7 @@ canRxAdd(TCU_BUS, VWTP_IN, relayTcuDiagHelloFromTCU)
|
|||
canRxAdd(TCU_BUS, VWTP_TESTER, relayTpPayloadFromTCU)
|
||||
|
||||
canRxAddMask(ECU_BUS, 0, 0, drop)
|
||||
--canRxAddMask(ECU_BUS, 0, 0, relayFromECU)
|
||||
-- canRxAddMask(ECU_BUS, 0, 0, relayFromECU)
|
||||
canRxAddMask(TCU_BUS, 0, 0, relayFromTCU)
|
||||
|
||||
everySecondTimer = Timer.new()
|
||||
|
@ -407,3 +407,4 @@ function onTick()
|
|||
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue