Fix crash on Common Image for Geely Geometry C

This commit is contained in:
Daniel Öster 2025-08-31 16:48:07 +03:00
parent f27015d5bd
commit a6f406a928
4 changed files with 22 additions and 13 deletions

View file

@ -15,8 +15,8 @@ static int16_t current_dA = 0;
static uint16_t voltage_dV = 0; static uint16_t voltage_dV = 0;
static uint32_t remaining_capacity_mAh = 0; static uint32_t remaining_capacity_mAh = 0;
static uint16_t cellvoltages_mV[48] = {0}; static uint16_t cellvoltages_mV[48] = {0};
static uint16_t cellvoltage_min_mV = 0; static uint16_t cellvoltage_min_mV = 3700;
static uint16_t cellvoltage_max_mV = 0; static uint16_t cellvoltage_max_mV = 3700;
static uint16_t cell_count = 0; static uint16_t cell_count = 0;
static uint16_t SOC = 0; static uint16_t SOC = 0;
static bool has_fault = false; static bool has_fault = false;

View file

@ -1,7 +1,7 @@
#include "GEELY-GEOMETRY-C-BATTERY.h" #include "GEELY-GEOMETRY-C-BATTERY.h"
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" //For "More battery info" webpage #include "../datalayer/datalayer_extended.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
/* TODO /* TODO

View file

@ -1,7 +1,6 @@
#ifndef GEELY_GEOMETRY_C_BATTERY_H #ifndef GEELY_GEOMETRY_C_BATTERY_H
#define GEELY_GEOMETRY_C_BATTERY_H #define GEELY_GEOMETRY_C_BATTERY_H
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h"
#include "CanBattery.h" #include "CanBattery.h"
#include "GEELY-GEOMETRY-C-HTML.h" #include "GEELY-GEOMETRY-C-HTML.h"
@ -11,6 +10,20 @@
class GeelyGeometryCBattery : public CanBattery { class GeelyGeometryCBattery : public CanBattery {
public: public:
// Use this constructor for the second battery.
GeelyGeometryCBattery(DATALAYER_BATTERY_TYPE* datalayer_ptr, DATALAYER_INFO_GEELY_GEOMETRY_C* extended,
CAN_Interface targetCan)
: CanBattery(targetCan) {
datalayer_battery = datalayer_ptr;
battery_voltage = 0;
}
// Use the default constructor to create the first or single battery.
GeelyGeometryCBattery() {
datalayer_battery = &datalayer.battery;
datalayer_geometryc = &datalayer_extended.geometryC;
}
virtual void setup(void); virtual void setup(void);
virtual void handle_incoming_can_frame(CAN_frame rx_frame); virtual void handle_incoming_can_frame(CAN_frame rx_frame);
virtual void update_values(); virtual void update_values();
@ -20,6 +33,11 @@ class GeelyGeometryCBattery : public CanBattery {
BatteryHtmlRenderer& get_status_renderer() { return renderer; } BatteryHtmlRenderer& get_status_renderer() { return renderer; }
private: private:
GeelyGeometryCHtmlRenderer renderer;
DATALAYER_BATTERY_TYPE* datalayer_battery;
DATALAYER_INFO_GEELY_GEOMETRY_C* datalayer_geometryc;
static const int POLL_SOC = 0x4B35; static const int POLL_SOC = 0x4B35;
static const int POLL_CC2_VOLTAGE = 0x4BCF; static const int POLL_CC2_VOLTAGE = 0x4BCF;
static const int POLL_CELL_MAX_VOLTAGE_NUMBER = 0x4B1E; static const int POLL_CELL_MAX_VOLTAGE_NUMBER = 0x4B1E;
@ -41,8 +59,6 @@ class GeelyGeometryCBattery : public CanBattery {
static const int POLL_MULTI_HARDWARE_VERSION = 0x4B6B; static const int POLL_MULTI_HARDWARE_VERSION = 0x4B6B;
static const int POLL_MULTI_SOFTWARE_VERSION = 0x4B6C; static const int POLL_MULTI_SOFTWARE_VERSION = 0x4B6C;
GeelyGeometryCHtmlRenderer renderer;
static const int MAX_PACK_VOLTAGE_70_DV = 4420; //70kWh static const int MAX_PACK_VOLTAGE_70_DV = 4420; //70kWh
static const int MIN_PACK_VOLTAGE_70_DV = 2860; static const int MIN_PACK_VOLTAGE_70_DV = 2860;
static const int MAX_PACK_VOLTAGE_53_DV = 4160; //53kWh static const int MAX_PACK_VOLTAGE_53_DV = 4160; //53kWh
@ -51,9 +67,6 @@ class GeelyGeometryCBattery : public CanBattery {
static const int MAX_CELL_VOLTAGE_MV = 4250; //Battery is put into emergency stop if one cell goes over this value static const int MAX_CELL_VOLTAGE_MV = 4250; //Battery is put into emergency stop if one cell goes over this value
static const int MIN_CELL_VOLTAGE_MV = 2700; //Battery is put into emergency stop if one cell goes below this value static const int MIN_CELL_VOLTAGE_MV = 2700; //Battery is put into emergency stop if one cell goes below this value
DATALAYER_BATTERY_TYPE* datalayer_battery;
DATALAYER_INFO_GEELY_GEOMETRY_C* datalayer_geometryc;
CAN_frame GEELY_191 = {.FD = false, //PAS_APA_Status , 10ms CAN_frame GEELY_191 = {.FD = false, //PAS_APA_Status , 10ms
.ext_ID = false, .ext_ID = false,
.DLC = 8, .DLC = 8,

View file

@ -1,8 +1,6 @@
#ifndef _GEELY_GEOMETRY_C_HTML_H #ifndef _GEELY_GEOMETRY_C_HTML_H
#define _GEELY_GEOMETRY_C_HTML_H #define _GEELY_GEOMETRY_C_HTML_H
#include <cstring>
#include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"
#include "../devboard/webserver/BatteryHtmlRenderer.h" #include "../devboard/webserver/BatteryHtmlRenderer.h"
@ -10,7 +8,6 @@ class GeelyGeometryCHtmlRenderer : public BatteryHtmlRenderer {
public: public:
String get_status_html() { String get_status_html() {
String content; String content;
char readableSerialNumber[29]; // One extra space for null terminator char readableSerialNumber[29]; // One extra space for null terminator
memcpy(readableSerialNumber, datalayer_extended.geometryC.BatterySerialNumber, memcpy(readableSerialNumber, datalayer_extended.geometryC.BatterySerialNumber,
sizeof(datalayer_extended.geometryC.BatterySerialNumber)); sizeof(datalayer_extended.geometryC.BatterySerialNumber));
@ -52,7 +49,6 @@ class GeelyGeometryCHtmlRenderer : public BatteryHtmlRenderer {
"<h4>Module 5 temperature: " + String(datalayer_extended.geometryC.ModuleTemperatures[4]) + " &deg;C</h4>"; "<h4>Module 5 temperature: " + String(datalayer_extended.geometryC.ModuleTemperatures[4]) + " &deg;C</h4>";
content += content +=
"<h4>Module 6 temperature: " + String(datalayer_extended.geometryC.ModuleTemperatures[5]) + " &deg;C</h4>"; "<h4>Module 6 temperature: " + String(datalayer_extended.geometryC.ModuleTemperatures[5]) + " &deg;C</h4>";
return content; return content;
} }
}; };