happy even while running
This commit is contained in:
parent
e3a187afa6
commit
06d357dd7c
|
@ -172,12 +172,16 @@ function sendMotor3()
|
|||
txCan(TCU_BUS, MOTOR_3, 0, canMotor3)
|
||||
end
|
||||
|
||||
motor3counter = 0
|
||||
function onMotor3(bus, id, dlc, data)
|
||||
motor3counter = (motor3counter + 1) % 16
|
||||
totalEcuMessages = totalEcuMessages + 1
|
||||
iat = 30 -- getBitRange(data, 8, 8) * 0.75 - 48
|
||||
pps = 7 -- getBitRange(data, 16, 8) * 0.40
|
||||
tps = 7 -- getBitRange(data, 56, 8) * 0.40
|
||||
-- print ('MOTOR_3 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
|
||||
if motor3counter % 70 == 0 then
|
||||
print ('MOTOR_3 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
|
||||
end
|
||||
end
|
||||
|
||||
function onMotor1(bus, id, dlc, data)
|
||||
|
@ -323,9 +327,9 @@ function sendMotor5()
|
|||
txCan(TCU_BUS, MOTOR_5, 0, motor5Data)
|
||||
end
|
||||
|
||||
counter16 = 0
|
||||
motor6Counter = 0
|
||||
function sendMotor6()
|
||||
counter16 = (counter16 + 1) % 16
|
||||
motor6Counter = (motor6Counter + 1) % 16
|
||||
|
||||
engineTorque = fakeTorque * 0.9
|
||||
actualTorque = fakeTorque
|
||||
|
@ -334,7 +338,7 @@ function sendMotor6()
|
|||
motor6Data[2] = math.floor(engineTorque / 0.39)
|
||||
motor6Data[3] = math.floor(actualTorque / 0.39)
|
||||
motor6Data[6] = math.floor(feedbackGearbox / 0.39)
|
||||
setBitRange(motor6Data, 60, 4, counter16)
|
||||
setBitRange(motor6Data, 60, 4, motor6Counter)
|
||||
|
||||
xorChecksum(motor6Data, 1)
|
||||
txCan(TCU_BUS, MOTOR_6, 0, motor6Data)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
-- scriptname script_5_fake_torque_motor1.lua
|
||||
-- scriptname script_6_fake_torque_motor1.lua
|
||||
|
||||
-- sometimes we want to cut a CAN bus and install rusEFI into that cut
|
||||
-- https://en.wikipedia.org/wiki/Man-in-the-middle_attack
|
||||
|
@ -19,6 +19,7 @@ motor1Data = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
|||
canMotorInfo02 = { 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 }
|
||||
motor6Data = { 0x00, 0x00, 0x00, 0x7E, 0xFE, 0xFF, 0xFF, 0x00 }
|
||||
motor7Data = { 0x1A, 0x66, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
||||
totalVehicleMessages = 0
|
||||
|
@ -26,6 +27,8 @@ totalTcuMessages = 0
|
|||
totalDropped = 0
|
||||
totalReplaced = 0
|
||||
|
||||
motor5FuelCounter = 0
|
||||
|
||||
function relayFromVehicleToTcu(bus, id, dlc, data)
|
||||
totalVehicleMessages = totalVehicleMessages + 1
|
||||
-- print('from ECU ' .. id .. " " .. arrayToString(data) .. " dropped=" .. totalDropped .. " replaced " .. totalReplaced)
|
||||
|
@ -69,6 +72,34 @@ function sendMotor1()
|
|||
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
|
||||
end
|
||||
|
||||
--motor5counter = 0
|
||||
motor5FuelCounter = 0
|
||||
function sendMotor5()
|
||||
-- motor5counter = (motor5counter + 1) % 16
|
||||
-- todo index = math.floor(motor5counter / 4)
|
||||
|
||||
setBitRange(motor5Data, 5, 9, motor5FuelCounter)
|
||||
vagXorChecksum(motor5Data, 8)
|
||||
txCan(TCU_BUS, MOTOR_5, 0, motor5Data)
|
||||
end
|
||||
|
||||
motor6Counter = 0
|
||||
function sendMotor6()
|
||||
motor6Counter = (motor6Counter + 1) % 16
|
||||
|
||||
engineTorque = fakeTorque * 0.9
|
||||
actualTorque = fakeTorque
|
||||
feedbackGearbox = 255
|
||||
|
||||
motor6Data[2] = math.floor(engineTorque / 0.39)
|
||||
motor6Data[3] = math.floor(actualTorque / 0.39)
|
||||
motor6Data[6] = math.floor(feedbackGearbox / 0.39)
|
||||
setBitRange(motor6Data, 60, 4, motor6Counter)
|
||||
|
||||
vagXorChecksum(motor6Data, 1)
|
||||
txCan(TCU_BUS, MOTOR_6, 0, motor6Data)
|
||||
end
|
||||
|
||||
function sendMotor7()
|
||||
txCan(TCU_BUS, MOTOR_7, 0, motor7Data)
|
||||
end
|
||||
|
@ -106,19 +137,31 @@ function onMotor1(bus, id, dlc, data)
|
|||
|
||||
motor1counter = motor1counter + 1
|
||||
if motor1counter % 40 == 0 then
|
||||
print('RPM=' .. rpm .. ' TPS=' .. tps)
|
||||
end
|
||||
print('RPM=' ..rpm ..' TPS=' ..tps)
|
||||
end
|
||||
|
||||
sendMotor1()
|
||||
end
|
||||
|
||||
motor3counter = 0
|
||||
function onMotor3(bus, id, dlc, data)
|
||||
motor3counter = (motor3counter + 1) % 16
|
||||
iat = 30 -- getBitRange(data, 8, 8) * 0.75 - 48
|
||||
pps = 7 -- getBitRange(data, 16, 8) * 0.40
|
||||
tps = 7 -- getBitRange(data, 56, 8) * 0.40
|
||||
if motor3counter % 70 == 0 then
|
||||
print ('MOTOR_3 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
|
||||
end
|
||||
relayFromVehicleToTcu(bus, id, dlc, data)
|
||||
end
|
||||
|
||||
canRxAdd(VEHICLE_BUS, Komf_1_912, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, ACC_GRA, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, GRA_Neu, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, Kombi_3, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, Soll_Verbauliste_neu, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, Systeminfo_1, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, Diagnose_1, relayFromVehicleToTcu) -- ?
|
||||
canRxAdd(VEHICLE_BUS, Diagnose_1, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, BRAKE_1_416, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, BRAKE_2_1440, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, BRAKE_3_1184, relayFromVehicleToTcu)
|
||||
|
@ -129,11 +172,9 @@ canRxAdd(VEHICLE_BUS, VPTP_TCU, relayFromVehicleToTcu)
|
|||
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_1, onMotor1)
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_2, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_3, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_3, onMotor3)
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_5, relayFromVehicleToTcu)
|
||||
canRxAdd(VEHICLE_BUS, MOTOR_6, relayFromVehicleToTcu)
|
||||
--canRxAdd(VEHICLE_BUS, MOTOR_7, relayFromVehicleToTcu)
|
||||
--canRxAdd(VEHICLE_BUS, Motor_Flexia, relayFromVehicleToTcu)
|
||||
--canRxAdd(VEHICLE_BUS, MOTOR_5, relayFromVehicleToTcu)
|
||||
|
||||
canRxAdd(TCU_BUS, VWTP_IN, relayFromTcuToVehicle)
|
||||
canRxAdd(TCU_BUS, VWTP_TESTER, relayFromTcuToVehicle)
|
||||
|
@ -148,6 +189,8 @@ canRxAddMask(TCU_BUS, 0, 0, printAndDrop)
|
|||
everySecondTimer = Timer.new()
|
||||
|
||||
function onTick()
|
||||
-- sendMotor5()
|
||||
sendMotor6()
|
||||
sendMotor7()
|
||||
|
||||
if everySecondTimer:getElapsedSeconds() > 1 then
|
||||
|
|
Loading…
Reference in New Issue