From 60104c33ff47651b95d00b4549726034f1ffe9cc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jan 2023 12:39:41 +0000 Subject: [PATCH 01/16] tools: rename script to harmonize file names Signed-off-by: Steffen Vogel --- tools/{start_fpga.sh => start-fpga.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{start_fpga.sh => start-fpga.sh} (100%) diff --git a/tools/start_fpga.sh b/tools/start-fpga.sh similarity index 100% rename from tools/start_fpga.sh rename to tools/start-fpga.sh From 76e2986ee7be8df3b471a3d1abe8b088551f2c57 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jan 2023 12:39:52 +0000 Subject: [PATCH 02/16] packaging: fix include search path for redispp build Signed-off-by: Steffen Vogel --- packaging/deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/deps.sh b/packaging/deps.sh index b8a792e0b..e170a6efd 100644 --- a/packaging/deps.sh +++ b/packaging/deps.sh @@ -264,7 +264,7 @@ if [ -z "${SKIP_REDISPP}" -a -z "${SKIP_REDIS}" ]; then pushd redis-plus-plus/build # Somehow redis++ fails to find the hiredis include path on Debian multiarch builds - REDISPP_CMAKE_OPTS+="-DCMAKE_CXX_FLAGS=-I/usr/local/include" + REDISPP_CMAKE_OPTS+="-DCMAKE_CXX_FLAGS=-I${PREFIX}/include" cmake -DREDIS_PLUS_PLUS_BUILD_TEST=OFF \ -DREDIS_PLUS_PLUS_BUILD_STATIC=OFF \ From 49caafec7dee066bf3b484f61ae8c1e3929d3d24 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jan 2023 12:40:00 +0000 Subject: [PATCH 03/16] cmake: fix linking if rdkafka if dependency is not installed in system search path Signed-off-by: Steffen Vogel --- lib/nodes/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index a0b38ecba..064bb6ded 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -119,7 +119,7 @@ endif() # Enable Kafka support if(WITH_NODE_KAFKA) list(APPEND NODE_SRC kafka.cpp) - list(APPEND LIBRARIES ${RDKAFKA_LIBRARIES}) + list(APPEND LIBRARIES PkgConfig::RDKAFKA) endif() # Enable Comedi support From a083488c02ce119e9ecb4aaef4a4e31c84dde6c8 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jan 2023 14:39:36 +0000 Subject: [PATCH 04/16] packaging: do not reinstall libethercat if it is already present Signed-off-by: Steffen Vogel --- packaging/deps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/deps.sh b/packaging/deps.sh index e170a6efd..97ff7ff98 100644 --- a/packaging/deps.sh +++ b/packaging/deps.sh @@ -98,7 +98,8 @@ if ! pkg-config "libzmq >= 2.2.0" && \ fi # Build & Install EtherLab -if [ -z "${SKIP_ETHERLAB}" ]; then +if ! pkg-config "libethercat >= 1.5.2" && \ + [ -z "${SKIP_ETHERLAB}" ]; then git clone ${GIT_OPTS} --branch stable-1.5 https://gitlab.com/etherlab.org/ethercat.git pushd ethercat ./bootstrap From 260280ece02f4e11dee6ac008a24f8c05b69ca2a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 18 Jan 2023 11:38:08 +0000 Subject: [PATCH 05/16] ngsi: fix access to signal list in dead-code Signed-off-by: Steffen Vogel --- lib/nodes/ngsi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nodes/ngsi.cpp b/lib/nodes/ngsi.cpp index 250c54ebe..d3813afad 100644 --- a/lib/nodes/ngsi.cpp +++ b/lib/nodes/ngsi.cpp @@ -184,9 +184,9 @@ public: json_t *json_value = json_array(); for (unsigned k = 0; k < cnt; k++) { - const auto *sig = (Signal *) list_at_safe(smp->signals, index); const auto *smp = &smps[k]; const auto *data = &smp->data[index]; + auto sig = smp->signals->getByIndex(index); json_array_append_new(json_value, json_pack("[ f, o, i ]", time_to_double(smp->ts.origin), @@ -349,7 +349,7 @@ int ngsi_parse_entity(NodeCompat *n, json_t *json_entity, struct Sample * const smp->ts.origin = tss; auto *sd = &smp->data[attr->index]; - auto *sig = (Signal *) list_at_safe(n->getInputSignals(false), attr->index); + auto sig = n->getInputSignals(false)->getByIndex(attr->index); if (!sig) return -11; From 0473821d9560ad94f149cd17a02c6a5288e9c93f Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Tue, 20 Jun 2023 15:36:13 +0200 Subject: [PATCH 06/16] C++ code-style Signed-off-by: Philipp Jungkamp --- src/villas-node.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/villas-node.cpp b/src/villas-node.cpp index 3f4693c96..232e470cd 100644 --- a/src/villas-node.cpp +++ b/src/villas-node.cpp @@ -111,7 +111,7 @@ protected: std::cout << " - " << std::left << std::setw(18) << p->getName() << p->getDescription() << std::endl; } std::cout << std::endl; -#endif /* WITH_HOOKS */ +#endif // WITH_HOOKS #ifdef WITH_API std::cout << "Supported API commands:" << std::endl; @@ -120,7 +120,7 @@ protected: std::cout << " - " << std::left << std::setw(18) << p->getName() << p->getDescription() << std::endl; } std::cout << std::endl; -#endif /* WITH_API */ +#endif // WITH_API printCopyright(); } @@ -204,9 +204,9 @@ protected: } }; -} /* namespace tools */ -} /* namespace node */ -} /* namespace villas */ +} // namespace tools +} // namespace node +} // namespace villas int main(int argc, char *argv[]) { From 46bc0eed7a398c940a33a14980247c1bea763f87 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:01:21 +0000 Subject: [PATCH 07/16] packaging: update versions of dependencies Signed-off-by: Steffen Vogel --- packaging/deps.sh | 58 +++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/packaging/deps.sh b/packaging/deps.sh index 97ff7ff98..12c82facd 100644 --- a/packaging/deps.sh +++ b/packaging/deps.sh @@ -13,14 +13,14 @@ CMAKE_OPTS+=" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX}" MAKE_THREADS=${MAKE_THREADS:-$(nproc)} MAKE_OPTS+="--jobs=${MAKE_THREADS}" -git config --global http.postBuffer 524288000 -git config --global core.compression 0 +PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${PREFIX}/lib/pkgconfig:${PREFIX}/lib64/pkgconfig:${PREFIX}/share/pkgconfig +export PKG_CONFIG_PATH -DIR=$(mktemp -d) -pushd ${DIR} +TMPDIR=$(mktemp -d) +pushd ${TMPDIR} # Build & Install Criterion -if ! pkg-config "criterion >= 2.3.1" && \ +if ! pkg-config "criterion >= 2.4.1" && \ [ "${ARCH}" == "x86_64" ] && \ [ -z "${SKIP_CRITERION}" ]; then git clone ${GIT_OPTS} --branch v2.3.3 --recursive https://github.com/Snaipe/Criterion @@ -50,17 +50,17 @@ if ! ( pkg-config "lua >= 5.1" || \ pkg-config "lua51" || \ [ -n "${RTLAB_ROOT}" -a -f "/usr/local/include/lua.h" ] \ ) && [ -z "${SKIP_LUA}" ]; then - wget http://www.lua.org/ftp/lua-5.3.6.tar.gz -O - | tar -xz - pushd lua-5.3.6 + wget http://www.lua.org/ftp/lua-5.4.4.tar.gz -O - | tar -xz + pushd lua-5.4.4 make ${MAKE_OPTS} MYCFLAGS=-fPIC linux - make ${MAKE_OPTS} MYCFLAGS=-fPIC install + make ${MAKE_OPTS} MYCFLAGS=-fPIC INSTALL_TOP=${PREFIX} install popd fi # Build & Install mosquitto if ! pkg-config "libmosquitto >= 1.4.15" && \ [ -z "${SKIP_LIBMOSQUITTO}" ]; then - git clone ${GIT_OPTS} --branch v2.0.12 https://github.com/eclipse/mosquitto + git clone ${GIT_OPTS} --branch v2.0.15 https://github.com/eclipse/mosquitto mkdir -p mosquitto/build pushd mosquitto/build cmake -DWITH_BROKER=OFF \ @@ -73,7 +73,7 @@ if ! pkg-config "libmosquitto >= 1.4.15" && \ fi # Build & Install rabbitmq-c -if ! pkg-config "librabbitmq >= 0.8.0" && \ +if ! pkg-config "librabbitmq >= 0.13.0" && \ [ -z "${SKIP_LIBRABBITMQ}" ]; then git clone ${GIT_OPTS} --branch v0.11.0 https://github.com/alanxz/rabbitmq-c mkdir -p rabbitmq-c/build @@ -111,10 +111,12 @@ fi # Build & Install libiec61850 if ! pkg-config "libiec61850 >= 1.5.0" && \ [ -z "${SKIP_LIBIEC61850}" ]; then - git clone ${GIT_OPTS} --branch v1.5 https://github.com/mz-automation/libiec61850 + git clone ${GIT_OPTS} --branch v1.5.1 https://github.com/mz-automation/libiec61850 mkdir -p libiec61850/build pushd libiec61850/build - cmake ${CMAKE_OPTS} .. + cmake -DBUILD_EXAMPLES=OFF \ + -DBUILD_PYTHON_BINDINGS=OFF \ + ${CMAKE_OPTS} .. make ${MAKE_OPTS} install popd fi @@ -122,10 +124,12 @@ fi # Build & Install lib60870 if ! pkg-config "lib60870 >= 2.3.1" && \ [ -z "${SKIP_LIB60870}" ]; then - git clone ${GIT_OPTS} https://github.com/mz-automation/lib60870.git + git clone ${GIT_OPTS} --branch v2.3.2 https://github.com/mz-automation/lib60870.git mkdir -p lib60870/build pushd lib60870/build - cmake ${CMAKE_OPTS} ../lib60870-C + cmake -DBUILD_EXAMPLES=OFF \ + -DBUILD_TESTS=OFF \ + ${CMAKE_OPTS} ../lib60870-C make ${MAKE_OPTS} install popd fi @@ -133,11 +137,12 @@ fi # Build & Install librdkafka if ! pkg-config "rdkafka >= 1.5.0" && \ [ -z "${SKIP_RDKAFKA}" ]; then - git clone ${GIT_OPTS} --branch v1.6.0 https://github.com/edenhill/librdkafka + git clone ${GIT_OPTS} --branch v2.0.1 https://github.com/edenhill/librdkafka mkdir -p librdkafka/build pushd librdkafka/build cmake -DRDKAFKA_BUILD_TESTS=OFF \ -DRDKAFKA_BUILD_EXAMPLES=OFF \ + -DWITH_CURL=OFF \ ${CMAKE_OPTS} .. make ${MAKE_OPTS} install popd @@ -147,7 +152,7 @@ fi if ! ( pkg-config "libcgraph >= 2.30" && \ pkg-config "libgvc >= 2.30" \ ) && [ -z "${SKIP_GRAPHVIZ}" ]; then - git clone ${GIT_OPTS} --branch 2.49.0 https://gitlab.com/graphviz/graphviz.git + git clone ${GIT_OPTS} --branch 2.50.0 https://gitlab.com/graphviz/graphviz.git mkdir -p graphviz/build pushd graphviz/build cmake ${CMAKE_OPTS} .. @@ -158,7 +163,7 @@ fi # Build & Install uldaq if ! pkg-config "libuldaq >= 1.2.0" && \ [ -z "${SKIP_ULDAQ}" ]; then - git clone ${GIT_OPTS} --branch v1.2.0 https://github.com/mccdaq/uldaq + git clone ${GIT_OPTS} --branch v1.2.1 https://github.com/mccdaq/uldaq pushd uldaq autoreconf -i ./configure \ @@ -172,7 +177,7 @@ fi if ! ( pkg-config "libnl-3.0 >= 3.2.25" && \ pkg-config "libnl-route-3.0 >= 3.2.25" \ ) && [ -z "${SKIP_ULDAQ}" ]; then - git clone ${GIT_OPTS} --branch libnl3_5_0 https://github.com/thom311/libnl + git clone ${GIT_OPTS} --branch libnl3_7_0 https://github.com/thom311/libnl pushd libnl autoreconf -i ./configure \ @@ -221,7 +226,7 @@ fi # Build & Install nanomsg if ! pkg-config "nanomsg >= 1.0.0" && \ [ -z "${SKIP_NANOMSG}" ]; then - git clone ${GIT_OPTS} --branch 1.1.5 https://github.com/nanomsg/nanomsg.git + git clone ${GIT_OPTS} --branch 1.2 https://github.com/nanomsg/nanomsg.git mkdir -p nanomsg/build pushd nanomsg/build cmake -DNN_TESTS=OFF \ @@ -237,7 +242,7 @@ fi # Build & Install libxil if ! pkg-config "libxil >= 1.0.0" && \ [ -z "${SKIP_LIBXIL}" ]; then - git clone ${GIT_OPTS} --branch v0.1.0 https://git.rwth-aachen.de/acs/public/villas/fpga/libxil.git + git clone ${GIT_OPTS} --branch master https://git.rwth-aachen.de/acs/public/villas/fpga/libxil.git mkdir -p libxil/build pushd libxil/build cmake ${CMAKE_OPTS} .. @@ -247,8 +252,9 @@ fi # Build & Install hiredis if ! pkg-config "hiredis >= 1.0.0" && \ - [ -z "${SKIP_HIREDIS}" -a -z "${SKIP_REDIS}" ]; then - git clone ${GIT_OPTS} --branch v1.0.0 https://github.com/redis/hiredis.git + [ -z "${SKIP_HIREDIS}" ] && \ + [ -z "${SKIP_REDIS}" ]; then + git clone ${GIT_OPTS} --branch v1.1.0 https://github.com/redis/hiredis.git mkdir -p hiredis/build pushd hiredis/build cmake -DDISABLE_TESTS=ON \ @@ -259,8 +265,10 @@ if ! pkg-config "hiredis >= 1.0.0" && \ fi # Build & Install redis++ -if [ -z "${SKIP_REDISPP}" -a -z "${SKIP_REDIS}" ]; then - git clone ${GIT_OPTS} --branch 1.2.3 https://github.com/sewenew/redis-plus-plus.git +if ! pkg-config "redis++ >= 1.2.3" && \ + [ -z "${SKIP_REDISPP}" ] && \ + [ -z "${SKIP_REDIS}" ]; then + git clone ${GIT_OPTS} --branch 1.3.7 https://github.com/sewenew/redis-plus-plus.git mkdir -p redis-plus-plus/build pushd redis-plus-plus/build @@ -338,7 +346,7 @@ if ! cmake --find-package -DNAME=LibDataChannel -DCOMPILER_ID=GNU -DLANGUAGE=CXX fi popd -rm -rf ${DIR} +rm -rf ${TMPDIR} # Update linker cache if [ -z "${SKIP_LDCONFIG}" ]; then From 88fb57df8e6bb661be5bffb07098fa37d71bbe70 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:02:08 +0000 Subject: [PATCH 08/16] web: disable libwebsocket server status as it has been removed from upstream lib Signed-off-by: Steffen Vogel --- lib/api/requests/status.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/api/requests/status.cpp b/lib/api/requests/status.cpp index c00a81a77..55813b941 100644 --- a/lib/api/requests/status.cpp +++ b/lib/api/requests/status.cpp @@ -22,24 +22,6 @@ namespace api { class StatusRequest : public Request { -protected: - -#ifdef LWS_WITH_SERVER_STATUS - json_t * getLwsStatus() - { - int ret; - - struct lws_context *ctx = lws_get_context(session->wsi); - char buf[4096]; - - ret = lws_json_dump_context(ctx, buf, sizeof(buf), 0); - if (ret <= 0) - throw Error(HTTP_STATUS_INTERNAL_SERVER_ERROR, "Failed to dump LWS context"); - - return json_loads(buf, 0, nullptr); - } -#endif /* LWS_WITH_SERVER_STATUS */ - public: using Request::Request; @@ -129,10 +111,6 @@ public: if (!json_status) throw Error(HTTP_STATUS_INTERNAL_SERVER_ERROR, "Failed to prepare response: {}", err.text); -#ifdef LWS_WITH_SERVER_STATUS - json_object_set(json_status, "lws", getLwsStatus()); -#endif /* LWS_WITH_SERVER_STATUS */ - return new JsonResponse(session, HTTP_STATUS_OK, json_status); } }; From a709a8a0fba1e49545eb2693853f92fa6cac0b64 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:03:38 +0000 Subject: [PATCH 09/16] iec60870: fix coding style Signed-off-by: Steffen Vogel --- lib/nodes/iec60870.cpp | 82 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index 65be0d701..a0af9ee6a 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -22,8 +22,8 @@ using namespace std::literals::chrono_literals; static CP56Time2a timespec_to_cp56time2a(timespec time) { time_t time_ms = - static_cast (time.tv_sec) * 1000 - + static_cast (time.tv_nsec) / 1000000; + static_cast(time.tv_sec) * 1000 + + static_cast(time.tv_nsec) / 1000000; return CP56Time2a_createFromMsTimestamp(NULL, time_ms); } @@ -148,7 +148,7 @@ SignalType ASDUData::signalType() const std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) const { - if (CS101_ASDU_getTypeID(asdu) != static_cast (descriptor->type)) + if (CS101_ASDU_getTypeID(asdu) != static_cast(descriptor->type)) return std::nullopt; for (int i = 0; i < CS101_ASDU_getNumberOfElements(asdu); i++) { @@ -163,41 +163,41 @@ std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) cons QualityDescriptor quality; switch (typeWithoutTimestamp()) { case ASDUData::SCALED_INT: { - auto scaled_int = reinterpret_cast (io); + auto scaled_int = reinterpret_cast(io); int scaled_int_value = MeasuredValueScaled_getValue(scaled_int); - signal_data.i = static_cast (scaled_int_value); + signal_data.i = static_cast(scaled_int_value); quality = MeasuredValueScaled_getQuality(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT: { - auto normalized_float = reinterpret_cast (io); + auto normalized_float = reinterpret_cast(io); float normalized_float_value = MeasuredValueNormalized_getValue(normalized_float); - signal_data.f = static_cast (normalized_float_value); + signal_data.f = static_cast(normalized_float_value); quality = MeasuredValueNormalized_getQuality(normalized_float); break; } case ASDUData::DOUBLE_POINT: { - auto double_point = reinterpret_cast (io); + auto double_point = reinterpret_cast(io); DoublePointValue double_point_value = DoublePointInformation_getValue(double_point); - signal_data.i = static_cast (double_point_value); + signal_data.i = static_cast(double_point_value); quality = DoublePointInformation_getQuality(double_point); break; } case ASDUData::SINGLE_POINT: { - auto single_point = reinterpret_cast (io); + auto single_point = reinterpret_cast(io); bool single_point_value = SinglePointInformation_getValue(single_point); - signal_data.b = static_cast (single_point_value); + signal_data.b = static_cast(single_point_value); quality = SinglePointInformation_getQuality(single_point); break; } case ASDUData::SHORT_FLOAT: { - auto short_float = reinterpret_cast (io); + auto short_float = reinterpret_cast(io); float short_float_value = MeasuredValueShort_getValue(short_float); - signal_data.f = static_cast (short_float_value); + signal_data.f = static_cast(short_float_value); quality = MeasuredValueShort_getQuality(short_float); break; } @@ -209,31 +209,31 @@ std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) cons std::optional time_cp56; switch (type()) { case ASDUData::SCALED_INT_WITH_TIMESTAMP: { - auto scaled_int = reinterpret_cast (io); + auto scaled_int = reinterpret_cast(io); time_cp56 = MeasuredValueScaledWithCP56Time2a_getTimestamp(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT_WITH_TIMESTAMP: { - auto normalized_float = reinterpret_cast (io); + auto normalized_float = reinterpret_cast(io); time_cp56 = MeasuredValueNormalizedWithCP56Time2a_getTimestamp(normalized_float); break; } case ASDUData::DOUBLE_POINT_WITH_TIMESTAMP: { - auto double_point = reinterpret_cast (io); + auto double_point = reinterpret_cast(io); time_cp56 = DoublePointWithCP56Time2a_getTimestamp(double_point); break; } case ASDUData::SINGLE_POINT_WITH_TIMESTAMP: { - auto single_point = reinterpret_cast (io); + auto single_point = reinterpret_cast(io); time_cp56 = SinglePointWithCP56Time2a_getTimestamp(single_point); break; } case ASDUData::SHORT_FLOAT_WITH_TIMESTAMP: { - auto short_float = reinterpret_cast (io); + auto short_float = reinterpret_cast(io); time_cp56 = MeasuredValueShortWithCP56Time2a_getTimestamp(short_float); break; } @@ -263,72 +263,72 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const InformationObject io; switch (descriptor->type) { case ASDUData::SCALED_INT: { - auto scaled_int_value = static_cast (sample.signal_data.i & 0xFFFF); + auto scaled_int_value = static_cast(sample.signal_data.i & 0xFFFF); auto scaled_int = MeasuredValueScaled_create(NULL, ioa, scaled_int_value, sample.quality); - io = reinterpret_cast (scaled_int); + io = reinterpret_cast(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT: { - auto normalized_float_value = static_cast (sample.signal_data.f); + auto normalized_float_value = static_cast(sample.signal_data.f); auto normalized_float = MeasuredValueNormalized_create(NULL, ioa, normalized_float_value, sample.quality); - io = reinterpret_cast (normalized_float); + io = reinterpret_cast(normalized_float); break; } case ASDUData::DOUBLE_POINT: { - auto double_point_value = static_cast (sample.signal_data.i & 0x3); + auto double_point_value = static_cast(sample.signal_data.i & 0x3); auto double_point = DoublePointInformation_create(NULL, ioa, double_point_value, sample.quality); - io = reinterpret_cast (double_point); + io = reinterpret_cast(double_point); break; } case ASDUData::SINGLE_POINT: { auto single_point_value = sample.signal_data.b; auto single_point = SinglePointInformation_create(NULL, ioa, single_point_value, sample.quality); - io = reinterpret_cast (single_point); + io = reinterpret_cast(single_point); break; } case ASDUData::SHORT_FLOAT: { - auto short_float_value = static_cast (sample.signal_data.f); + auto short_float_value = static_cast(sample.signal_data.f); auto short_float = MeasuredValueShort_create(NULL, ioa, short_float_value, sample.quality); - io = reinterpret_cast (short_float); + io = reinterpret_cast(short_float); break; } case ASDUData::SCALED_INT_WITH_TIMESTAMP: { - auto scaled_int_value = static_cast (sample.signal_data.i & 0xFFFF); + auto scaled_int_value = static_cast(sample.signal_data.i & 0xFFFF); auto scaled_int = MeasuredValueScaledWithCP56Time2a_create(NULL, ioa, scaled_int_value, sample.quality, timestamp.value()); - io = reinterpret_cast (scaled_int); + io = reinterpret_cast(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT_WITH_TIMESTAMP: { - auto normalized_float_value = static_cast (sample.signal_data.f); + auto normalized_float_value = static_cast(sample.signal_data.f); auto normalized_float = MeasuredValueNormalizedWithCP56Time2a_create(NULL, ioa, normalized_float_value, sample.quality, timestamp.value()); - io = reinterpret_cast (normalized_float); + io = reinterpret_cast(normalized_float); break; } case ASDUData::DOUBLE_POINT_WITH_TIMESTAMP: { - auto double_point_value = static_cast (sample.signal_data.i & 0x3); + auto double_point_value = static_cast(sample.signal_data.i & 0x3); auto double_point = DoublePointWithCP56Time2a_create(NULL, ioa, double_point_value, sample.quality, timestamp.value()); - io = reinterpret_cast (double_point); + io = reinterpret_cast(double_point); break; } case ASDUData::SINGLE_POINT_WITH_TIMESTAMP: { auto single_point_value = sample.signal_data.b; auto single_point = SinglePointWithCP56Time2a_create(NULL, ioa, single_point_value, sample.quality, timestamp.value()); - io = reinterpret_cast (single_point); + io = reinterpret_cast(single_point); break; } case ASDUData::SHORT_FLOAT_WITH_TIMESTAMP: { - auto short_float_value = static_cast (sample.signal_data.f); + auto short_float_value = static_cast(sample.signal_data.f); auto short_float = MeasuredValueShortWithCP56Time2a_create(NULL, ioa, short_float_value, sample.quality, timestamp.value()); - io = reinterpret_cast (short_float); + io = reinterpret_cast(short_float); break; } @@ -383,27 +383,27 @@ void SlaveNode::createSlave() noexcept // Setup callbacks into the class CS104_Slave_setClockSyncHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu, CP56Time2a new_time) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onClockSync(connection, asdu, new_time); }, this); CS104_Slave_setInterrogationHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu, QualifierOfInterrogation qoi) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onInterrogation(connection, asdu, qoi); }, this); CS104_Slave_setASDUHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onASDU(connection, asdu); }, this); CS104_Slave_setConnectionEventHandler(server.slave, [](void *tcp_node, IMasterConnection connection, CS104_PeerConnectionEvent event){ - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); self->debugPrintConnection(connection, event); }, this); CS104_Slave_setRawMessageHandler(server.slave, [](void *tcp_node, IMasterConnection connection, uint8_t *message, int message_size, bool sent){ - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); self->debugPrintMessage(connection, message, message_size, sent); }, this); From ea1f8c3d51ebeec345a5880f1e552aa65a03f8e4 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:03:59 +0000 Subject: [PATCH 10/16] iec60870: fix compiler warning Signed-off-by: Steffen Vogel --- lib/nodes/iec60870.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index a0af9ee6a..d3683bb76 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -260,7 +260,7 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const ? std::optional { timespec_to_cp56time2a(sample.timestamp.value()) } : std::nullopt; - InformationObject io; + InformationObject io = nullptr; switch (descriptor->type) { case ASDUData::SCALED_INT: { auto scaled_int_value = static_cast(sample.signal_data.i & 0xFFFF); @@ -337,6 +337,7 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const } bool successfully_added = CS101_ASDU_addInformationObject(asdu, io); + InformationObject_destroy(io); return successfully_added; From 0aafb47dd21ddeaaa9cf7311f176486e634eb6d6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:04:21 +0000 Subject: [PATCH 11/16] redis: fix compiler warnings Signed-off-by: Steffen Vogel --- lib/nodes/redis.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/nodes/redis.cpp b/lib/nodes/redis.cpp index 8dcfbcb7a..0336a5255 100644 --- a/lib/nodes/redis.cpp +++ b/lib/nodes/redis.cpp @@ -216,7 +216,7 @@ void redis_on_message(NodeCompat *n, const std::string &channel, const std::stri n->logger->debug("Message: {}: {}", channel, msg); - int alloc, scanned, pushed; + int alloc, scanned, pushed = 0; unsigned cnt = n->in.vectorize; struct Sample *smps[cnt]; @@ -247,7 +247,6 @@ void redis_on_message(NodeCompat *n, const std::string &channel, const std::stri if (scanned < 0) { n->logger->error("Failed to decode samples"); - pushed = 0; goto out; } From 09c1e01f6fcab5fa70d7b15289036f4be27ba496 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:04:59 +0000 Subject: [PATCH 12/16] fix code-style Signed-off-by: Steffen Vogel --- lib/mapping.cpp | 1 - lib/path.cpp | 2 +- lib/super_node.cpp | 12 ++++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/mapping.cpp b/lib/mapping.cpp index 655d517f0..f7c3793ed 100644 --- a/lib/mapping.cpp +++ b/lib/mapping.cpp @@ -313,7 +313,6 @@ std::string MappingEntry::toString(unsigned index) const return ss.str(); } - Signal::Ptr MappingEntry::toSignal(unsigned index) const { auto name = toString(index); diff --git a/lib/path.cpp b/lib/path.cpp index 28be09de3..08042fe00 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -87,7 +87,7 @@ void * Path::runPoll() if (ret < 0) throw SystemError("Failed to poll"); - logger->debug("returned from poll(2): ret={}", ret); + logger->debug("Returned from poll(2): ret={}", ret); for (unsigned i = 0; i < pfds.size(); i++) { auto &pfd = pfds[i]; diff --git a/lib/super_node.cpp b/lib/super_node.cpp index ec70b8287..605ac468c 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -269,8 +269,10 @@ void SuperNode::startNodes() void SuperNode::startPaths() { for (auto *p : paths) { - if (p->isEnabled()) - p->start(); + if (!p->isEnabled()) + continue; + + p->start(); } } @@ -291,8 +293,10 @@ void SuperNode::prepareNodes() void SuperNode::preparePaths() { for (auto *p : paths) { - if (p->isEnabled()) - p->prepare(nodes); + if (!p->isEnabled()) + continue; + + p->prepare(nodes); } } From b81e4d9b74d10df730969df02ed14307c91616d3 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:30:01 +0000 Subject: [PATCH 13/16] remove obsolete rmshm and rmsem tools Signed-off-by: Steffen Vogel --- tools/CMakeLists.txt | 10 ---------- tools/rmsem.cpp | 20 -------------------- tools/rmshm.cpp | 20 -------------------- 3 files changed, 50 deletions(-) delete mode 100644 tools/rmsem.cpp delete mode 100644 tools/rmshm.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6604284f6..bcef18645 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -5,16 +5,6 @@ # @license Apache 2.0 ################################################################################### -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - add_executable(rmshm rmshm.cpp) - target_link_libraries(rmshm PUBLIC Threads::Threads rt) - - add_executable(rmsem rmsem.cpp) - target_link_libraries(rmsem PUBLIC Threads::Threads rt) - - list(APPEND TOOLS rmsem rmshm) -endif() - install( TARGETS ${TOOLS} COMPONENT tools diff --git a/tools/rmsem.cpp b/tools/rmsem.cpp deleted file mode 100644 index e3b7682b1..000000000 --- a/tools/rmsem.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/** Delete semaphores. - * - * @author Steffen Vogel - * @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC - * @license Apache 2.0 - *********************************************************************************/ - -#include -#include - -int main(int argc, char *argv[]) -{ - for (int i = 1; i < argc; i++) { - int ret = sem_unlink(argv[i]); - if (ret) - std::cerr << "Failed to unlink: " << argv[i] << std::endl; - } - - return 0; -} diff --git a/tools/rmshm.cpp b/tools/rmshm.cpp deleted file mode 100644 index 00539f84b..000000000 --- a/tools/rmshm.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/** Delete shared memory regions. - * - * @author Steffen Vogel - * @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC - * @license Apache 2.0 - *********************************************************************************/ - -#include -#include - -int main(int argc, char *argv[]) -{ - for (int i = 1; i < argc; i++) { - int ret = shm_unlink(argv[i]); - if (ret) - std::cerr << "Failed to unlink: " << argv[i] << std::endl; - } - - return 0; -} From a37b64111fa8d72a16365a24ec6f42e5fb401d0e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 4 Apr 2023 13:37:35 +0000 Subject: [PATCH 14/16] fpga: call base-class function for NodeFactory::start() Signed-off-by: Steffen Vogel --- lib/nodes/fpga.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nodes/fpga.cpp b/lib/nodes/fpga.cpp index cc3f8c006..d0b6b3cdc 100644 --- a/lib/nodes/fpga.cpp +++ b/lib/nodes/fpga.cpp @@ -240,7 +240,7 @@ int FpgaNodeFactory::start(SuperNode *sn) cards.splice(cards.end(), piceCards); - return 0; + return NodeFactory::start(sn); } static FpgaNodeFactory p; From 398497300d87bbc21aae40b8369676f11b040a03 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 4 Apr 2023 13:38:10 +0000 Subject: [PATCH 15/16] cmake: update package description Signed-off-by: Steffen Vogel --- cmake/VILLASnodePackaging.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/VILLASnodePackaging.cmake b/cmake/VILLASnodePackaging.cmake index 90fe4d003..2fcf94ade 100644 --- a/cmake/VILLASnodePackaging.cmake +++ b/cmake/VILLASnodePackaging.cmake @@ -13,7 +13,7 @@ set(CPACK_BUILD_SOURCE_DIRS ${PROJECT_SOURCE_DIR}/src;${PROJECT_SOURCE_DIR}/lib; set(CPACK_PACKAGE_NAME "villas-node") set(CPACK_PACKAGE_VENDOR ${PROJECT_AUTHOR}) -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is VILLASnode, a gateway for processing and forwardning simulation data between real-time simulators.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Connecting real-time power grid simulation equipment") set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION}) set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_PROJECT_MAJOR_VERSION}) set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_PROJECT_MINOR_VERSION}) From 9d28079d24169c340dbe7e064cb34bd893719309 Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Wed, 21 Jun 2023 10:06:52 +0200 Subject: [PATCH 16/16] node-redis: Work around breaking change in redis-plus-plus Signed-off-by: Philipp Jungkamp --- CMakeLists.txt | 8 ++++++++ include/villas/node/config.hpp.in | 1 + include/villas/nodes/redis_helpers.hpp | 17 +++++++++++++++++ lib/nodes/redis.cpp | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ffb6b4a8..83f69fedb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,14 @@ if (REDISPP_FOUND) set(REDISPP_WITH_TLS ON) endif() unset(CONTENTS) + + # Redis++ had a breaking change between 1.3.6 and 1.3.7 + # Detect this change by checking if the new header exists + # + # See https://github.com/sewenew/redis-plus-plus/commit/192ebae13583ff0611e2d7666a9c1e98a2a0dc86 + if (EXISTS "${REDISPP_INCLUDEDIR}/sw/redis++/redis_uri.h") + set(REDISPP_WITH_URI ON) + endif() endif() # Check if libwebsockets is build with deflate extension diff --git a/include/villas/node/config.hpp.in b/include/villas/node/config.hpp.in index 68e9a245a..16281314f 100644 --- a/include/villas/node/config.hpp.in +++ b/include/villas/node/config.hpp.in @@ -58,3 +58,4 @@ /* Library features */ #cmakedefine LWS_DEFLATE_FOUND #cmakedefine REDISPP_WITH_TLS +#cmakedefine REDISPP_WITH_URI diff --git a/include/villas/nodes/redis_helpers.hpp b/include/villas/nodes/redis_helpers.hpp index e30c291a4..d35018ed5 100644 --- a/include/villas/nodes/redis_helpers.hpp +++ b/include/villas/nodes/redis_helpers.hpp @@ -188,3 +188,20 @@ OStream &operator<<(OStream &os, const enum villas::node::RedisMode &m) return os; } + +namespace villas { +namespace node { +#ifdef REDISPP_WITH_URI + sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) + { + auto u = sw::redis::Uri { uri }; + return u.connection_options(); + } +#else + sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) + { + return sw::redis::ConnectionOptions { uri }; + } +#endif +} // node +} // villas diff --git a/lib/nodes/redis.cpp b/lib/nodes/redis.cpp index 0336a5255..ec33a83ca 100644 --- a/lib/nodes/redis.cpp +++ b/lib/nodes/redis.cpp @@ -418,7 +418,7 @@ int villas::node::redis_parse(NodeCompat *n, json_t *json) /* Connection options */ if (uri) - r->options = sw::redis::ConnectionOptions(uri); + r->options = make_redis_connection_options(uri); if (db >= 0) r->options.db = db;