Fix mt_bus_awake
This commit is contained in:
parent
c5aa9c4d93
commit
982f1d4e0e
1 changed files with 7 additions and 7 deletions
|
@ -96,10 +96,10 @@ OvmsVehicleRenaultZoePh2::~OvmsVehicleRenaultZoePh2() {
|
||||||
void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) {
|
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]);
|
||||||
ESP_LOGD(TAG, "Status CAN Bus: %s", mt_bus_awake ? "true" : "false");
|
ESP_LOGD(TAG, "Status CAN Bus: %s", mt_bus_awake->AsBool() ? "true" : "false");
|
||||||
|
|
||||||
// Poll reply gives 0x83 0xc0 that means zoe is sleeping and CAN gateway does not respond to anything
|
// 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) {
|
if (mt_bus_awake->AsBool() && 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);
|
||||||
|
@ -110,7 +110,7 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) {
|
||||||
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
|
//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
|
if (!mt_bus_awake->AsBool() && (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)");
|
ESP_LOGI(TAG,"Zoe woke up (CAN Bus activity detected)");
|
||||||
mt_bus_awake->SetValue(true);
|
mt_bus_awake->SetValue(true);
|
||||||
StandardMetrics.ms_v_env_awake->SetValue(true);
|
StandardMetrics.ms_v_env_awake->SetValue(true);
|
||||||
|
@ -119,23 +119,23 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) {
|
||||||
StandardMetrics.ms_v_env_charging12v->SetValue(true);
|
StandardMetrics.ms_v_env_charging12v->SetValue(true);
|
||||||
POLLSTATE_ON;
|
POLLSTATE_ON;
|
||||||
}
|
}
|
||||||
if (mt_bus_awake && !CarIsCharging && data[2] == 0x92 && data[3] == 0x10) { //received 0x9210 from LBC, only sent freely on starting charge so far
|
if (mt_bus_awake->AsBool() && !CarIsCharging && data[2] == 0x92 && data[3] == 0x10) { //received 0x9210 from LBC, only sent freely on starting charge so far
|
||||||
ESP_LOGI(TAG,"Zoe stared charging");
|
ESP_LOGI(TAG,"Zoe stared charging");
|
||||||
StandardMetrics.ms_v_env_on->SetValue(false);
|
StandardMetrics.ms_v_env_on->SetValue(false);
|
||||||
StandardMetrics.ms_v_charge_state->SetValue("charging");
|
StandardMetrics.ms_v_charge_state->SetValue("charging");
|
||||||
POLLSTATE_CHARGING;
|
POLLSTATE_CHARGING;
|
||||||
}
|
}
|
||||||
if (mt_bus_awake && CarIsCharging && data[2] == 0x92 && data[3] == 0x43) { //received 0x9243 from LBC, only sent freely on stopping charge so far
|
if (mt_bus_awake->AsBool() && CarIsCharging && data[2] == 0x92 && data[3] == 0x43) { //received 0x9243 from LBC, only sent freely on stopping charge so far
|
||||||
ESP_LOGI(TAG,"Zoe stopped charging");
|
ESP_LOGI(TAG,"Zoe stopped charging");
|
||||||
StandardMetrics.ms_v_charge_state->SetValue("stopped");
|
StandardMetrics.ms_v_charge_state->SetValue("stopped");
|
||||||
POLLSTATE_ON;
|
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
|
if (mt_bus_awake->AsBool() && !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");
|
ESP_LOGI(TAG,"Zoe is driving");
|
||||||
StandardMetrics.ms_v_env_on->SetValue(false);
|
StandardMetrics.ms_v_env_on->SetValue(false);
|
||||||
POLLSTATE_RUNNING;
|
POLLSTATE_RUNNING;
|
||||||
CarIsDriving = true;
|
CarIsDriving = true;
|
||||||
} else if (mt_bus_awake && CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() < 5) {
|
} else if (mt_bus_awake->AsBool() && CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() < 5) {
|
||||||
ESP_LOGI(TAG,"Zoe stopped driving");
|
ESP_LOGI(TAG,"Zoe stopped driving");
|
||||||
POLLSTATE_ON;
|
POLLSTATE_ON;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue