GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 19
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 15
Decisions: 0.0% 0 / - / 2

firmware/controllers/can/can_dash_nissan.cpp
Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #if EFI_CAN_SUPPORT || EFI_UNIT_TEST
4 #include "can.h"
5 #include "can_msg_tx.h"
6
7 //https://www.drive2.ru/b/500679938089681452/
8 #define NISSAN_STEERING_WHEEL 0x002
9
10 #define NISSAN_ENGINE_2 0x231_561
11
12 #define NISSAN_ENGINE_7_233_563 0x233
13
14 #define NISSAN_ENGINE_1_RPM_1F9_505 0x1F9
15
16 // Nissan z33 350Z and else
17 // 0x23d = 573
18 #define NISSAN_ENGINE_3_23D_573 0x23D
19 #define NISSAN_ENGINE_4_23E_574 0x23E
20
21 #define NISSAN_TCU_1 0x251
22 #define NISSAN_TCU_2 0x253
23
24 // 640
25 #define NISSAN_VEHICLE_SPEED_280 0x280
26 // wheel speed see "102 CAN Communication decoded"
27 // 19500 value would be 100 kph
28 // 644
29 #define NISSAN_WHEEL_SPEED1 0x284
30 // 645
31 #define NISSAN_WHEEL_SPEED2 0x285
32
33 // 670
34 #define NISSAN_UNKNOWN_4 0x29E
35
36 #define NISSAN_ABS 0x2A0
37
38 // 833 doors
39 #define NISSAN_BCM 0x341
40
41 // https://www.drive2.com/l/530057789272229668/
42 // 852
43 #define NISSAN_VEHICLE_SPEED 0x354
44
45 #define NISSAN_ENGINE_5_CLT_551_1361 0x551
46 // 1408
47 #define NISSAN_RPM_AGAIN 0x580
48 #define NISSAN_ODOMETER 0x5C5
49 // 1549
50 #define NISSAN_BCM_2 0x60D
51
52
53 void canDashboardNissanVQ(CanCycle cycle) {
54 static int rollingId = 0;
55
56 if (cycle.isInterval(CI::_50ms)) {
57 {
58 CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_1_RPM_1F9_505, 8);
59 msg.setShortValueMsb(Sensor::getOrZero(SensorType::Rpm) * 8, /*offset*/ 2);
60 }
61
62 {
63 CanTxMessage msg(CanCategory::OBD, NISSAN_ENGINE_5_CLT_551_1361, 8);
64
65 int clt = Sensor::getOrZero(SensorType::Clt);
66 msg[0] = clt + 45;
67 }
68
69
70 {
71 CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_3_23D_573, 8);
72
73 rollingId = (rollingId + 1) % 4;
74 const uint8_t magicByte[4] = {0x03, 0x23, 0x42, 0x63};
75
76 msg[0] = magicByte[rollingId];
77 msg[1] = (int)(Sensor::getOrZero(SensorType::AcceleratorPedal) * 255 / 100);
78
79 // thank you "102 CAN Communication decoded"
80 #define CAN_23D_RPM_MULT 3.15
81 int rpm315 = (int)(Sensor::getOrZero(SensorType::Rpm) / CAN_23D_RPM_MULT);
82 msg.setShortValue(rpm315, /*offset*/ 3);
83
84 msg[7] = 0x70; // todo: CLT decoding?
85 }
86 }
87 }
88
89 #endif
90