Rename data_nodes to data_objects and update references

As part of the v0.4 ThingSet spec, data nodes are named objects.
This commit is contained in:
Martin Jäger
2021-08-04 14:19:57 +02:00
parent 748c75489e
commit 51e0a3ae82
10 changed files with 42 additions and 42 deletions
@@ -18,7 +18,7 @@ def append_stuff(temp_obj):
main_obj[current_key] = temp_obj.copy()
temp_obj.clear()
with open("src/data_nodes.cpp", 'r') as fd:
with open("src/data_objects.cpp", 'r') as fd:
for (num, line) in enumerate(fd, 1):
if line =="\n":
continue
+3 -3
View File
@@ -4,7 +4,7 @@ zephyr_include_directories(.)
target_sources(app PRIVATE
bat_charger.cpp
data_nodes.cpp
data_objects.cpp
data_storage.cpp
daq.cpp
daq_driver.c
@@ -24,8 +24,8 @@ target_sources(app PRIVATE
add_subdirectory(ext)
if(${CONFIG_CUSTOM_DATA_NODES_FILE})
target_sources(app PRIVATE data_nodes_custom.cpp)
if(${CONFIG_CUSTOM_DATA_OBJECTS_FILE})
target_sources(app PRIVATE data_objects_custom.cpp)
endif()
# Using this option enables user-specific customization of the firmware. The
+10 -10
View File
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "data_nodes.h"
#include "data_objects.h"
#include <zephyr.h>
#include <soc.h>
@@ -14,7 +14,7 @@
#include <stm32_ll_utils.h>
#include <sys/crc.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(data_nodes, CONFIG_DATA_NODES_LOG_LEVEL);
LOG_MODULE_REGISTER(data_objects, CONFIG_DATA_OBJECTS_LOG_LEVEL);
#endif
#include <stdio.h>
@@ -28,8 +28,8 @@ LOG_MODULE_REGISTER(data_nodes, CONFIG_DATA_NODES_LOG_LEVEL);
#include "helper.h"
// can be used to configure custom data objects in separate file instead
// (e.g. data_nodes_custom.cpp)
#ifndef CONFIG_CUSTOM_DATA_NODES_FILE
// (e.g. data_objects_custom.cpp)
#ifndef CONFIG_CUSTOM_DATA_OBJECTS_FILE
const char manufacturer[] = "Libre Solar";
const char device_type[] = DT_PROP(DT_PATH(pcb), type);
@@ -68,7 +68,7 @@ uint16_t can_node_addr = CONFIG_THINGSET_CAN_DEFAULT_NODE_ID;
*
* Normal priority data objects (consuming 2 or more bytes) start from IDs > 23 = 0x17
*/
static DataNode data_nodes[] = {
static DataNode data_objects[] = {
// DEVICE INFORMATION /////////////////////////////////////////////////////
// using IDs >= 0x18
@@ -123,7 +123,7 @@ static DataNode data_nodes[] = {
// CONFIGURATION //////////////////////////////////////////////////////////
// using IDs >= 0x30 except for high priority data objects
TS_NODE_PATH(ID_CONF, "conf", 0, &data_nodes_update_conf),
TS_NODE_PATH(ID_CONF, "conf", 0, &data_objects_update_conf),
// battery settings
/*{
@@ -1228,9 +1228,9 @@ static DataNode data_nodes[] = {
ID_CTRL, TS_ANY_RW, PUBSUB_CTRL),
};
ThingSet ts(data_nodes, sizeof(data_nodes)/sizeof(DataNode));
ThingSet ts(data_objects, sizeof(data_objects)/sizeof(DataNode));
void data_nodes_update_conf()
void data_objects_update_conf()
{
bool changed;
if (battery_conf_check(&bat_conf_user)) {
@@ -1256,7 +1256,7 @@ void data_nodes_update_conf()
}
}
void data_nodes_init()
void data_objects_init()
{
#ifndef UNIT_TEST
uint8_t buf[12];
@@ -1324,4 +1324,4 @@ void update_control()
charger.time_last_ctrl_msg = uptime();
}
#endif /* CUSTOM_DATA_NODES_FILE */
#endif /* CUSTOM_DATA_OBJECTS_FILE */
+9 -9
View File
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef DATA_NODES_H_
#define DATA_NODES_H_
#ifndef DATA_OBJECTS_H_
#define DATA_OBJECTS_H_
/** @file
*
* @brief Handling of ThingSet data nodes
* @brief Handling of ThingSet data objects
*/
#include <stdint.h>
@@ -41,12 +41,12 @@
#define PUBSUB_CTRL (1U << 3) // control data sent and received via CAN
/*
* Data node versioning for EEPROM
* Data object versioning for EEPROM
*
* Increment the version number each time any data node IDs stored in NVM are changed. Otherwise
* Increment the version number each time any data object IDs stored in NVM are changed. Otherwise
* data might get corrupted.
*/
#define DATA_NODES_VERSION 4
#define DATA_OBJECTS_VERSION 4
extern bool pub_serial_enable;
extern bool pub_can_enable;
@@ -54,12 +54,12 @@ extern bool pub_can_enable;
/**
* Callback function to be called when conf values were changed
*/
void data_nodes_update_conf();
void data_objects_update_conf();
/**
* Initializes and reads data nodes from EEPROM
* Initializes and reads data objects from EEPROM
*/
void data_nodes_init();
void data_objects_init();
/**
* Callback to provide authentication mechanism via ThingSet
+9 -9
View File
@@ -10,7 +10,7 @@
#include "mcu.h"
#include "thingset.h"
#include "data_nodes.h"
#include "data_objects.h"
#include "helper.h"
#include <stdio.h>
@@ -61,7 +61,7 @@ uint32_t _calc_crc(const uint8_t *buf, size_t len)
/*
* EEPROM header bytes:
* - 0-1: Data nodes version number
* - 0-1: Data objects version number
* - 2-3: Number of data bytes
* - 4-7: CRC32
*
@@ -90,7 +90,7 @@ void data_storage_read()
buf_header[0], buf_header[1], buf_header[2], buf_header[3],
buf_header[4], buf_header[5], buf_header[6], buf_header[7]);
if (version == DATA_NODES_VERSION && len <= sizeof(buf)) {
if (version == DATA_OBJECTS_VERSION && len <= sizeof(buf)) {
k_mutex_lock(&data_buf_lock, K_FOREVER);
err = eeprom_read(eeprom_dev, EEPROM_HEADER_SIZE, buf, len);
@@ -99,7 +99,7 @@ void data_storage_read()
if (_calc_crc(buf, len) == crc) {
int status = ts.bin_sub(buf, sizeof(buf), TS_WRITE_MASK, PUB_NVM);
LOG_INF("EEPROM read and data nodes updated, ThingSet result: 0x%x", status);
LOG_INF("EEPROM read and data objects updated, ThingSet result: 0x%x", status);
}
else {
LOG_ERR("EEPROM data CRC invalid, expected 0x%x (data_len = %d)",
@@ -123,7 +123,7 @@ void data_storage_write()
int len = ts.bin_pub(buf + EEPROM_HEADER_SIZE, sizeof(buf) - EEPROM_HEADER_SIZE, PUB_NVM);
uint32_t crc = _calc_crc(buf + EEPROM_HEADER_SIZE, len);
*((uint16_t*)&buf[0]) = (uint16_t)DATA_NODES_VERSION;
*((uint16_t*)&buf[0]) = (uint16_t)DATA_OBJECTS_VERSION;
*((uint16_t*)&buf[2]) = (uint16_t)(len);
*((uint32_t*)&buf[4]) = crc;
@@ -156,7 +156,7 @@ void data_storage_write()
/*
* NVS header bytes:
* - 0-1: Data nodes version number
* - 0-1: Data objects version number
*
* Data starts from byte 2
*/
@@ -208,12 +208,12 @@ void data_storage_read()
uint16_t version = *((uint16_t*)&buf[0]);
if (version == DATA_NODES_VERSION) {
if (version == DATA_OBJECTS_VERSION) {
k_mutex_lock(&data_buf_lock, K_FOREVER);
int status = ts.bin_sub(buf + NVS_HEADER_SIZE, num_bytes - NVS_HEADER_SIZE,
TS_WRITE_MASK, PUB_NVM);
LOG_INF("NVS read and data nodes updated, ThingSet result: 0x%x", status);
LOG_INF("NVS read and data objects updated, ThingSet result: 0x%x", status);
k_mutex_unlock(&data_buf_lock);
}
@@ -230,7 +230,7 @@ void data_storage_write()
k_mutex_lock(&data_buf_lock, K_FOREVER);
*((uint16_t*)&buf[0]) = (uint16_t)DATA_NODES_VERSION;
*((uint16_t*)&buf[0]) = (uint16_t)DATA_OBJECTS_VERSION;
int len = ts.bin_pub(buf + NVS_HEADER_SIZE, sizeof(buf) - NVS_HEADER_SIZE, PUB_NVM);
+1 -1
View File
@@ -19,7 +19,7 @@
#include <logging/log.h>
LOG_MODULE_REGISTER(ext_can, CONFIG_CAN_LOG_LEVEL);
#include "data_nodes.h"
#include "data_objects.h"
#include "hardware.h"
#include "thingset.h"
#include "bat_charger.h"
+1 -1
View File
@@ -16,7 +16,7 @@
#include "thingset.h"
#include "hardware.h"
#include "data_nodes.h"
#include "data_objects.h"
#if CONFIG_UEXT_SERIAL_THINGSET
#define UART_DEVICE_NAME DT_LABEL(DT_ALIAS(uart_uext))
+2 -2
View File
@@ -26,7 +26,7 @@
#include "load.h" // load and USB output management
#include "leds.h" // LED switching using charlieplexing
#include "device_status.h" // log data (error memory, min/max measurements, etc.)
#include "data_nodes.h" // for access to internal data via ThingSet
#include "data_objects.h" // for access to internal data via ThingSet
void main(void)
{
@@ -54,7 +54,7 @@ void main(void)
#endif
// read custom configuration from EEPROM
data_nodes_init();
data_objects_init();
// Data Acquisition (DAQ) setup
daq_setup();
+1 -1
View File
@@ -24,7 +24,7 @@
#include "load.h" // load and USB output management
#include "leds.h" // LED switching using charlieplexing
#include "device_status.h" // log data (error memory, min/max measurements, etc.)
#include "data_nodes.h" // for access to internal data via ThingSet
#include "data_objects.h" // for access to internal data via ThingSet
DcBus lv_bus;
PowerPort lv_terminal(&lv_bus, true); // low voltage terminal (battery for typical MPPT)
+5 -5
View File
@@ -399,8 +399,8 @@ config DAQ_LOG_LEVEL
help
Log level for the DAQ module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config DATA_NODES_LOG_LEVEL
int "Log level for the data nodes module"
config DATA_OBJECTS_LOG_LEVEL
int "Log level for the data objects module"
default 2
depends on LOG
help
@@ -453,12 +453,12 @@ menuconfig CUSTOMIZATION
if CUSTOMIZATION
config CUSTOM_DATA_NODES_FILE
config CUSTOM_DATA_OBJECTS_FILE
bool "Use custom data nodes file"
default n
help
Use a custom file instead of default data_nodes.cpp for
ThingSet configuration.
Use the file data_objects_custom.cpp instead of the default data_objects.cpp
for ThingSet configuration.
config CUSTOM_DCDC_CONTROLLER
bool "Custom implementation of DC/DC controller"