forked from achamaikin/CCSModuleSW30Web
Expose charging session elapsed time in monitoring packet (v1.0.27).
CONN.ChargingTime ticks at 1 Hz during Charging; serial GET_STATUS reports elapsed min/sec instead of zero stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -68,6 +68,7 @@ typedef struct{
|
|||||||
uint16_t WantedCurrent; //0.1A/bit
|
uint16_t WantedCurrent; //0.1A/bit
|
||||||
CONN_Error_t chargingError; // 0 if okay
|
CONN_Error_t chargingError; // 0 if okay
|
||||||
uint8_t EvConnected;
|
uint8_t EvConnected;
|
||||||
|
uint32_t ChargingTime; // seconds of active charging in current session
|
||||||
uint8_t hv_limit; // Limits PSU voltage to LV range when set
|
uint8_t hv_limit; // Limits PSU voltage to LV range when set
|
||||||
uint32_t hv_tick; // Timer for delayed HV limit switching
|
uint32_t hv_tick; // Timer for delayed HV limit switching
|
||||||
uint8_t hv_limit_count; // Anti-chatter counter for LV limit switching
|
uint8_t hv_limit_count; // Anti-chatter counter for LV limit switching
|
||||||
@@ -82,3 +83,4 @@ extern ChargingConnector_t CONN;
|
|||||||
|
|
||||||
void CONN_Init();
|
void CONN_Init();
|
||||||
void CONN_Loop();
|
void CONN_Loop();
|
||||||
|
void CONN_GetElapsedForMonitoring(uint16_t *min, uint8_t *sec);
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ extern "C" {
|
|||||||
/* USER CODE BEGIN EC */
|
/* USER CODE BEGIN EC */
|
||||||
#define FW_VERSION_MAJOR 1
|
#define FW_VERSION_MAJOR 1
|
||||||
#define FW_VERSION_MINOR 0
|
#define FW_VERSION_MINOR 0
|
||||||
#define FW_VERSION_PATCH 26
|
#define FW_VERSION_PATCH 27
|
||||||
/* USER CODE END EC */
|
/* USER CODE END EC */
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ void CONN_Init(){
|
|||||||
CONN.connControl = CMD_NONE;
|
CONN.connControl = CMD_NONE;
|
||||||
CONN.connState = Unknown;
|
CONN.connState = Unknown;
|
||||||
CONN.RequestedVoltage = PSU_MIN_VOLTAGE;
|
CONN.RequestedVoltage = PSU_MIN_VOLTAGE;
|
||||||
|
CONN.ChargingTime = 0;
|
||||||
CONN.hv_limit = 0u;
|
CONN.hv_limit = 0u;
|
||||||
CONN.hv_tick = 0u;
|
CONN.hv_tick = 0u;
|
||||||
CONN.hv_limit_count = 0u;
|
CONN.hv_limit_count = 0u;
|
||||||
@@ -20,6 +21,7 @@ void CONN_Init(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CONN_Loop(){
|
void CONN_Loop(){
|
||||||
|
static uint32_t charging_time_tick = 0;
|
||||||
static CONN_State_t last_connState = Unknown;
|
static CONN_State_t last_connState = Unknown;
|
||||||
if(last_connState != CONN.connState){
|
if(last_connState != CONN.connState){
|
||||||
last_connState = CONN.connState;
|
last_connState = CONN.connState;
|
||||||
@@ -40,6 +42,25 @@ void CONN_Loop(){
|
|||||||
log_printf(LOG_WARN, "CONN0 Error: %d\n", (int)CONN.chargingError);
|
log_printf(LOG_WARN, "CONN0 Error: %d\n", (int)CONN.chargingError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HAL_GetTick() - charging_time_tick >= 1000U) {
|
||||||
|
charging_time_tick += 1000U;
|
||||||
|
if (CONN.connState == Charging) {
|
||||||
|
CONN.ChargingTime++;
|
||||||
|
}
|
||||||
|
if (CONN.connState == Unplugged) {
|
||||||
|
CONN.ChargingTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CONN_GetElapsedForMonitoring(uint16_t *min, uint8_t *sec) {
|
||||||
|
uint32_t elapsed_sec = CONN.ChargingTime;
|
||||||
|
if (min != NULL) {
|
||||||
|
*min = (uint16_t)(elapsed_sec / 60U);
|
||||||
|
}
|
||||||
|
if (sec != NULL) {
|
||||||
|
*sec = (uint8_t)(elapsed_sec % 60U);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CONN_SetState(CONN_State_t state){
|
void CONN_SetState(CONN_State_t state){
|
||||||
|
|||||||
@@ -139,8 +139,9 @@ static void monitoring_data_callback(void) {
|
|||||||
statusPacket.outputEnabled = CONN.outputEnabled;
|
statusPacket.outputEnabled = CONN.outputEnabled;
|
||||||
statusPacket.chargingError = CONN.chargingError;
|
statusPacket.chargingError = CONN.chargingError;
|
||||||
statusPacket.connState = CONN.connState;
|
statusPacket.connState = CONN.connState;
|
||||||
statusPacket.chargingElapsedTimeMin = 0;
|
CONN_GetElapsedForMonitoring(
|
||||||
statusPacket.chargingElapsedTimeSec = 0;
|
&statusPacket.chargingElapsedTimeMin,
|
||||||
|
&statusPacket.chargingElapsedTimeSec);
|
||||||
statusPacket.estimatedRemainingChargingTime = 0;
|
statusPacket.estimatedRemainingChargingTime = 0;
|
||||||
|
|
||||||
// состояние зарядной станции
|
// состояние зарядной станции
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+4030
-4017
File diff suppressed because it is too large
Load Diff
+25594
-23362
File diff suppressed because it is too large
Load Diff
+1886
-1513
File diff suppressed because it is too large
Load Diff
+4030
-4016
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
|||||||
../Core/Src/charger_control.c:11:6:CONN_Init 1
|
../Core/Src/charger_control.c:11:6:CONN_Init 1
|
||||||
../Core/Src/charger_control.c:19:6:CONN_Loop 7
|
../Core/Src/charger_control.c:23:6:CONN_Loop 10
|
||||||
../Core/Src/charger_control.c:42:6:CONN_SetState 16
|
../Core/Src/charger_control.c:56:6:CONN_GetElapsedForMonitoring 3
|
||||||
|
../Core/Src/charger_control.c:66:6:CONN_SetState 16
|
||||||
|
|||||||
Reference in New Issue
Block a user