extracting can_dash_nissan.cpp
This commit is contained in:
parent
e2aa1dd7a9
commit
fdd9eddc3b
|
@ -12,6 +12,7 @@
|
|||
#if EFI_CAN_SUPPORT
|
||||
#include "can_dash.h"
|
||||
#include "can_dash_ms.h"
|
||||
#include "can_dash_nissan.h"
|
||||
#include "can_msg_tx.h"
|
||||
#include "can_bmw.h"
|
||||
#include "can_vag.h"
|
||||
|
@ -61,48 +62,6 @@ static time_msecs_t mph_ctr;
|
|||
// when A/C compressor is allowed to be on, these values need to be sent so the A/C panel activates the compressor
|
||||
#define GENESIS_COUPLE_AC_ENABLE_18F 0x18F
|
||||
|
||||
//https://www.drive2.ru/b/500679938089681452/
|
||||
#define NISSAN_STEERING_WHEEL 0x002
|
||||
|
||||
#define NISSAN_ENGINE_1_RPM_1F9_505 0x1F9
|
||||
|
||||
#define NISSAN_ENGINE_2 0x231_561
|
||||
#define NISSAN_ENGINE_7_233_563 0x233
|
||||
// Nissan z33 350Z and else
|
||||
// 0x23d = 573
|
||||
#define NISSAN_ENGINE_3_23D_573 0x23D
|
||||
#define NISSAN_ENGINE_4_23E_574 0x23E
|
||||
|
||||
#define NISSAN_TCU_1 0x251
|
||||
#define NISSAN_TCU_2 0x253
|
||||
|
||||
// 640
|
||||
#define NISSAN_VEHICLE_SPEED_280 0x280
|
||||
// wheel speed see "102 CAN Communication decoded"
|
||||
// 19500 value would be 100 kph
|
||||
// 644
|
||||
#define NISSAN_WHEEL_SPEED1 0x284
|
||||
// 645
|
||||
#define NISSAN_WHEEL_SPEED2 0x285
|
||||
|
||||
// 670
|
||||
#define NISSAN_UNKNOWN_4 0x29E
|
||||
|
||||
#define NISSAN_ABS 0x2A0
|
||||
|
||||
// 833 doors
|
||||
#define NISSAN_BCM 0x341
|
||||
|
||||
// https://www.drive2.com/l/530057789272229668/
|
||||
// 852
|
||||
#define NISSAN_VEHICLE_SPEED 0x354
|
||||
|
||||
#define NISSAN_ENGINE_5_CLT_551_1361 0x551
|
||||
// 1408
|
||||
#define NISSAN_RPM_AGAIN 0x580
|
||||
#define NISSAN_ODOMETER 0x5C5
|
||||
// 1549
|
||||
#define NISSAN_BCM_2 0x60D
|
||||
|
||||
static uint8_t rpmcounter;
|
||||
static uint8_t seatbeltcnt;
|
||||
|
@ -119,7 +78,6 @@ void canDashboardFiat(CanCycle cycle);
|
|||
void canMazdaRX8(CanCycle cycle);
|
||||
void canDashboardW202(CanCycle cycle);
|
||||
void canDashboardVagMqb(CanCycle cycle);
|
||||
void canDashboardNissanVQ(CanCycle cycle);
|
||||
void canDashboardGenesisCoupe(CanCycle cycle);
|
||||
void canDashboardAim(CanCycle cycle);
|
||||
void canDashboardHaltech(CanCycle cycle);
|
||||
|
@ -312,8 +270,6 @@ void canDashboardW202(CanCycle cycle) {
|
|||
}
|
||||
}
|
||||
|
||||
static int rollingId = 0;
|
||||
|
||||
void canDashboardGenesisCoupe(CanCycle cycle) {
|
||||
if (cycle.isInterval(CI::_50ms)) {
|
||||
{
|
||||
|
@ -328,40 +284,6 @@ void canDashboardGenesisCoupe(CanCycle cycle) {
|
|||
}
|
||||
}
|
||||
|
||||
void canDashboardNissanVQ(CanCycle cycle) {
|
||||
if (cycle.isInterval(CI::_50ms)) {
|
||||
{
|
||||
CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_1_RPM_1F9_505, 8);
|
||||
msg.setShortValueMsb(Sensor::getOrZero(SensorType::Rpm) * 8, /*offset*/ 2);
|
||||
}
|
||||
|
||||
{
|
||||
CanTxMessage msg(CanCategory::OBD, NISSAN_ENGINE_5_CLT_551_1361, 8);
|
||||
|
||||
int clt = Sensor::getOrZero(SensorType::Clt);
|
||||
msg[0] = clt + 45;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_3_23D_573, 8);
|
||||
|
||||
rollingId = (rollingId + 1) % 4;
|
||||
const uint8_t magicByte[4] = {0x03, 0x23, 0x42, 0x63};
|
||||
|
||||
msg[0] = magicByte[rollingId];
|
||||
msg[1] = (int)(Sensor::getOrZero(SensorType::AcceleratorPedal) * 255 / 100);
|
||||
|
||||
// thank you "102 CAN Communication decoded"
|
||||
#define CAN_23D_RPM_MULT 3.15
|
||||
int rpm315 = (int)(Sensor::getOrZero(SensorType::Rpm) / CAN_23D_RPM_MULT);
|
||||
msg.setShortValue(rpm315, /*offset*/ 3);
|
||||
|
||||
msg[7] = 0x70; // todo: CLT decoding?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://docs.google.com/spreadsheets/d/1XMfeGlhgl0lBL54lNtPdmmFd8gLr2T_YTriokb30kJg
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
#include "pch.h"
|
||||
|
||||
#if EFI_CAN_SUPPORT
|
||||
#include "can.h"
|
||||
#include "can_msg_tx.h"
|
||||
|
||||
//https://www.drive2.ru/b/500679938089681452/
|
||||
#define NISSAN_STEERING_WHEEL 0x002
|
||||
|
||||
#define NISSAN_ENGINE_2 0x231_561
|
||||
|
||||
#define NISSAN_ENGINE_7_233_563 0x233
|
||||
|
||||
#define NISSAN_ENGINE_1_RPM_1F9_505 0x1F9
|
||||
|
||||
// Nissan z33 350Z and else
|
||||
// 0x23d = 573
|
||||
#define NISSAN_ENGINE_3_23D_573 0x23D
|
||||
#define NISSAN_ENGINE_4_23E_574 0x23E
|
||||
|
||||
#define NISSAN_TCU_1 0x251
|
||||
#define NISSAN_TCU_2 0x253
|
||||
|
||||
// 640
|
||||
#define NISSAN_VEHICLE_SPEED_280 0x280
|
||||
// wheel speed see "102 CAN Communication decoded"
|
||||
// 19500 value would be 100 kph
|
||||
// 644
|
||||
#define NISSAN_WHEEL_SPEED1 0x284
|
||||
// 645
|
||||
#define NISSAN_WHEEL_SPEED2 0x285
|
||||
|
||||
// 670
|
||||
#define NISSAN_UNKNOWN_4 0x29E
|
||||
|
||||
#define NISSAN_ABS 0x2A0
|
||||
|
||||
// 833 doors
|
||||
#define NISSAN_BCM 0x341
|
||||
|
||||
// https://www.drive2.com/l/530057789272229668/
|
||||
// 852
|
||||
#define NISSAN_VEHICLE_SPEED 0x354
|
||||
|
||||
#define NISSAN_ENGINE_5_CLT_551_1361 0x551
|
||||
// 1408
|
||||
#define NISSAN_RPM_AGAIN 0x580
|
||||
#define NISSAN_ODOMETER 0x5C5
|
||||
// 1549
|
||||
#define NISSAN_BCM_2 0x60D
|
||||
|
||||
|
||||
void canDashboardNissanVQ(CanCycle cycle) {
|
||||
static int rollingId = 0;
|
||||
|
||||
if (cycle.isInterval(CI::_50ms)) {
|
||||
{
|
||||
CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_1_RPM_1F9_505, 8);
|
||||
msg.setShortValueMsb(Sensor::getOrZero(SensorType::Rpm) * 8, /*offset*/ 2);
|
||||
}
|
||||
|
||||
{
|
||||
CanTxMessage msg(CanCategory::OBD, NISSAN_ENGINE_5_CLT_551_1361, 8);
|
||||
|
||||
int clt = Sensor::getOrZero(SensorType::Clt);
|
||||
msg[0] = clt + 45;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
CanTxMessage msg(CanCategory::NBC, NISSAN_ENGINE_3_23D_573, 8);
|
||||
|
||||
rollingId = (rollingId + 1) % 4;
|
||||
const uint8_t magicByte[4] = {0x03, 0x23, 0x42, 0x63};
|
||||
|
||||
msg[0] = magicByte[rollingId];
|
||||
msg[1] = (int)(Sensor::getOrZero(SensorType::AcceleratorPedal) * 255 / 100);
|
||||
|
||||
// thank you "102 CAN Communication decoded"
|
||||
#define CAN_23D_RPM_MULT 3.15
|
||||
int rpm315 = (int)(Sensor::getOrZero(SensorType::Rpm) / CAN_23D_RPM_MULT);
|
||||
msg.setShortValue(rpm315, /*offset*/ 3);
|
||||
|
||||
msg[7] = 0x70; // todo: CLT decoding?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "can.h"
|
||||
|
||||
void canDashboardNissanVQ(CanCycle cycle);
|
|
@ -53,6 +53,7 @@ CONTROLLERS_SRC_CPP = \
|
|||
$(CONTROLLERS_DIR)/can/can_tx.cpp \
|
||||
$(CONTROLLERS_DIR)/can/can_dash.cpp \
|
||||
$(CONTROLLERS_DIR)/can/can_dash_ms.cpp \
|
||||
$(CONTROLLERS_DIR)/can/can_dash_nissan.cpp \
|
||||
$(CONTROLLERS_DIR)/can/can_vss.cpp \
|
||||
$(CONTROLLERS_DIR)/engine_controller.cpp \
|
||||
$(CONTROLLERS_DIR)/engine_controller_misc.cpp \
|
||||
|
|
Loading…
Reference in New Issue