From c3421c1b9184da659824f83fa53ba103bb437491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20M=C3=A1tik?= Date: Tue, 22 Dec 2020 17:47:56 +0100 Subject: [PATCH] Added parsing of BMW i3 params - added some BMW i3 params parsing - added rxBuffOffset to liveData --- CarBmwI3.cpp | 60 +++++++++++++++++++++++----------------------------- LiveData.h | 3 +++ 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/CarBmwI3.cpp b/CarBmwI3.cpp index ff5b8bd..5270743 100644 --- a/CarBmwI3.cpp +++ b/CarBmwI3.cpp @@ -31,40 +31,12 @@ void CarBmwI3::activateCommandQueue() { // Loop from (BMW i3) // BMS "ATSH6F1", - "22DDBC" /*, // SOC + + "22DD69", // HV_STORM + "22DDB4", // HV_SPANNUNG + "22DDBC" // SOC - // VMCU - "ATSH7E2", - "2101", - // speed, ... - "2102", - // aux, ... - - //"ATSH7Df", - //"2106", - //"220106", - - // Aircondition - // IONIQ OK - "ATSH7B3", - "220100", - // in/out temp - "220102", - // coolant temp1, 2 - - // BCM / TPMS - // IONIQ OK - "ATSH7A0", - "22c00b", - // tire pressure/temp - - // CLUSTER MODULE - // IONIQ OK - "ATSH7C6", - "22B002", - // odo - */ }; // 28kWh version @@ -82,6 +54,7 @@ void CarBmwI3::activateCommandQueue() { liveData->commandQueueLoopFrom = commandQueueLoopFrom; liveData->commandQueueCount = commandQueue.size(); + liveData->rxBuffOffset = 1; // there is one additional byte in received packets compared to other cars } /** @@ -89,7 +62,29 @@ void CarBmwI3::activateCommandQueue() { */ void CarBmwI3::parseRowMerged() { + Serial.println("--Parsing row merged: "); + Serial.print("--responseRowMerged: "); Serial.println(liveData->responseRowMerged); + Serial.print("--currentAtshRequest: "); Serial.println(liveData->currentAtshRequest); + Serial.print("--commandRequest: "); Serial.println(liveData->commandRequest); + Serial.print("--mergedLength: "); Serial.println(liveData->responseRowMerged.length()); + if (liveData->responseRowMerged.length() <= 6) { + Serial.println("--too short data, skiping processing"); + } + + // BMS + if (liveData->currentAtshRequest.equals("ATSH6F1")) { + if (liveData->commandRequest.equals("22DD69")) { + liveData->params.batPowerAmp = - liveData->hexToDecFromResponse(6, 14, 4, true) / 100.0; + } + + if (liveData->commandRequest.equals("22DDB4")) { // HV_SPANNUNG_BATTERIE + liveData->params.batVoltage = liveData->hexToDecFromResponse(6, 10, 2, false) / 100.0; + } + if (liveData->commandRequest.equals("22DDBC")) { + liveData->params.socPerc = liveData->hexToDecFromResponse(6, 10, 2, false) / 10.0; + } + } } @@ -101,4 +96,3 @@ void CarBmwI3::loadTestData() } - diff --git a/LiveData.h b/LiveData.h index 9fcb256..456b17f 100644 --- a/LiveData.h +++ b/LiveData.h @@ -225,6 +225,9 @@ class LiveData { BLEAdvertisedDevice* foundMyBleDevice; BLEClient* pClient; BLEScan* pBLEScan; + + // Canbus + uint8_t rxBuffOffset = 0; // offset of processing received data, in some cars needs to be set to 1, like in BMW i3 // Params PARAMS_STRUC params; // Realtime sensor values