Skip to content
Merged
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
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,27 @@ ProcessorCount(PROCESSORS_NUM)

set(CMAKE_ECLIPSE_MAKE_ARGUMENTS ${CMAKE_ECLIPSE_MAKE_ARGUMENTS} "--no-print-directory -j${PROCESSORS_NUM} -r -s" CACHE STRING "Make parameters")

# Check if the build run from Jenkins or locally
project(${PROJECT_NAME} LANGUAGES C)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(OPTION_ASAN "Enable AddressSanitizer" OFF)

set(PROJECT_COMPILE_OPTIONS "")

if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
list(APPEND PROJECT_COMPILE_OPTIONS -Wall -Wextra -Werror)

if(OPTION_ASAN)
message(STATUS "AddressSanitizer enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g3")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()
elseif(OPTION_ASAN)
message(WARNING "AddressSanitizer is only supported with GCC and Clang compilers.")
endif()

# TODO: Change STATIC to SHARED when libeebus is a part of SDK
add_library(${PROJECT_NAME} STATIC)

Expand Down Expand Up @@ -161,6 +179,12 @@ target_include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)

target_compile_options(
${PROJECT_NAME}
PRIVATE
${PROJECT_COMPILE_OPTIONS}
)

# Warn if there are unresolved symbols in libeebus.
# There should not be any unresolved symbols, and we don't want to
# wait until the executable is linked to find out.
Expand Down
5 changes: 5 additions & 0 deletions examples/heat_pump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ target_include_directories(${PROJECT_NAME}
${PROJECT_SOURCE_DIR}
)

target_compile_options(${PROJECT_NAME}
PRIVATE
${PROJECT_COMPILE_OPTIONS}
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
${MATH_LIBRARY}
Expand Down
11 changes: 11 additions & 0 deletions examples/heat_pump/hpsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ EebusError HpsrvConstruct(Hpsrv* self) {
}

EebusError AddLpc(Hpsrv* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

self->cs_lpc_listener = CsLpcListenerCreate();
if (self->cs_lpc_listener == NULL) {
return kEebusErrorMemoryAllocate;
Expand All @@ -132,6 +134,8 @@ EebusError AddLpc(Hpsrv* self, DeviceLocalObject* device_local, EntityLocalObjec
}

EebusError AddLpp(Hpsrv* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

self->cs_lpp_listener = CsLppListenerCreate();
if (self->cs_lpp_listener == NULL) {
return kEebusErrorMemoryAllocate;
Expand All @@ -149,6 +153,8 @@ EebusError AddLpp(Hpsrv* self, DeviceLocalObject* device_local, EntityLocalObjec
}

EebusError AddMpc(Hpsrv* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

static const MuMpcMeasurementConfig measurement_default_cfg = {
.value_source = kMeasurementValueSourceTypeMeasuredValue,
};
Expand Down Expand Up @@ -363,12 +369,16 @@ void OnRemoteSkiDisconnected(ServiceReaderObject* self, EebusServiceObject* serv

void OnRemoteServicesUpdate(ServiceReaderObject* self, EebusServiceObject* service, const Vector* entries) {
UNUSED(self);
UNUSED(service);
UNUSED(entries);

// Optional: print the remote services
}

void OnShipIdUpdate(ServiceReaderObject* self, const char* ski, const char* shipd_id) {
UNUSED(self);
UNUSED(ski);
UNUSED(shipd_id);
}

void OnShipStateUpdate(ServiceReaderObject* self, const char* ski, SmeState state) {
Expand All @@ -379,6 +389,7 @@ void OnShipStateUpdate(ServiceReaderObject* self, const char* ski, SmeState stat

bool IsWaitingForTrustAllowed(const ServiceReaderObject* self, const char* ski) {
UNUSED(self);
UNUSED(ski);

return true;
}
Expand Down
5 changes: 5 additions & 0 deletions examples/hems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ target_include_directories(${PROJECT_NAME}
${PROJECT_SOURCE_DIR}
)

target_compile_options(${PROJECT_NAME}
PRIVATE
${PROJECT_COMPILE_OPTIONS}
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
${MATH_LIBRARY}
Expand Down
3 changes: 3 additions & 0 deletions examples/hems/eg_lpc_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ EgLpListenerObject* EgLpcListenerCreate(HemsObject* hems) {
}

void Destruct(EgLpListenerObject* self) {
UNUSED(self);
// Nothing to be deallocated yet
}

Expand All @@ -101,6 +102,8 @@ void OnRemoteEntityConnect(EgLpListenerObject* self, const EntityAddressType* en
}

void OnRemoteEntityDisconnect(EgLpListenerObject* self, const EntityAddressType* entity_addr) {
UNUSED(entity_addr);

EgLpcListener* const lpc_listener = EG_LP_LISTENER(self);

// Currently only single remote entity is supported,
Expand Down
3 changes: 3 additions & 0 deletions examples/hems/eg_lpp_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ EgLpListenerObject* EgLppListenerCreate(HemsObject* hems) {
}

void Destruct(EgLpListenerObject* self) {
UNUSED(self);
// Nothing to be deallocated yet
}

Expand All @@ -101,6 +102,8 @@ void OnRemoteEntityConnect(EgLpListenerObject* self, const EntityAddressType* en
}

void OnRemoteEntityDisconnect(EgLpListenerObject* self, const EntityAddressType* entity_addr) {
UNUSED(entity_addr);

EgLppListener* const lpp_listener = EG_LP_LISTENER(self);

// Currently only single remote entity is supported,
Expand Down
7 changes: 7 additions & 0 deletions examples/hems/hems.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ EebusError HemsConstruct(Hems* self) {
}

EebusError AddEgLpc(Hems* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

self->eg_lpc_listener = EgLpcListenerCreate(HEMS_OBJECT(self));
if (self->eg_lpc_listener == NULL) {
return kEebusErrorMemoryAllocate;
Expand All @@ -121,6 +123,8 @@ EebusError AddEgLpc(Hems* self, DeviceLocalObject* device_local, EntityLocalObje
}

EebusError AddEgLpp(Hems* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

self->eg_lpp_listener = EgLppListenerCreate(HEMS_OBJECT(self));
if (self->eg_lpp_listener == NULL) {
return kEebusErrorMemoryAllocate;
Expand All @@ -137,6 +141,8 @@ EebusError AddEgLpp(Hems* self, DeviceLocalObject* device_local, EntityLocalObje
}

EebusError AddMaMpc(Hems* self, DeviceLocalObject* device_local, EntityLocalObject* entity_local) {
UNUSED(device_local);

self->ma_mpc_listener = MaMpcListenerCreate(HEMS_OBJECT(self));
if (self->ma_mpc_listener == NULL) {
return kEebusErrorMemoryAllocate;
Expand Down Expand Up @@ -301,6 +307,7 @@ void OnShipStateUpdate(ServiceReaderObject* self, const char* ski, SmeState stat

bool IsWaitingForTrustAllowed(const ServiceReaderObject* self, const char* ski) {
UNUSED(self);
UNUSED(ski);

return true;
}
Expand Down
1 change: 0 additions & 1 deletion examples/hems/ma_mpc_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ static const MaMpcListenerInterface ma_mpc_listener_methods = {
};

static EebusError MaMpcListenerConstruct(MaMpcListener* self, HemsObject* hems);
static float GetValue(const ScaledValue* value);

EebusError MaMpcListenerConstruct(MaMpcListener* self, HemsObject* hems) {
// Override "virtual functions table"
Expand Down
11 changes: 11 additions & 0 deletions src/cli/eebus_cli_cs_lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>

#include "src/cli/eebus_cli_cs_lp.h"
#include "src/common/eebus_arguments.h"
#include "src/common/eebus_bool/eebus_bool.h"
#include "src/common/eebus_date_time/eebus_date_time.h"
#include "src/use_case/model/scaled_value.h"
Expand Down Expand Up @@ -101,6 +102,7 @@ EebusCliHandlerObject* CsLpCliCreate(EnergyDirectionType energy_direction, CsLpU
}

void Destruct(EebusCliHandlerObject* self) {
UNUSED(self);
// Nothing to be deallocated yet
}

Expand All @@ -110,6 +112,9 @@ void Destruct(EebusCliHandlerObject* self) {
//
//-------------------------------------------------------------------------------------------//
void HandleCmdGetPowerLimit(const CsLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

LoadLimit limit = {0};
if (CsLpGetActivePowerLimit(self->cs_lp, &limit) != kEebusErrorOk) {
printf("%s getting Active Power Limit failed\n", self->cmd_name_caps);
Expand All @@ -123,6 +128,9 @@ void HandleCmdGetPowerLimit(const CsLpCli* self, const char* const* tokens, size
}

void HandleCmdGetFailsafeLimit(const CsLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

ScaledValue power_limit = {0};
bool is_changeable = false;
if (CsLpGetFailsafeActivePowerLimit(self->cs_lp, &power_limit, &is_changeable) != kEebusErrorOk) {
Expand All @@ -136,6 +144,9 @@ void HandleCmdGetFailsafeLimit(const CsLpCli* self, const char* const* tokens, s
}

void HandleCmdGetFailsafeDuration(const CsLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

DurationType duration = {0};
bool is_changeable = false;
if (CsLpGetFailsafeDurationMinimum(self->cs_lp, &duration, &is_changeable) != kEebusErrorOk) {
Expand Down
10 changes: 10 additions & 0 deletions src/cli/eebus_cli_eg_lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>

#include "src/cli/eebus_cli_eg_lp.h"
#include "src/common/eebus_arguments.h"
#include "src/common/eebus_bool/eebus_bool.h"
#include "src/common/eebus_date_time/eebus_date_time.h"
#include "src/use_case/model/scaled_value.h"
Expand Down Expand Up @@ -132,6 +133,9 @@ void Destruct(EebusCliHandlerObject* self) {
//
//-------------------------------------------------------------------------------------------//
void HandleCmdGetPowerLimit(const EgLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

LoadLimit limit = {0};
if (EgLpGetActivePowerLimit(self->eg_lp, self->entity_addr, &limit) != kEebusErrorOk) {
printf("%s getting power limit failed\n", self->cmd_name_caps);
Expand All @@ -145,6 +149,9 @@ void HandleCmdGetPowerLimit(const EgLpCli* self, const char* const* tokens, size
}

void HandleCmdGetFailsafeLimit(const EgLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

ScaledValue power_limit = {0};
if (EgLpGetFailsafeActivePowerLimit(self->eg_lp, self->entity_addr, &power_limit) != kEebusErrorOk) {
printf("%s getting failsafe limit failed\n", self->cmd_name_caps);
Expand All @@ -156,6 +163,9 @@ void HandleCmdGetFailsafeLimit(const EgLpCli* self, const char* const* tokens, s
}

void HandleCmdGetFailsafeDuration(const EgLpCli* self, const char* const* tokens, size_t num_tokens) {
UNUSED(tokens);
UNUSED(num_tokens);

DurationType duration = {0};
if (EgLpGetFailsafeDurationMinimum(self->eg_lp, self->entity_addr, &duration) != kEebusErrorOk) {
printf("%s getting failsafe duration failed\n", self->cmd_name_caps);
Expand Down
2 changes: 2 additions & 0 deletions src/cli/eebus_cli_mu_mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>

#include "src/cli/eebus_cli_mu_mpc.h"
#include "src/common/eebus_arguments.h"
#include "src/use_case/actor/mu/mpc/mu_mpc.h"

typedef struct MuMpcCli MuMpcCli;
Expand Down Expand Up @@ -76,6 +77,7 @@ EebusCliHandlerObject* MuMpcCliCreate(MuMpcUseCaseObject* mu_mpc) {
}

void Destruct(EebusCliHandlerObject* self) {
UNUSED(self);
// Nothing to be deallocated yet
}

Expand Down
14 changes: 14 additions & 0 deletions src/common/eebus_data/eebus_data_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string.h>

#include "src/common/api/eebus_data_interface.h"
#include "src/common/eebus_arguments.h"
#include "src/common/eebus_assert.h"
#include "src/common/eebus_errors.h"
#include "src/common/eebus_malloc.h"
Expand Down Expand Up @@ -118,6 +119,7 @@ EebusError EebusDataBaseCopyMatching(
void* dst_base_addr,
const void* data_to_match_base_addr
) {
UNUSED(data_to_match_base_addr);
// No matching check is done by default
return EEBUS_DATA_WRITE(cfg, dst_base_addr, base_addr);
}
Expand All @@ -139,6 +141,10 @@ bool EebusDataBaseHasIdentifiers(const EebusDataCfg* cfg, const void* base_addr)

bool EebusDataBaseSelectorsMatch(const EebusDataCfg* cfg, const void* base_addr, const EebusDataCfg* selectors_cfg,
const void* selectors_base_addr) {
UNUSED(cfg);
UNUSED(base_addr);
UNUSED(selectors_cfg);
UNUSED(selectors_base_addr);
// SelectorsMatch() currently is not supported by default
EEBUS_ASSERT_ALWAYS();
return false;
Expand Down Expand Up @@ -167,11 +173,19 @@ EebusError EebusDataBaseWriteElements(const EebusDataCfg* cfg, void* base_addr,

EebusError EebusDataBaseWritePartial(const EebusDataCfg* cfg, void* base_addr, void* src_base_addr,
const EebusDataCfg* selectors_cfg, const void* selectors_base_addr, SelectorsMatcher selectors_matcher) {
UNUSED(selectors_cfg);
UNUSED(selectors_base_addr);
UNUSED(selectors_matcher);

return EEBUS_DATA_WRITE_ELEMENTS(cfg, base_addr, src_base_addr);
}

void EebusDataBaseDeletePartial(const EebusDataCfg* cfg, void* base_addr, const EebusDataCfg* selectors_cfg,
const void* selectors_base_addr, SelectorsMatcher selectors_matcher, const EebusDataCfg* elements_cfg,
const void* elements_base_addr) {
UNUSED(selectors_cfg);
UNUSED(selectors_base_addr);
UNUSED(selectors_matcher);

EEBUS_DATA_DELETE_ELEMENTS(cfg, base_addr, elements_cfg, elements_base_addr);
}
Loading
Loading