Compare commits

...

4 commits

3 changed files with 51 additions and 25 deletions

View file

@ -523,7 +523,7 @@ class OvmsVehicle : public InternalRamAllocated
uint16_t type; // UDS poll type / OBD2 "mode", see VEHICLE_POLL_TYPE_… uint16_t type; // UDS poll type / OBD2 "mode", see VEHICLE_POLL_TYPE_…
union union
{ {
uint32_t pid; // PID (shortcut for requests w/o payload) uint16_t pid; // PID (shortcut for requests w/o payload)
struct struct
{ {
uint16_t pid; // PID for requests with additional payload uint16_t pid; // PID for requests with additional payload

View file

@ -55,23 +55,24 @@ static const char *TAG = "v-zoe-ph2";
// Pollstate 2 - POLLSTATE_RUNNING - car is driving // Pollstate 2 - POLLSTATE_RUNNING - car is driving
// Pollstate 3 - POLLSTATE_CHARGING - car is charging // Pollstate 3 - POLLSTATE_CHARGING - car is charging
static const OvmsVehicle::poll_pid_t renault_zoe_polls[] = { static const OvmsVehicle::poll_pid_t renault_zoe_polls[] = {
//***TX-ID, ***RX-ID, ***SID, ***PID, { Polltime (seconds) for Pollstate 0, 1, 2, 3}, ***CAN BUS Interface, ***FRAMETYPE
//LBC //LBC
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 0, 10, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9001, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // SOC { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9001, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // SOC
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x91BC, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // SOH { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x91BC, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // SOH
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9131, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Temp Bat Module 1 { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9131, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Temp Bat Module 1
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9021, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Cell Bat Module 1-62 { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9021, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Cell Bat Module 1-62
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9062, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Cell Bat Module 63-96 { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x9062, { 0, 60, 600, 60 }, 0, ISOTP_EXTFRAME }, // Cell Bat Module 63-96
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x20B6, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Battery Voltage { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x20B6, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Battery Voltage
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x900D, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Battery Current { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x900D, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Battery Current
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x291C8, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Battery Available Energy kWh { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x91C8, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Battery Available Energy kWh
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9243, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Energy charged kWh { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9243, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Energy charged kWh
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9244, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Energy discharged kWh { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9244, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Energy discharged kWh
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9246, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Energy regenerated kWh { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x9246, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Energy regenerated kWh
{ 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21D9, { 0, 30, 1, 2 }, 0, ISOTP_EXTFRAME }, // Charging State (1: Slow, 2: Fast, 3: Init Charging) { 0x18dadbf1, 0x18daf1db, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21D9, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Charging State (1: Slow, 2: Fast, 3: Init Charging)
//EVC-HCM-VCM //EVC-HCM-VCM
{ 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 0, 10, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session { 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session
{ 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2006, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Odometer { 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2006, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Odometer
{ 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21DF, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // 12Battery Current { 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21DF, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // 12Battery Current
{ 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2005, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // 12Battery Voltage { 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2005, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // 12Battery Voltage
@ -81,9 +82,13 @@ static const OvmsVehicle::poll_pid_t renault_zoe_polls[] = {
{ 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x303D, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // HV Battery Insulation Resistance { 0x18daf1da, 0x18dadaf1, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x303D, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // HV Battery Insulation Resistance
//Motor Inverter //Motor Inverter
{ 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 0, 10, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session { 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session
{ 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x700F, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Stator Temperature 1 { 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x700F, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Stator Temperature 1
{ 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x7010, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Stator Temperature 2 { 0x18dadff1, 0x18daf1df, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x7010, { 0, 10, 10, 10 }, 0, ISOTP_EXTFRAME }, // Stator Temperature 2
//Navigation-UCC-ITM
{ 0x747, 0x767, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_STD }, // OBD Extended Diagnostic Session
{ 0x747, 0x767, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2109, { 0, 10, 10, 10 }, 0, ISOTP_STD }, // Volume Setting (for debug only)
POLL_LIST_END POLL_LIST_END
}; };
@ -116,7 +121,7 @@ OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() {
// Poll Specific PIDs // Poll Specific PIDs
POLLSTATE_ON; POLLSTATE_ON;
PollSetPidList(m_can1, renault_zoe_polls); PollSetPidList(m_can1, renault_zoe_polls);
PollSetThrottling(5); PollSetThrottling(1);
PollSetResponseSeparationTime(20); PollSetResponseSeparationTime(20);
// init metrics: // init metrics:
@ -124,6 +129,7 @@ OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() {
mt_bus_awake = MyMetrics.InitBool("zph2.v.bus.awake", SM_STALE_MIN, true); mt_bus_awake = MyMetrics.InitBool("zph2.v.bus.awake", SM_STALE_MIN, true);
mt_available_energy = MyMetrics.InitFloat("zph2.v.avail.energy", SM_STALE_MID, 0, kWh); mt_available_energy = MyMetrics.InitFloat("zph2.v.avail.energy", SM_STALE_MID, 0, kWh);
mt_main_power_consumed = MyMetrics.InitFloat("zph2.c.main.power.consumed", SM_STALE_MID, 0, kWh); mt_main_power_consumed = MyMetrics.InitFloat("zph2.c.main.power.consumed", SM_STALE_MID, 0, kWh);
mt_navi_volume = MyMetrics.InitFloat("zph2.c.radio.volume", SM_STALE_MID, 0, Percentage);
// init commands: // init commands:
cmd_zoe = MyCommandApp.RegisterCommand("zoe-ph2", "Renault Zoe Ph2"); cmd_zoe = MyCommandApp.RegisterCommand("zoe-ph2", "Renault Zoe Ph2");
@ -172,10 +178,12 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) {
/** /**
* Handles incoming poll results * Handles incoming poll results
*/ */
void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uint32_t pid, uint8_t* data, uint8_t length, uint16_t remain) { void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uint16_t pid, uint8_t* data, uint8_t length, uint16_t remain) {
string& rxbuf = zoe_obd_rxbuf; string& rxbuf = zoe_obd_rxbuf;
static uint32_t last_pid = -1; static uint32_t last_pid = -1;
ESP_LOGV(TAG, "pid: %04x length: %d m_poll_ml_remain: %d m_poll_ml_frame: %d", pid, length, m_poll_ml_remain, m_poll_ml_frame);
if (pid != last_pid) { if (pid != last_pid) {
ESP_LOGD(TAG, "pid: %04x length: %d m_poll_ml_remain: %d m_poll_ml_frame: %d", pid, length, m_poll_ml_remain, m_poll_ml_frame); ESP_LOGD(TAG, "pid: %04x length: %d m_poll_ml_remain: %d m_poll_ml_frame: %d", pid, length, m_poll_ml_remain, m_poll_ml_frame);
last_pid = pid; last_pid = pid;
@ -216,6 +224,10 @@ void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uin
// ****** PEB ***** // ****** PEB *****
case 0x77e: case 0x77e:
IncomingPEB(type, pid, rxbuf.data(), rxbuf.size()); IncomingPEB(type, pid, rxbuf.data(), rxbuf.size());
break;
// ****** Navigation-UCC-ITM *****
case 0x747:
IncomingUCC(type, pid, rxbuf.data(), rxbuf.size());
break; break;
} }
} }
@ -223,7 +235,7 @@ void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uin
/** /**
* Handle incoming polls from the motor inverter * Handle incoming polls from the motor inverter
*/ */
void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x700F: { // Motor temperature case 0x700F: { // Motor temperature
StandardMetrics.ms_v_mot_temp->SetValue(CAN_BYTE(0), Celcius); StandardMetrics.ms_v_mot_temp->SetValue(CAN_BYTE(0), Celcius);
@ -234,7 +246,7 @@ void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint32_t pid, const ch
/** /**
* Handle incoming polls from the EVC Computer * Handle incoming polls from the EVC Computer
*/ */
void OvmsVehicleRenaultZoePh2::IncomingEVC(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingEVC(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x2006: { // Odometer (Total Vehicle Distance) case 0x2006: { // Odometer (Total Vehicle Distance)
StandardMetrics.ms_v_pos_odometer->SetValue((float) CAN_UINT24(0), Kilometers); StandardMetrics.ms_v_pos_odometer->SetValue((float) CAN_UINT24(0), Kilometers);
@ -272,7 +284,7 @@ void OvmsVehicleRenaultZoePh2::IncomingEVC(uint16_t type, uint32_t pid, const ch
/** /**
* Handle incoming polls from the BCB Computer * Handle incoming polls from the BCB Computer
*/ */
void OvmsVehicleRenaultZoePh2::IncomingBCB(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingBCB(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x504A: { case 0x504A: {
// 793,24,39,1,20000,0,W,504A,62504A,ff\n" // Mains active power consumed // 793,24,39,1,20000,0,W,504A,62504A,ff\n" // Mains active power consumed
@ -322,7 +334,7 @@ void OvmsVehicleRenaultZoePh2::IncomingBCB(uint16_t type, uint32_t pid, const ch
/** /**
* Handle incoming polls from the LBC Computer * Handle incoming polls from the LBC Computer
*/ */
void OvmsVehicleRenaultZoePh2::IncomingLBC(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x20B6: { case 0x20B6: {
StandardMetrics.ms_v_bat_voltage->SetValue((float) (CAN_UINT(0))); StandardMetrics.ms_v_bat_voltage->SetValue((float) (CAN_UINT(0)));
@ -391,7 +403,7 @@ void OvmsVehicleRenaultZoePh2::IncomingLBC(uint16_t type, uint32_t pid, const ch
/** /**
* Handle incoming polls from the UBP Computer * Handle incoming polls from the UBP Computer
*/ */
void OvmsVehicleRenaultZoePh2::IncomingUCH(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingUCH(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x4B7C: { case 0x4B7C: {
// Todo // Todo
@ -409,7 +421,7 @@ void OvmsVehicleRenaultZoePh2::IncomingUCH(uint16_t type, uint32_t pid, const ch
/** /**
* Handle incoming polls from the PEB Computer * Handle incoming polls from the PEB Computer
*/ */
void OvmsVehicleRenaultZoePh2::IncomingPEB(uint16_t type, uint32_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingPEB(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x3018: { case 0x3018: {
// 77e,24,39,0.015625,0,2,ºC,3018,623018,ff\n" // DCDC converter temperature // 77e,24,39,0.015625,0,2,ºC,3018,623018,ff\n" // DCDC converter temperature
@ -426,6 +438,18 @@ void OvmsVehicleRenaultZoePh2::IncomingPEB(uint16_t type, uint32_t pid, const ch
} }
} }
/**
* Handle incoming polls from the navigation cluster
*/
void OvmsVehicleRenaultZoePh2::IncomingUCC(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) {
case 0x2109: { // Motor temperature
mt_navi_volume->SetValue((float(CAN_UINT(0))));
break;
}
}
}
/** /**
* Takes care of setting all the state appropriate when the car is on * Takes care of setting all the state appropriate when the car is on

View file

@ -74,15 +74,16 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle {
static OvmsVehicleRenaultZoePh2* GetInstance(OvmsWriter* writer=NULL); static OvmsVehicleRenaultZoePh2* GetInstance(OvmsWriter* writer=NULL);
void IncomingFrameCan1(CAN_frame_t* p_frame); void IncomingFrameCan1(CAN_frame_t* p_frame);
void IncomingPollReply(canbus* bus, uint16_t type, uint32_t pid, uint8_t* data, uint8_t length, uint16_t remain); void IncomingPollReply(canbus* bus, uint16_t type, uint16_t pid, uint8_t* data, uint8_t length, uint16_t remain);
protected: protected:
void IncomingINV(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingEVC(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingEVC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingBCB(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingBCB(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingLBC(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingUCH(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingUCH(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingPEB(uint16_t type, uint32_t pid, const char* data, uint16_t len); void IncomingPEB(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void IncomingUCC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
void car_on(bool isOn); void car_on(bool isOn);
virtual void Ticker1(uint32_t ticker); virtual void Ticker1(uint32_t ticker);
virtual void Ticker10(uint32_t ticker); virtual void Ticker10(uint32_t ticker);
@ -98,6 +99,7 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle {
OvmsMetricBool *mt_bus_awake; // can-bus awake status OvmsMetricBool *mt_bus_awake; // can-bus awake status
OvmsMetricFloat *mt_available_energy; // Available Energy OvmsMetricFloat *mt_available_energy; // Available Energy
OvmsMetricFloat *mt_main_power_consumed; // Mains active power consumed OvmsMetricFloat *mt_main_power_consumed; // Mains active power consumed
OvmsMetricFloat *mt_navi_volume; //Radio volume for debug only
public: public:
void WebInit(); void WebInit();