Skip to content

Commit

Permalink
BMW 6HP gatewy #3954
Browse files Browse the repository at this point in the history
OMG it works!!!
  • Loading branch information
rusefillc committed Feb 23, 2022
1 parent 2951411 commit 387e957
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions firmware/config/engines/bmw_n73.cpp
Expand Up @@ -96,9 +96,9 @@ canRxAdd(E90_GEAR_SELECTOR)
canRxAdd(E90_DSC_STATUS)
canRxAdd(E90_DSC_SPEED)
canRxAdd(E90_COOLANT)
canRxAdd(E90_LOCKING)
canRxAdd(E90_MSA)
canRxAdd(E90_DASH_ON)
--canRxAdd(E90_LOCKING)
--canRxAdd(E90_MSA)
--canRxAdd(E90_DASH_ON)
canRxAdd(E90_ECU_NETWORK)
canRxAdd(E90_INPA_TCU)
Expand Down Expand Up @@ -152,27 +152,29 @@ end
function onCanRx(bus, id, dlc, data)
id = id % 2048
-- local output = string.format("%x", id)
if id == E90_TORQUE_1 then
TORQ_AVL = 0.5 * (getTwoBytes(data, 1, 1) >> 4)
TORQ_AVL_DMEE = 0.5 * (getTwoBytes(data, 3, 1) >> 4)
print('E90_TORQUE_1 TORQ_AVL=' ..TORQ_AVL ..' TORQ_AVL_DMEE=' ..TORQ_AVL_DMEE)
printDebug('E90_TORQUE_1 TORQ_AVL=' ..TORQ_AVL ..' TORQ_AVL_DMEE=' ..TORQ_AVL_DMEE)
relayToTcu(id, data)
elseif id == E90_TORQUE_2 then
printDebug('E90_TORQUE_2')
relayToTcu(id, data)
elseif id == E90_RPM_THROTTLE then
rpm = getTwoBytes(data, 4, 0.25)
pedal = data [1 + 3] * 100 / 256.0
print('E90_RPM_THROTTLE rpm=' .. rpm .. ' pedal=' .. pedal)
printDebug('E90_RPM_THROTTLE rpm=' .. rpm .. ' pedal=' .. pedal)
output = {0, 0, 0, data [1 + 3], data [1 + 4], data [1 + 5], 0, 0}
counterE90_RPM_THROTTLE = (counterE90_RPM_THROTTLE + 1) % 15
output[2] = counterE90_RPM_THROTTLE
output[1] = bmwChecksum(E90_RPM_THROTTLE, output, 2, 7)
relayToTcu(id, data)
-- print('original ' ..print_array(data))
-- print('repacked ' ..print_array(output))
relayToTcu(id, output)
elseif id == E90_DSC_TORQUE_DEMAND then
printDebug('E90_DSC_TORQUE_DEMAND')
relayToTcu(id, data)
Expand Down Expand Up @@ -217,7 +219,7 @@ function onCanRx(bus, id, dlc, data)
printDebug('E90_ECU_NETWORK')
relayToTcu(id, data)
elseif id == E90_INPA_TCU then
print('E90_INPA_TCU')
printDebug('E90_INPA_TCU')
relayToTcu(id, data)
elseif id == TCU_TORQUE_DEMAND2 then
TORQ_TAR_EGS = getBitRange(data, 12, 12)
Expand All @@ -228,7 +230,11 @@ function onCanRx(bus, id, dlc, data)
printDebug('*******TCU_TRANSMISSION_DATA')
gearBits = data[1] & 0xF
if (gearBits >= 5 and gearBits <= 0xA) then
printDebug('*******TCU_TRANSMISSION_DATA gear ' .. (gearBits - 4))
print('*******TCU_TRANSMISSION_DATA gear ' ..(gearBits - 4))
elseif gearBits == 1 or gearBits == 2 or gearBits == 3 then
printDebug('*******TCU_TRANSMISSION_DATA gear R/N/P')
else
printDebug('*******TCU_TRANSMISSION_DATA gear ' .. gearBits)
end
relayToEcu(id, data)
elseif id == TCU_GEARBOX_DATA_2 then
Expand All @@ -247,7 +253,7 @@ function onCanRx(bus, id, dlc, data)
printDebug('*******TCU_SERVICE')
relayToEcu(id, data)
elseif id == TCU_INPA_RESPONSE then
print('*******TCU_INPA_RESPONSE')
printDebug('*******TCU_INPA_RESPONSE')
relayToEcu(id, data)
else
print('No handler for ' ..id)
Expand Down

0 comments on commit 387e957

Please sign in to comment.