mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
updated scripts - adding missing entities to modbus
This commit is contained in:
@@ -2,6 +2,10 @@ import fileinput
|
|||||||
import csv
|
import csv
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is used to build the contents of the `Modbus-Entity-Registers.md` file used in the emsesp.org documentation.
|
||||||
|
#
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
|
|
||||||
tag_to_tagtype = {
|
tag_to_tagtype = {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This is used to build the contents of the `Modbus-Entity-Registers.md` file used in the emsesp.org documentation.
|
||||||
|
|
||||||
make clean
|
make clean
|
||||||
make ARGS=-DEMSESP_STANDALONE
|
make ARGS=-DEMSESP_STANDALONE
|
||||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/generate-modbus-register-doc.py
|
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/generate-modbus-register-doc.py
|
||||||
|
|||||||
56
scripts/generate_csv_and_headers.sh
Executable file
56
scripts/generate_csv_and_headers.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Builds the dump CSV files, modbus headers and documentation.
|
||||||
|
# To be run before a release with
|
||||||
|
# sh ./scripts/generate_csv_and_headers.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
# build dummy modbus_entity_parameters.hpp so it compiles
|
||||||
|
cat >./src/modbus_entity_parameters.hpp <<EOL
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#define REGISTER_MAPPING(device_type, device_value_tag_type, long_name, modbus_register_offset, modbus_register_count) \\
|
||||||
|
{ device_type, device_value_tag_type, long_name[0], modbus_register_offset, modbus_register_count }
|
||||||
|
|
||||||
|
// IMPORTANT: This list MUST be ordered by keys "device_type", "device_value_tag_type" and "modbus_register_offset" in this order.
|
||||||
|
const std::initializer_list<Modbus::EntityModbusInfo> Modbus::modbus_register_mappings = {};
|
||||||
|
|
||||||
|
} // namespace emsesp
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
EOL
|
||||||
|
|
||||||
|
# build emsesp for standalone
|
||||||
|
make clean
|
||||||
|
make ARGS=-DEMSESP_STANDALONE
|
||||||
|
|
||||||
|
# dump_entities.csv
|
||||||
|
rm -f dump_entities.csv
|
||||||
|
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py >dump_entities.csv
|
||||||
|
ls -al dump_entities.csv
|
||||||
|
|
||||||
|
# dump_telegrams.csv
|
||||||
|
rm -f dump_telegrams.csv
|
||||||
|
echo "test telegram_dump" | ./emsesp | python3 ./scripts/strip_csv.py >dump_telegrams.csv
|
||||||
|
ls -al dump_telegrams.csv
|
||||||
|
|
||||||
|
# generate ./src/modbus_entity_parameters.hpp
|
||||||
|
rm -f ./src/modbus_entity_parameters.hpp
|
||||||
|
cat dump_entities.csv | python3 ./scripts/update_modbus_registers.py >./src/modbus_entity_parameters.hpp
|
||||||
|
ls -al ./src/modbus_entity_parameters.hpp
|
||||||
|
|
||||||
|
# generate doc - Modbus-Entity-Registers.md used in the emsesp.org documentation.
|
||||||
|
cat dump_entities.csv | python3 ./scripts/generate-modbus-register-doc.py >./docs/Modbus-Entity-Registers.md
|
||||||
@@ -47,6 +47,7 @@ string_sizes = {
|
|||||||
"thermostat/switchtime1": 16,
|
"thermostat/switchtime1": 16,
|
||||||
"thermostat/switchtime2": 16,
|
"thermostat/switchtime2": 16,
|
||||||
"thermostat/switchtime": 16,
|
"thermostat/switchtime": 16,
|
||||||
|
"thermostat/switchtimeww": 21,
|
||||||
"controller/datetime": 25
|
"controller/datetime": 25
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +165,7 @@ with fileinput.input() as f_input:
|
|||||||
for row in entities_reader:
|
for row in entities_reader:
|
||||||
entity = {}
|
entity = {}
|
||||||
for i, val in enumerate(row):
|
for i, val in enumerate(row):
|
||||||
|
# print(headers[i] + ": " + val)
|
||||||
entity[headers[i]] = val
|
entity[headers[i]] = val
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
@@ -196,8 +198,8 @@ for entity in entities:
|
|||||||
(-string_sizes[entity_dev_name] // 2) # divide and round up
|
(-string_sizes[entity_dev_name] // 2) # divide and round up
|
||||||
|
|
||||||
if int(entity["modbus count"]) <= 0:
|
if int(entity["modbus count"]) <= 0:
|
||||||
raise Exception('Entity "' + entity_shortname +
|
raise Exception('Entity "' + entity_dev_name + ' (' + entity_shortname + ')' +
|
||||||
'" does not have a size - string sizes need to be added manually to update_modbus_registers.py')
|
'" does not have a size - string sizes need to be added manually to update_modbus_registers.py/string_sizes')
|
||||||
|
|
||||||
# if entity["modbus count"] == "0":
|
# if entity["modbus count"] == "0":
|
||||||
# print("ignoring " + entity_dev_name + " - it has a register length of zero")
|
# print("ignoring " + entity_dev_name + " - it has a register length of zero")
|
||||||
|
|||||||
Reference in New Issue
Block a user