GCC Code Coverage Report


Directory: ./
File: firmware/config/engines/nissan_vq.lua
Date: 2025-10-24 15:43:41
Coverage Exec Excl Total
Lines: -% 0 0 0
Functions: -% 0 0 0
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 // by definition this should be a copy-paste of https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/350z-ac.txt
2 strncpy(config->luaScript, R"(
3
4 IN_284 = 0x284 -- 644
5 IN_285 = 0x285 -- 645
6 IN_285 = 0x285
7 IN_35D = 0x35d
8
9 ENGINE_1_1F9_505 = 505
10 ENGINE_2_561 = 561
11 ENGINE_7_233_563 = 563
12 ENGINE_3_23D_573 = 573
13 ENGINE_4_23E_574 = 574
14 ENGINE_5_551_1361 = 1361
15 ENGINE_6_580_1408 = 1408
16
17 speedSensor = Sensor.new("VehicleSpeed")
18 speedSensor : setTimeout(3000)
19
20 setTickRate(100)
21 startUpTimer = Timer.new()
22 startUpTimer : reset()
23 rpm = 0
24 pps = 0
25
26 globalAcOut = 0
27 cltGauge = 0
28
29 function getTwoBytesMSB(data, offset, factor)
30 return (data[offset + 1] * 256 + data[offset + 2]) * factor
31 end
32
33 -- Little-endian System, "Intel"
34 function setTwoBytesLsb(data, offset, value)
35 value = math.floor(value)
36 data[offset + 2] = value >> 8
37 data[offset + 1] = value & 0xff
38 end
39
40 payloadENGINE_3_573 = { 0x00, 0, 0x0C, 0x01, 0x0A, 0x87, 0xFF, 0xFF }
41 function sendENGINE_3_573()
42 rpmWithSweep = startUpTimer : getElapsedSeconds() < 2 and 8000 or rpm
43 setTwoBytesLsb(payloadENGINE_3_573, 3, rpmWithSweep / 3.125)
44
45 payloadENGINE_3_573[2] = pps / 0.392
46 payloadENGINE_3_573[3] = pps / 0.392 -- Throttle_position_capped
47 payloadENGINE_3_573[8] = cltGauge
48 txCan(1, ENGINE_3_23D_573, 0, payloadENGINE_3_573)
49 end
50
51 payloadENGINE_7_563 = {0x79, 0xa2, 0x00, 0x18, 0x0e, 0x00, 0x00, 0x01}
52 function sendENGINE_7_233_563()
53 local RPMread = rpm / 3.125
54 local RPMhi = RPMread / 256
55 local RPMlo = RPMread
56
57 payloadENGINE_7_563[1] = cltGauge
58 payloadENGINE_7_563[4] = state_233
59 payloadENGINE_7_563[5] = RPMlo
60 payloadENGINE_7_563[8] = RPMhi
61
62 state_233 = rpm > 250 and 0x10 or 0x18
63
64 txCan(1, ENGINE_7_233_563, 0, payloadENGINE_7_563) -- transmit CLT and RPM for who knows whom
65 end
66
67 function sendENGINE_1_505()
68 if rpm > 250 then
69 if cltValue <= 80 then
70 txCan(1, ENGINE_1_1F9_505, 0, fanPayloadOff)
71 elseif cltValue < 85 then
72 -- send nothing
73 elseif cltValue < 90 then
74 txCan(1, ENGINE_1_1F9_505, 0, fanPayloadLo)
75 else
76 txCan(1, ENGINE_1_1F9_505, 0, fanPayloadHi)
77 end
78 else
79 txCan(1, ENGINE_1_1F9_505, 0, fanPayloadOff)
80 end
81 -- print('CLT temp' ..cltValue)
82 end
83
84 payloadENGINE_2_561 = {0xe0, 0x80, 0x09, 0xe0, 0xd4, 0xc3, 0x4c, 0x9e}
85 function sendENGINE_2_231_561()
86 payloadENGINE_2_561[3] = pps / 0.5 -- tps or pps
87 txCan(1, ENGINE_2_561, 0, payloadENGINE_2_561)
88 end
89
90 payloadENGINE_4_574 = {0x00, 0x40, 0xff, 0x45, 0x00, 0xd6, 0x00, 0xa2}
91 function sendENGINE_4_23E_574()
92 payloadENGINE_4_574[3] = (100 - pps) / 0.392 -- data[3] -- affects desired torque converter pressure Throttle_position_inverted
93 payloadENGINE_4_574[7] = pps / 0.392 -- data[7] -- TPS
94 txCan(1, ENGINE_4_23E_574, 0, payloadENGINE_4_574)
95 end
96
97 CAN_721_2d1 = 721
98 payload721_2d1 = {0x00, 0x84, 0x00, 0x00, 0x31, 0xf8, 0x01}
99 function sendCan721_2d1()
100 txCan(1, CAN_721_2d1, 0, payload721_2d1)
101 end
102
103 CAN_734_2de = 734
104 payload734_2de = {0x0f, 0x08, 0x02, 0x00, 0x19, 0x65, 0x07, 0xa8}
105 function sendCan734_2de()
106 txCan(1, CAN_734_2de, 0, payload734_2de)
107 end
108
109 payloadENGINE_5 = {0x7d, 0xdb, 0x00, 0xa0, 0x00, 0x02, 0x80, 0xff}
110 function sendENGINE_5_551_1361()
111 txCan(1, ENGINE_5_551_1361, 0, payloadENGINE_5)
112 end
113
114 payloadENGINE_6 = {0x00, 0x82, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00}
115 function sendEngine6_580_1408()
116 txCan(1, ENGINE_6_580_1408, 0, payloadENGINE_6)
117 end
118
119 _10msPeriodTimer = Timer.new()
120 _15msPeriodTimer = Timer.new()
121
122 function onTick()
123 pps = getSensor("AcceleratorPedal") or 0
124 pps = (pps == nil and 0 or pps)
125 rpm = math.floor(getSensor("RPM") + 0.5)
126
127
128 cltValue = getSensor("CLT")
129 cltValue = (cltValue == nil and 0 or cltValue)
130
131 --print('ac out = ' ..globalAcOut)
132 if globalAcOut == 1 and rpm > 250 then
133 fanPayloadOff = { 0x88, 0x00 }
134 fanPayloadLo = { 0x88, 0x00 }
135 fanPayloadHi = { 0x88, 0x00 }
136 else
137 --print('ac off payload')
138 fanPayloadOff = { 0x00, 0x00 }
139 fanPayloadLo = { 0x40, 0x00 }
140 fanPayloadHi = { 0x80, 0x00 }
141 end
142
143 -- clt gauge stuff
144 if cltValue < 115 then
145 cltGauge = math.floor(cltValue * 1.5 + 0.5)
146 else
147 cltGauge = 0xF0
148 end
149
150
151 if _10msPeriodTimer : getElapsedSeconds() > 0.01 then
152 _10msPeriodTimer : reset()
153 sendENGINE_1_505()
154 sendENGINE_2_231_561()
155 sendENGINE_7_233_563()
156 sendENGINE_3_573()
157 sendENGINE_4_23E_574()
158 sendCan721_2d1()
159 sendCan734_2de()
160 end
161
162
163 if _15msPeriodTimer : getElapsedSeconds() > 0.015 then
164 _15msPeriodTimer : reset()
165 sendENGINE_5_551_1361()
166 sendEngine6_580_1408()
167 end
168
169
170 end
171
172 function onCanRxAbs1(bus, id, dlc, data)
173 kph = getTwoBytesMSB(data, 0, 0.005)
174 speedSensor : set(kph)
175 end
176
177 function onCanRxAc(bus, id, dlc, data)
178 --print('got CAN id=' ..id ..' dlc=' ..dlc)
179 --print('ac value is= '..data[1])
180 if data[1] == 193 then
181 setAcRequestState(true)
182 globalAcOut = 1
183 --print('ac is on')
184 else
185 setAcRequestState(false)
186 globalAcOut = 0
187 --print('ac is off')
188 end
189
190 end
191
192 function onCanRxWheelSpeed1(bus, id, dlc, data)
193 end
194
195 function onCanRxWheelSpeed2(bus, id, dlc, data)
196 end
197
198 canRxAdd(IN_284, onCanRxWheelSpeed1)
199 canRxAdd(IN_285, onCanRxWheelSpeed2)
200 canRxAdd(IN_35D, onCanRxAbs1)
201 canRxAdd(IN_35D, onCanRxAc)
202
203 )", efi::size(config->luaScript));
204