| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | #include "custom_engine.h" | |||
| 3 | ||||
| 4 | // set engine_type 57 | |||
| 5 | ✗ | void setHondaCivicBcm() { | ||
| 6 | ✗ | setBodyControlUnit(); | ||
| 7 | ✗ | engineConfiguration->totalGearsCount = 6; | ||
| 8 | ✗ | engineConfiguration->gearRatio[0] = 12; | ||
| 9 | ✗ | engineConfiguration->gearRatio[1] = 9; | ||
| 10 | ✗ | engineConfiguration->gearRatio[2] = 6.2; | ||
| 11 | ✗ | engineConfiguration->gearRatio[3] = 4.8; | ||
| 12 | ✗ | engineConfiguration->gearRatio[4] = 3.7; | ||
| 13 | ✗ | engineConfiguration->gearRatio[5] = 2.8; | ||
| 14 | ||||
| 15 | ✗ | engineConfiguration->isBoostControlEnabled = true; | ||
| 16 | ||||
| 17 | #ifdef HW_SMALL_CAN_BOARD | |||
| 18 | strncpy(config->luaScript, R"( | |||
| 19 | -- this controls onCanRx rate as well! | |||
| 20 | setTickRate(300) | |||
| 21 | ||||
| 22 | timeout = 3000 | |||
| 23 | ||||
| 24 | rpmSensor = Sensor.new("rpm") | |||
| 25 | rpmSensor : setTimeout(timeout) | |||
| 26 | ||||
| 27 | ppsSensor = Sensor.new("AcceleratorPedal") | |||
| 28 | ppsSensor : setTimeout(timeout) | |||
| 29 | ||||
| 30 | speedSensor = Sensor.new("VehicleSpeed") | |||
| 31 | speedSensor : setTimeout(timeout) | |||
| 32 | ||||
| 33 | canTimer = Timer.new() | |||
| 34 | canTimer : reset() | |||
| 35 | ||||
| 36 | hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" } | |||
| 37 | ||||
| 38 | function getTwoBytesMSB(data, offset, factor) | |||
| 39 | return (data[offset + 1] * 256 + data[offset + 2]) * factor | |||
| 40 | end | |||
| 41 | ||||
| 42 | function getTwoBytesLSB(data, offset, factor) | |||
| 43 | return (data[offset + 2] * 256 + data[offset + 1]) * factor | |||
| 44 | end | |||
| 45 | ||||
| 46 | function onPOWERTRAIN_DATA(bus, id, dlc, data) | |||
| 47 | canTimer : reset() | |||
| 48 | -- print('onPOWERTRAIN_DATA ' ..arrayToString(data)) | |||
| 49 | ||||
| 50 | ppsValue = data[1] * 100.0 / 255 | |||
| 51 | ppsSensor : set(ppsValue) | |||
| 52 | ||||
| 53 | rpmValue = getTwoBytesMSB(data, 2, 1) | |||
| 54 | rpmSensor : set(rpmValue) | |||
| 55 | -- print('onPOWERTRAIN_DATA ' .. rpmValue .. ' pedal ' .. ppsValue) | |||
| 56 | end | |||
| 57 | ||||
| 58 | function onCAR_SPEED(bus, id, dlc, data) | |||
| 59 | canTimer : reset() | |||
| 60 | speedKph = getTwoBytesLSB(data, 1, 0.01) | |||
| 61 | print('onCAR_SPEED ' .. speedKph) | |||
| 62 | speedSensor : set(speedKph) | |||
| 63 | ||||
| 64 | print('onPOWERTRAIN_DATA speed' .. speedKph .. ' ratio ' .. (speedKph / rpmValue)) | |||
| 65 | ||||
| 66 | end | |||
| 67 | ||||
| 68 | canRxAdd(1, 0x17C, onPOWERTRAIN_DATA) | |||
| 69 | canRxAdd(1, 0x309, onCAR_SPEED) | |||
| 70 | ||||
| 71 | commTimer = Timer.new() | |||
| 72 | commTimer : reset() | |||
| 73 | ||||
| 74 | canDelay = 1 | |||
| 75 | commDelay = 20 | |||
| 76 | ||||
| 77 | function onTick() | |||
| 78 | if getOutput("isUsbConnected") == 1 then | |||
| 79 | commTimer : reset() | |||
| 80 | end | |||
| 81 | if (canTimer : getElapsedSeconds() > canDelay) and (commTimer : getElapsedSeconds() > commDelay) then | |||
| 82 | mcu_standby() | |||
| 83 | end | |||
| 84 | end | |||
| 85 | )", efi::size(config->luaScript)); | |||
| 86 | #endif // HW_SMALL_CAN_BOARD | |||
| 87 | ✗ | } | ||
| 88 |