auto comments

This commit is contained in:
proddy
2024-07-14 23:45:07 +02:00
parent 5f1cc56939
commit 7fc2afc11b
3 changed files with 33 additions and 3 deletions

View File

@@ -3,9 +3,11 @@
# This script generates c++ code for the modbus parameter definitions.
#
# Usage:
# - first, dump all entities to csv by running 'scripts/dump_entities.sh'
# - first, dump all entities to csv by running 'sh ./scripts/dump_entities.sh'
# - then run 'cat ../dump_entities.csv | python3 update_modbus_registers.py > ../src/modbus_entity_parameters.hpp'
# from the "scripts" folder
# OR
# run `sh ./scripts/update_modbus_registers.sh` from the root folder
import fileinput
import csv
@@ -114,6 +116,12 @@ device_type_names = [
cpp_file_template = Template('''#include "modbus.h"
#include "emsdevice.h"
/*
* This file is auto-generated by the update_modbus_registers.sh script. Do not modify.
*/
// clang-format off
namespace emsesp {
using dt = EMSdevice::DeviceType;
@@ -125,7 +133,10 @@ using dt = EMSdevice::DeviceType;
const std::initializer_list<Modbus::EntityModbusInfo> Modbus::modbus_register_mappings = {
$entries};
} // namespace emsesp''')
} // namespace emsesp
// clang-format off
''')
# cpp_entry_template = Template(
# ' {std::make_tuple($devtype, $tagtype, std::string(\"$shortname\")), {$registeroffset, $registercount}},\n')
cpp_entry_template = Template(

View File

@@ -3,7 +3,7 @@
# Update modbus parameters from entity definitions.
# This script generates c++ code for the modbus parameter definitions.
#
# Run this script from the EMS-ESP32 root directory with the command `scripts/update_modbus_registers.sh`.
# Run this script from the EMS-ESP32 root directory with the command `sh ./scripts/update_modbus_registers.sh`.
while [[ $# -gt 0 ]]; do
case $1 in
@@ -35,6 +35,12 @@ if [ "$RESET" = "YES" ]; then
#include "modbus.h"
#include "emsdevice.h"
/*
* This file is auto-generated by the update_modbus_registers.sh script. Do not modify.
*/
// clang-format off
namespace emsesp {
using dt = EMSdevice::DeviceType;
@@ -46,6 +52,9 @@ using dt = EMSdevice::DeviceType;
const std::initializer_list<Modbus::EntityModbusInfo> Modbus::modbus_register_mappings = {};
} // namespace emsesp
// clang-format on
EOL
fi
@@ -53,3 +62,4 @@ make clean
make ARGS=-DEMSESP_STANDALONE
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/update_modbus_registers.py > ./src/modbus_entity_parameters.hpp
echo "Modbus entity parameters written to ./src/modbus_entity_parameters.hpp."

View File

@@ -1,6 +1,12 @@
#include "modbus.h"
#include "emsdevice.h"
/*
* This file is auto-generated by the update_modbus_registers.sh script. Do not modify.
*/
// clang-format off
namespace emsesp {
using dt = EMSdevice::DeviceType;
@@ -513,3 +519,6 @@ const std::initializer_list<Modbus::EntityModbusInfo> Modbus::modbus_register_ma
};
} // namespace emsesp
// clang-format off