Skip to content

Commit

Permalink
Merge pull request #244 from Dimitrie78/master
Browse files Browse the repository at this point in the history
Smart metrics update und missing canwrite query
  • Loading branch information
dexterbg committed Jul 24, 2019
2 parents 1dc82dd + 01ab258 commit 52d5ba3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion vehicle/OVMS.V3/changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Open Vehicle Monitor System v3 - Change log

????-??-?? ??? ??????? OTA release
- New vehicle: Smart ED/EQ 4.Generation (453) (adaption by Thomas Heuer <egon@heuer-humfeld.de>)

2019-05-12 MWJ 3.2.002 OTA release
- Vehicle framework: added idling alert (ported from V2)
Expand All @@ -9,7 +10,7 @@ Open Vehicle Monitor System v3 - Change log
- Vehicle framework: Regenerative braking signal generation
- Vehicle framework: DBC and RETOOLS integrations
- Vehicles: Extensions to Kia Niro, Kia Soul, Mitsubishi, Nissan Leaf,
Renault Twizy, SmartID, Tesla Model S, and Think City
Renault Twizy, SmartED, Tesla Model S, and Think City

2019-01-19 MWJ 3.2.001 OTA release
- Twizy: support auxiliary charger fan and auxiliary charger
Expand Down
25 changes: 16 additions & 9 deletions vehicle/OVMS.V3/components/vehicle_smarted/src/vehicle_smarted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void OvmsVehicleSmartED::IncomingFrameCan1(CAN_frame_t* p_frame) {
float HVA = StandardMetrics.ms_v_bat_current->AsFloat();
HV = ((float) d[6] * 256 + (float) d[7]);
HV = HV / 10.0;
float HVP = (HV * HVA) / 1000;
float HVP = (HV * HVA) / 1000.0;
StandardMetrics.ms_v_bat_voltage->SetValue(HV, Volts);
StandardMetrics.ms_v_bat_power->SetValue(HVP);
break;
Expand Down Expand Up @@ -486,7 +486,7 @@ void OvmsVehicleSmartED::IncomingFrameCan1(CAN_frame_t* p_frame) {
case 0x200: // hand brake and speed
{
StandardMetrics.ms_v_env_handbrake->SetValue(d[0]);
float velocity = (d[2] * 256 + d[3]) / 18;
float velocity = (d[2] * 256 + d[3]) / 18.0;
StandardMetrics.ms_v_pos_speed->SetValue(velocity, Kph);
CalculateAcceleration();
break;
Expand All @@ -499,9 +499,9 @@ void OvmsVehicleSmartED::IncomingFrameCan1(CAN_frame_t* p_frame) {
{
float soc = StandardMetrics.ms_v_bat_soc->AsFloat();
if(soc > 0) {
float smart_range_ideal = (m_range_ideal * soc) / 100;
float smart_range_ideal = (m_range_ideal * soc) / 100.0;
StandardMetrics.ms_v_bat_range_ideal->SetValue(smart_range_ideal); // ToDo
StandardMetrics.ms_v_bat_range_full->SetValue((float) (d[7] / soc) * 100, Kilometers); // ToDo
StandardMetrics.ms_v_bat_range_full->SetValue((float) (d[7] / soc) * 100.0, Kilometers); // ToDo
}
StandardMetrics.ms_v_bat_range_est->SetValue(d[7], Kilometers);
StandardMetrics.ms_v_env_throttle->SetValue(d[5]);
Expand Down Expand Up @@ -553,8 +553,8 @@ void OvmsVehicleSmartED::IncomingFrameCan1(CAN_frame_t* p_frame) {
}
case 0x3CE: //Consumption from start and from reset
{
float energy_start = (d[0] * 256 + d[1]) / 100;
float energy_reset = (d[2] * 256 + d[3]) / 100;
float energy_start = (d[0] * 256 + d[1]) / 100.0;
float energy_reset = (d[2] * 256 + d[3]) / 100.0;

mt_bat_energy_used_start->SetValue(energy_start);
mt_bat_energy_used_reset->SetValue(energy_reset);
Expand Down Expand Up @@ -699,7 +699,9 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartED::CommandSetChargeCurrent(uint1
So calculate an offset 0xA4 = d164: e.g. 12A = 0xA4 - 0x7C = 0x28 = d40 -> subtract from the maximum (0xA4 = 32A)
then divide by two to get the value for 20A (with 0.5A resolution).
*/

if(!m_enable_write)
return Fail;

CAN_frame_t frame;
memset(&frame, 0, sizeof(frame));

Expand Down Expand Up @@ -728,7 +730,9 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartED::CommandWakeup() {
Both patterns should comply with the Bosch CAN bus spec. for waking up a sleeping bus with recessive bits.
0x423 01 00 00 00 will wake up the CAN bus but not the right on.
*/

if(!m_enable_write)
return Fail;

ESP_LOGI(TAG, "Send Wakeup Command");

CAN_frame_t frame;
Expand Down Expand Up @@ -759,6 +763,9 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartED::CommandSetChargeTimer(bool ti
0x512 00 00 12 1E 00 00 00 00
if one sets e.g. the time at 18:30. If you now mask byte 3 (0x12) with 0x40 (and set the second bit to high there), the A / C function is also activated.
*/
if(!m_enable_write)
return Fail;

if(!StandardMetrics.ms_v_env_awake->AsBool()) {
if (!MyConfig.IsDefined("password","pin")) return Fail;

Expand Down Expand Up @@ -960,7 +967,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartED::CommandStat(int verbosity, Ov
if (*cac != '-')
writer->printf("CAC: %s\n", cac);

const char* soh = StdMetrics.ms_v_bat_soh->AsUnitString("-", Native, 0).c_str();
const char* soh = StdMetrics.ms_v_bat_soh->AsUnitString("-", Native, 1).c_str();
if (*soh != '-')
writer->printf("SOH: %s\n", soh);

Expand Down

0 comments on commit 52d5ba3

Please sign in to comment.