Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fixes, bug fixes and warning eliminations exposed when using CMake and ESP-IDF v5 #1096

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/console/argtable3/argtable3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3464,7 +3464,7 @@ static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *s
/* public api */
TRex *trex_compile(const TRexChar *pattern,const TRexChar **error,int flags)
{
TRex *exp = (TRex *)malloc(sizeof(TRex));
TRex * volatile exp = (TRex *)malloc(sizeof(TRex));
exp->_eol = exp->_bol = NULL;
exp->_p = pattern;
exp->_nallocated = (int)scstrlen(pattern) * sizeof(TRexChar);
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/mongoose/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ idf_component_register(SRCS ${srcs}

if (CONFIG_OVMS_SC_GPL_MONGOOSE)

component_compile_definitions("MG_ARCH=MG_ARCH_FREERTOS" "MG_ENABLE_LINES=1" "MG_ENABLE_LWIP=1" "MG_ENABLE_IPV6=1" "MG_ENABLE_ASSERT=1")
component_compile_definitions("MG_ARCH=MG_ARCH_FREERTOS" "MG_ENABLE_LINES=1" "MG_ENABLE_LWIP=1" "MG_ENABLE_ASSERT=1")

if (CONFIG_MG_SSL_IF_MBEDTLS)
component_compile_definitions("MG_ENABLE_MBEDTLS=1")
Expand Down
4 changes: 4 additions & 0 deletions vehicle/OVMS.V3/components/mongoose/include/mg_locals.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@

#endif

#ifdef CONFIG_LWIP_IPV6
#define MG_ENABLE_IPV6 1
#endif

// Override memory allocation macros in mongoose.c
#define CS_COMMON_MG_MEM_H_
#define MG_MALLOC ExternalRamMalloc
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/ovms_cellular/src/gsmnmea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static bool valid_nmea_cksum(const std::string line)
return 0;
unsigned char chk = 0;
while (cp < ep)
chk ^= (const unsigned char)*cp++;
chk ^= (unsigned char)*cp++;
unsigned char chk2 = (unsigned char)strtoul(ep + 1, NULL, 16);
return (chk == chk2);
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions vehicle/OVMS.V3/components/ovms_webserver/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $(COMPONENT_PATH)/assets/script.js : \

$(COMPONENT_PATH)/assets/script.js.gz : \
$(COMPONENT_PATH)/assets/script.js
cat $^ | gzip -c > $@
cat $^ | gzip -9 -c > $@

$(COMPONENT_PATH)/assets/charts.js : \
$(COMPONENT_PATH)/assets/highcharts.js \
Expand All @@ -55,15 +55,15 @@ $(COMPONENT_PATH)/assets/charts.js : \

$(COMPONENT_PATH)/assets/charts.js.gz : \
$(COMPONENT_PATH)/assets/charts.js
cat $^ | gzip -c > $@
cat $^ | gzip -9 -c > $@

$(COMPONENT_PATH)/assets/tables.js : \
$(COMPONENT_PATH)/assets/datatables.min.js
cat $^ > $@ && dos2unix $@

$(COMPONENT_PATH)/assets/tables.js.gz : \
$(COMPONENT_PATH)/assets/tables.js
cat $^ | gzip -c > $@
cat $^ | gzip -9 -c > $@

$(COMPONENT_PATH)/assets/style.css : \
$(COMPONENT_PATH)/assets/intro.css \
Expand All @@ -77,11 +77,11 @@ $(COMPONENT_PATH)/assets/style.css : \

$(COMPONENT_PATH)/assets/style.css.gz : \
$(COMPONENT_PATH)/assets/style.css
cat $^ | gzip -c > $@
cat $^ | gzip -9 -c > $@

$(COMPONENT_PATH)/assets/zones.json.gz : \
$(COMPONENT_PATH)/assets/zones.json
cat $^ | gzip -c > $@
cat $^ | gzip -9 -c > $@

src/web_framework.o: \
$(COMPONENT_PATH)/assets/script.js.gz \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const char *TAG = "webserver";
#include <string.h>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include "ovms_webserver.h"
#include "ovms_config.h"
#include "ovms_metrics.h"
Expand Down
7 changes: 5 additions & 2 deletions vehicle/OVMS.V3/components/vehicle/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,11 @@ void OvmsVehicle::RegisterCanBus(int bus, CAN_mode_t mode, CAN_speed_t speed, db
{
std::string busname = string_format("can%d", bus);
can = (canbus*)MyPcpApp.FindDeviceByName(busname.c_str());
can->SetPowerMode(On);
can->Start(mode,speed,dbcfile);
if (can)
{
can->SetPowerMode(On);
can->Start(mode,speed,dbcfile);
}
}
#endif
switch (bus)
Expand Down
1 change: 1 addition & 0 deletions vehicle/OVMS.V3/components/vehicle/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#ifndef __VEHICLE_H__
#define __VEHICLE_H__

#include <cmath>
#include <map>
#include <vector>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ void OvmsHyundaiIoniqEv::RangeCalcReset()
void xiq_range_reset(int verbosity, OvmsWriter *writer, OvmsCommand *cmd, int argc, const char *const *argv)
{
OvmsHyundaiIoniqEv *mycar = (OvmsHyundaiIoniqEv *)(MyVehicleFactory.ActiveVehicle());
if (mycar) {
if (mycar == NULL) {
writer->puts("Error: No vehicle module selected");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions vehicle/OVMS.V3/components/vehicle_maple60s/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ set(srcs)
set(include_dirs)

if (CONFIG_OVMS_VEHICLE_MAPLE60S)
list(APPEND srcs "src/vehicle_maple60s.cpp")
list(APPEND srcs "src/vehicle_maple_60s.cpp")
list(APPEND include_dirs "src")
endif ()

# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
PRIV_REQUIRES "main"
WHOLE_ARCHIVE)
WHOLE_ARCHIVE)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(srcs)
set(include_dirs)

if (CONFIG_OVMS_VEHICLE_MAXE6)
list(APPEND srcs "vehicle_me6.cpp")
list(APPEND srcs "src/vehicle_me6.cpp")
list(APPEND include_dirs "src")
endif ()

Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/vehicle_mgev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(srcs)
set(include_dirs)

if (CONFIG_OVMS_VEHICLE_MG_EV)
list(APPEND srcs "src/mg_auth.cpp" "src/mg_bcm.cpp" "src/mg_can_handler.cpp" "src/mg_configuration.cpp" "src/mg_gwm.cpp" "src/mg_poll_atc.cpp" "src/mg_poll_bcm.cpp" "src/mg_poll_bms.cpp" "src/mg_poll_dcdc.cpp" "src/mg_poll_evcc.cpp" "src/mg_poll_peps.cpp" "src/mg_poll_tpms.cpp" "src/mg_poll_vcu.cpp" "src/mg_software_versions.cpp" "src/mg_web.cpp" "src/vehicle_mgev.cpp" "src/vehicle_mgev_a.cpp" "src/vehicle_mgev_b.cpp" "src/vehicle_mg5.cpp" "src/vehicle_mgzsev2.cpp" )
list(APPEND srcs "src/mg_auth.cpp" "src/mg_bcm.cpp" "src/mg_can_handler.cpp" "src/mg_configuration.cpp" "src/mg_gwm.cpp" "src/mg_poll_atc.cpp" "src/mg_poll_bcm.cpp" "src/mg_poll_bms.cpp" "src/mg_poll_dcdc.cpp" "src/mg_poll_evcc.cpp" "src/mg_poll_gwm.cpp" "src/mg_poll_peps.cpp" "src/mg_poll_tpms.cpp" "src/mg_poll_vcu.cpp" "src/mg_software_versions.cpp" "src/mg_web.cpp" "src/vehicle_mgev.cpp" "src/vehicle_mgev_a.cpp" "src/vehicle_mgev_b.cpp" "src/vehicle_mg5.cpp" "src/vehicle_mgzsev2.cpp")
list(APPEND include_dirs "src")
endif ()

Expand Down
14 changes: 14 additions & 0 deletions vehicle/OVMS.V3/components/vehicle_renaulttwizy/src/rt_battmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ void OvmsVehicleRenaultTwizy::BatteryUpdate()
}


/**
* BatterySetSensorAndUpdate: Set sensor state and update if all done
*/
void OvmsVehicleRenaultTwizy::BatterySetSensorAndUpdate(uint8_t flag)
{
uint8_t batt_sensors_state = twizy_batt_sensors_state;
batt_sensors_state |= flag;
twizy_batt_sensors_state = batt_sensors_state;
if ((batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}
}


/**
* BatteryReset: reset deviations, alerts & watches
*/
Expand Down
33 changes: 6 additions & 27 deletions vehicle/OVMS.V3/components/vehicle_renaulttwizy/src/rt_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void OvmsVehicleRenaultTwizy::CanResponder(const CAN_frame_t* p_frame)
}
}


/**
* Asynchronous CAN RX handler
*/
Expand Down Expand Up @@ -353,12 +352,8 @@ void OvmsVehicleRenaultTwizy::IncomingFrameCan1(CAN_frame_t* p_frame)
}
}
}

// detect fetch completion:
twizy_batt_sensors_state |= BATT_SENSORS_GOT554;
if ((twizy_batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}

BatterySetSensorAndUpdate(BATT_SENSORS_GOT554);
}
break;

Expand Down Expand Up @@ -409,11 +404,7 @@ void OvmsVehicleRenaultTwizy::IncomingFrameCan1(CAN_frame_t* p_frame)
twizy_cell[8].volt_new = ((UINT) CAN_NIBL(4) << 8) | ((UINT) CAN_BYTE(5));
twizy_cell[9].volt_new = ((UINT) CAN_BYTE(6) << 4) | ((UINT) CAN_NIBH(7));

// detect fetch completion:
twizy_batt_sensors_state |= BATT_SENSORS_GOT557;
if ((twizy_batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}
BatterySetSensorAndUpdate(BATT_SENSORS_GOT557);
}
break;

Expand All @@ -428,11 +419,7 @@ void OvmsVehicleRenaultTwizy::IncomingFrameCan1(CAN_frame_t* p_frame)
twizy_cell[12].volt_new = ((UINT) CAN_BYTE(3) << 4) | ((UINT) CAN_NIBH(4));
twizy_cell[13].volt_new = ((UINT) CAN_NIBL(4) << 8) | ((UINT) CAN_BYTE(5));

// detect fetch completion:
twizy_batt_sensors_state |= BATT_SENSORS_GOT55E;
if ((twizy_batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}
BatterySetSensorAndUpdate(BATT_SENSORS_GOT55E);
}
break;

Expand All @@ -449,11 +436,7 @@ void OvmsVehicleRenaultTwizy::IncomingFrameCan1(CAN_frame_t* p_frame)
v2 = ((UINT) CAN_NIBL(6) << 8) | ((UINT) CAN_BYTE(7));
twizy_batt[0].volt_new = (v1 + v2 + 1) >> 1;

// detect fetch completion:
twizy_batt_sensors_state |= BATT_SENSORS_GOT55F;
if ((twizy_batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}
BatterySetSensorAndUpdate(BATT_SENSORS_GOT55F);
}
break;

Expand Down Expand Up @@ -757,11 +740,7 @@ void OvmsVehicleRenaultTwizy::IncomingFrameCan1(CAN_frame_t* p_frame)
}
}

// detect fetch completion:
twizy_batt_sensors_state |= BATT_SENSORS_GOT700;
if ((twizy_batt_sensors_state & BATT_SENSORS_READY) >= BATT_SENSORS_GOTALL) {
BatteryUpdate();
}
BatterySetSensorAndUpdate(BATT_SENSORS_GOT700);
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class OvmsVehicleRenaultTwizy : public OvmsVehicle
void BatteryUpdate();
void BatteryReset();
void BatterySendDataUpdate(bool force = false);
void BatterySetSensorAndUpdate(uint8_t flag);
vehicle_command_t CommandBatt(int verbosity, OvmsWriter* writer, OvmsCommand* cmd, int argc, const char* const* argv);

protected:
Expand Down
13 changes: 13 additions & 0 deletions vehicle/OVMS.V3/components/vehicle_zombie_vcu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(srcs)
set(include_dirs)

if (CONFIG_OVMS_VEHICLE_ZOMBIE_VCU)
list(APPEND srcs "src/vehicle_zombie_vcu.cpp")
list(APPEND include_dirs "src")
endif ()

# requirements can't depend on config
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
PRIV_REQUIRES "main"
WHOLE_ARCHIVE)
8 changes: 7 additions & 1 deletion vehicle/OVMS.V3/main/ovms_boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ static const char *TAG = "boot";
#include "string_writer.h"
#include <string.h>

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 4)
#define ADC_ATTEN ADC_ATTEN_DB_12
#else
#define ADC_ATTEN ADC_ATTEN_DB_11
#endif

boot_data_t __attribute__((section(".rtc.noload"))) boot_data;

Boot MyBoot __attribute__ ((init_priority (1100)));
Expand Down Expand Up @@ -337,7 +343,7 @@ Boot::Boot()
if (min_12v_level > 0)
{
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN);
uint32_t adc_level = 0;
for (int i = 0; i < 5; i++)
{
Expand Down
4 changes: 4 additions & 0 deletions vehicle/OVMS.V3/main/ovms_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ static const char *TAG = "events";
#include "ovms_boot.h"
#if ESP_IDF_VERSION_MAJOR >= 4
#include <esp_netif_types.h>
#ifdef CONFIG_ETH_ENABLED
#include <esp_eth_com.h>
#endif
#endif
#if ESP_IDF_VERSION_MAJOR >= 5
#include <esp_wifi_types.h>
#endif
Expand Down Expand Up @@ -764,6 +766,7 @@ void OvmsEvents::ReceiveSystemEvent(void* handler_args, esp_event_base_t base, i
break;
}
}
#ifdef CONFIG_ETH_ENABLED
else if (base == ETH_EVENT)
{
switch (id)
Expand All @@ -784,6 +787,7 @@ void OvmsEvents::ReceiveSystemEvent(void* handler_args, esp_event_base_t base, i
break;
}
}
#endif
}

#else
Expand Down
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/main/ovms_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ bool OvmsMetricBool::SetValue(std::string value, metric_unit_t units)

bool OvmsMetricBool::SetValue(const dbcNumber& value, metric_unit_t units)
{
return SetValue((bool)value.GetUnsignedInteger(), units);
return SetValue((uint32_t)(bool)value.GetUnsignedInteger(), units);
}

void OvmsMetricBool::Clear()
Expand Down
Loading