Implement car on of driving charging method depending on some free frames
This commit is contained in:
parent
464a2e4b39
commit
7d3889fbcc
|
@ -45,7 +45,7 @@ static const OvmsVehicle::poll_pid_t renault_zoe_polls[] = {
|
||||||
|
|
||||||
//EVC-HCM-VCM
|
//EVC-HCM-VCM
|
||||||
//{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session
|
//{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIISESSION, SESSION_EXTDIAG, { 60, 60, 60, 60 }, 0, ISOTP_EXTFRAME }, // OBD Extended Diagnostic Session
|
||||||
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2006, { 180, 10, 10, 300 }, 0, ISOTP_EXTFRAME }, // Odometer
|
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2006, { 0, 10, 10, 300 }, 0, ISOTP_EXTFRAME }, // Odometer
|
||||||
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2A8C, { 0, 10, 5, 3 }, 0, ISOTP_EXTFRAME }, // 12Battery Current
|
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2A8C, { 0, 10, 5, 3 }, 0, ISOTP_EXTFRAME }, // 12Battery Current
|
||||||
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2005, { 0, 10, 5, 3 }, 0, ISOTP_EXTFRAME }, // 12Battery Voltage
|
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x2005, { 0, 10, 5, 3 }, 0, ISOTP_EXTFRAME }, // 12Battery Voltage
|
||||||
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21D0, { 0, 10, 10, 3 }, 0, ISOTP_EXTFRAME }, // DCDC Temperature
|
{ 0x18dadaf1, 0x18daf1da, VEHICLE_POLL_TYPE_OBDIIEXTENDED, 0x21D0, { 0, 10, 10, 3 }, 0, ISOTP_EXTFRAME }, // DCDC Temperature
|
||||||
|
|
|
@ -99,13 +99,47 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) {
|
||||||
uint8_t *data = p_frame->data.u8;
|
uint8_t *data = p_frame->data.u8;
|
||||||
ESP_LOGI(TAG, "PID:%x DATA: %02x %02x %02x %02x %02x %02x %02x %02x", p_frame->MsgID, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
ESP_LOGI(TAG, "PID:%x DATA: %02x %02x %02x %02x %02x %02x %02x %02x", p_frame->MsgID, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
||||||
|
|
||||||
if (data[0] == 0x83 && data[1] == 0xc0 && mt_bus_awake) {
|
// Poll reply gives 0x83 0xc0 that means zoe is sleeping and CAN gateway does not respond to anything
|
||||||
|
if (mt_bus_awake && data[0] == 0x83 && data[1] == 0xc0) {
|
||||||
ESP_LOGI(TAG,"Zoe has gone to sleep (CAN Gateway NAK response)");
|
ESP_LOGI(TAG,"Zoe has gone to sleep (CAN Gateway NAK response)");
|
||||||
mt_bus_awake->SetValue(false);
|
mt_bus_awake->SetValue(false);
|
||||||
StandardMetrics.ms_v_env_awake->SetValue(false);
|
StandardMetrics.ms_v_env_awake->SetValue(false);
|
||||||
car_on(false);
|
StandardMetrics.ms_v_env_on->SetValue(false);
|
||||||
|
StandardMetrics.ms_v_env_awake->SetValue(false);
|
||||||
|
StandardMetrics.ms_v_env_charging12v->SetValue(false);
|
||||||
|
StandardMetrics.ms_v_pos_speed->SetValue( 0 );
|
||||||
POLLSTATE_OFF;
|
POLLSTATE_OFF;
|
||||||
|
}
|
||||||
|
//There are some free frames on wakeup and start and stop charging.... I try to use them to see if Car is awake and charging, see /Reference/ZOE_Ph2_xxx text files
|
||||||
|
if (!mt_bus_awake && (data[0] == 0x05 || data[0] == 0x06 || data[0] == 0x07)) { //listen for SingleFrames (0x0) with length of 5-7
|
||||||
|
ESP_LOGI(TAG,"Zoe woke up (CAN Bus activity detected)");
|
||||||
|
mt_bus_awake->SetValue(true);
|
||||||
|
StandardMetrics.ms_v_env_awake->SetValue(true);
|
||||||
|
StandardMetrics.ms_v_env_on->SetValue(true);
|
||||||
|
StandardMetrics.ms_v_env_awake->SetValue(true);
|
||||||
|
StandardMetrics.ms_v_env_charging12v->SetValue(true);
|
||||||
|
POLLSTATE_ON;
|
||||||
}
|
}
|
||||||
|
if (mt_bus_awake && data[data[2] == 0x92 && data[3] == 0x10]) { //received 0x9210 from LBC, only sent freely on starting charge so far
|
||||||
|
ESP_LOGI(TAG,"Zoe stared charging");
|
||||||
|
StandardMetrics.ms_v_env_on->SetValue(false);
|
||||||
|
StandardMetrics.ms_v_charge_state->SetValue("charging");
|
||||||
|
POLLSTATE_CHARGING;
|
||||||
|
}
|
||||||
|
if (mt_bus_awake && data[data[2] == 0x92 && data[3] == 0x43]) { //received 0x9243 from LBC, only sent freely on stopping charge so far
|
||||||
|
ESP_LOGI(TAG,"Zoe stopped charging");
|
||||||
|
StandardMetrics.ms_v_charge_state->SetValue("stopped");
|
||||||
|
POLLSTATE_ON;
|
||||||
|
}
|
||||||
|
if (mt_bus_awake && !CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() > 5) { //If GPS speed bigger than 5km/h then assume Vehicle driving, later I used OBD speed for that
|
||||||
|
ESP_LOGI(TAG,"Zoe is driving");
|
||||||
|
StandardMetrics.ms_v_env_on->SetValue(false);
|
||||||
|
POLLSTATE_RUNNING;
|
||||||
|
CarIsDriving = true;
|
||||||
|
} else if (mt_bus_awake && CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() < 5) {
|
||||||
|
ESP_LOGI(TAG,"Zoe stopped driving");
|
||||||
|
POLLSTATE_ON;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,36 +188,6 @@ void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes care of setting all the state appropriate when the car is on
|
|
||||||
* or off. Centralized so we can more easily make on and off mirror
|
|
||||||
* images.
|
|
||||||
*/
|
|
||||||
void OvmsVehicleRenaultZoePh2::car_on(bool isOn) {
|
|
||||||
if (isOn && !StandardMetrics.ms_v_env_on->AsBool()) {
|
|
||||||
// Car is beeing turned ON
|
|
||||||
ESP_LOGI(TAG,"CAR IS ON");
|
|
||||||
StandardMetrics.ms_v_env_on->SetValue(isOn);
|
|
||||||
StandardMetrics.ms_v_env_awake->SetValue(isOn);
|
|
||||||
// Handle 12Vcharging
|
|
||||||
StandardMetrics.ms_v_env_charging12v->SetValue(true);
|
|
||||||
POLLSTATE_RUNNING;
|
|
||||||
}
|
|
||||||
else if(!isOn && StandardMetrics.ms_v_env_on->AsBool()) {
|
|
||||||
// Car is being turned OFF
|
|
||||||
ESP_LOGI(TAG,"CAR IS OFF");
|
|
||||||
if (!StandardMetrics.ms_v_charge_inprogress->AsBool()) {
|
|
||||||
StandardMetrics.ms_v_env_charging12v->SetValue(false);
|
|
||||||
POLLSTATE_ON;
|
|
||||||
} else {
|
|
||||||
POLLSTATE_CHARGING;
|
|
||||||
}
|
|
||||||
StandardMetrics.ms_v_env_on->SetValue( isOn );
|
|
||||||
StandardMetrics.ms_v_env_awake->SetValue( isOn );
|
|
||||||
StandardMetrics.ms_v_pos_speed->SetValue( 0 );;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class OvmsVehicleRenaultZoePh2Init {
|
class OvmsVehicleRenaultZoePh2Init {
|
||||||
public: OvmsVehicleRenaultZoePh2Init();
|
public: OvmsVehicleRenaultZoePh2Init();
|
||||||
} MyOvmsVehicleRenaultZoePh2Init __attribute__ ((init_priority (9000)));
|
} MyOvmsVehicleRenaultZoePh2Init __attribute__ ((init_priority (9000)));
|
||||||
|
|
|
@ -69,6 +69,7 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle {
|
||||||
void IncomingPollReply(canbus* bus, uint16_t type, uint16_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);
|
||||||
void WebInit();
|
void WebInit();
|
||||||
void WebDeInit();
|
void WebDeInit();
|
||||||
|
bool CarIsDriving = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
void IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
||||||
|
@ -77,8 +78,6 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle {
|
||||||
void IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
void IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
||||||
void IncomingHVAC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
void IncomingHVAC(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
||||||
void IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
void IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len);
|
||||||
|
|
||||||
void car_on(bool isOn);
|
|
||||||
|
|
||||||
// Renault ZOE specific metrics
|
// Renault ZOE specific metrics
|
||||||
OvmsMetricFloat *mt_pos_odometer_start; // ODOmeter at Start
|
OvmsMetricFloat *mt_pos_odometer_start; // ODOmeter at Start
|
||||||
|
|
Loading…
Reference in a new issue