diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5327e624..4b5e9272d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,18 +47,18 @@ repos: - id: editorconfig-checker alias: ec args: - - -disable-indent-size - - -exclude - - ^LICENSE$|^LICENSES/|\.ecf$ + - -disable-indent-size + - -exclude + - ^LICENSE$|^LICENSES/|\.ecf$ # Using this mirror lets us use mypyc-compiled black, which is about 2x faster - repo: https://github.com/psf/black-pre-commit-mirror - rev: "23.3.0" + rev: "24.10.0" hooks: - id: black-jupyter exclude: .*_pb2.pyi?$ args: - - --line-length=90 + - --line-length=90 - repo: https://github.com/pycqa/flake8 rev: "7.3.0" @@ -66,7 +66,7 @@ repos: - id: flake8 exclude: .*_pb2.pyi?$ args: - - --max-line-length=90 + - --max-line-length=90 - repo: https://github.com/markdownlint/markdownlint rev: "v0.13.0" diff --git a/clients/shmem/villas-shmem.cpp b/clients/shmem/villas-shmem.cpp index a39d975fa..f76ca4c3d 100644 --- a/clients/shmem/villas-shmem.cpp +++ b/clients/shmem/villas-shmem.cpp @@ -36,7 +36,7 @@ class Shmem : public Tool { void usage() override { std::cout - << "Usage: villas-test-shmem WNAME VECTORIZE" << std::endl + << "Usage: villas-test-shmem WNAME RNAME VECTORIZE" << std::endl << " WNAME name of the shared memory object for the output queue" << std::endl << " RNAME name of the shared memory object for the input queue" diff --git a/common/include/villas/compat.hpp b/common/include/villas/compat.hpp index 757e46ae8..7b8e84a9a 100644 --- a/common/include/villas/compat.hpp +++ b/common/include/villas/compat.hpp @@ -1,4 +1,4 @@ -/* Compatability for different library versions. +/* Compatibility for different library versions. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/common/include/villas/kernel/vfio_container.hpp b/common/include/villas/kernel/vfio_container.hpp index d1a27c652..e9ef36b7d 100644 --- a/common/include/villas/kernel/vfio_container.hpp +++ b/common/include/villas/kernel/vfio_container.hpp @@ -24,7 +24,7 @@ namespace villas { namespace kernel { namespace vfio { -// Backwards compatability with older kernels +// Backwards compatibility with older kernels #ifdef VFIO_UPDATE_VADDR static constexpr size_t EXTENSION_SIZE = VFIO_UPDATE_VADDR + 1; #elif defined(VFIO_UNMAP_ALL) diff --git a/common/include/villas/list.hpp b/common/include/villas/list.hpp index d09447b00..48b972b49 100644 --- a/common/include/villas/list.hpp +++ b/common/include/villas/list.hpp @@ -64,7 +64,7 @@ void list_push(struct List *l, void *p); // Clear list. void list_clear(struct List *l); -// Remove all occurences of a list item. +// Remove all occurrences of a list item. void list_remove_all(struct List *l, void *p); int list_remove(struct List *l, size_t idx); @@ -74,7 +74,7 @@ int list_insert(struct List *l, size_t idx, void *p); // Return the first element of the list for which cmp returns zero. void *list_search(struct List *l, cmp_cb_t cmp, const void *ctx); -// Returns the number of occurences for which cmp returns zero when called on all list elements. +// Returns the number of occurrences for which cmp returns zero when called on all list elements. int list_count(struct List *l, cmp_cb_t cmp, void *ctx); // Return 0 if list contains pointer p. diff --git a/common/include/villas/utils.hpp b/common/include/villas/utils.hpp index 0919013bf..7807f29ff 100644 --- a/common/include/villas/utils.hpp +++ b/common/include/villas/utils.hpp @@ -66,18 +66,18 @@ char *decolor(char *str); // @return Normal variate random variable (Gaussian) double boxMuller(float m, float s); -// Double precission uniform random variable +// Double precision uniform random variable double randf(); // Concat formatted string to an existing string. // // This function uses realloc() to resize the destination. -// Please make sure to only on dynamic allocated destionations!!! +// Please make sure to only use it on dynamically allocated destinations!!! // // @param dest A pointer to a malloc() allocated memory region // @param fmt A format string like for printf() // @param ... Optional parameters like for printf() -// @retval The the new value of the dest buffer. +// @retval The new value of the dest buffer. char *strcatf(char **dest, const char *fmt, ...) __attribute__((format(printf, 2, 3))); diff --git a/common/lib/compat.cpp b/common/lib/compat.cpp index 1197643b0..8a0b391d0 100644 --- a/common/lib/compat.cpp +++ b/common/lib/compat.cpp @@ -1,4 +1,4 @@ -/* Compatability for different library versions. +/* Compatibility for different library versions. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/common/lib/kernel/devices/ip_device.cpp b/common/lib/kernel/devices/ip_device.cpp index af6612625..6a8c00009 100644 --- a/common/lib/kernel/devices/ip_device.cpp +++ b/common/lib/kernel/devices/ip_device.cpp @@ -19,7 +19,7 @@ using villas::kernel::devices::IpDevice; IpDevice IpDevice::from(const fs::path unsafe_path) { if (!is_path_valid(unsafe_path)) throw RuntimeError( - "Path {} failed validation as IpDevicePath [adress in hex].[name] ", + "Path {} failed validation as IpDevicePath [address in hex].[name] ", unsafe_path.string()); return IpDevice(unsafe_path); } diff --git a/common/lib/kernel/vfio_container.cpp b/common/lib/kernel/vfio_container.cpp index e329443e4..989759dd9 100644 --- a/common/lib/kernel/vfio_container.cpp +++ b/common/lib/kernel/vfio_container.cpp @@ -57,7 +57,7 @@ static std::array construct_vfio_extension_str() { ret[VFIO_SPAPR_TCE_v2_IOMMU] = "SPAPR TCE v2"; // cppcheck-suppress containerOutOfBounds ret[VFIO_NOIOMMU_IOMMU] = "No IOMMU"; -// Backwards compatability with older kernels +// Backwards compatibility with older kernels #ifdef VFIO_UNMAP_ALL ret[VFIO_UNMAP_ALL] = "Unmap all"; #endif diff --git a/common/lib/memory.cpp b/common/lib/memory.cpp index 9750194b3..a9f60d96b 100644 --- a/common/lib/memory.cpp +++ b/common/lib/memory.cpp @@ -1,4 +1,4 @@ -/* Memory managment. +/* Memory management. * * Author: Daniel Krebs * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/common/lib/memory_manager.cpp b/common/lib/memory_manager.cpp index 904b228b3..1ea8d6d25 100644 --- a/common/lib/memory_manager.cpp +++ b/common/lib/memory_manager.cpp @@ -1,4 +1,4 @@ -/* Memory managment. +/* Memory management. * * Author: Daniel Krebs * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/common/lib/utils.cpp b/common/lib/utils.cpp index 848c607da..e45f816e4 100644 --- a/common/lib/utils.cpp +++ b/common/lib/utils.cpp @@ -43,14 +43,14 @@ std::vector tokenize(const std::string &s, std::vector tokens; size_t lastPos = 0; - size_t curentPos; + size_t currentPos; - while ((curentPos = s.find(delimiter, lastPos)) != std::string::npos) { - const size_t tokenLength = curentPos - lastPos; + while ((currentPos = s.find(delimiter, lastPos)) != std::string::npos) { + const size_t tokenLength = currentPos - lastPos; tokens.push_back(s.substr(lastPos, tokenLength)); // Advance in string - lastPos = curentPos + delimiter.length(); + lastPos = currentPos + delimiter.length(); } // Check if there's a last token behind the last delimiter. @@ -159,7 +159,7 @@ char *decolor(char *str) { } void killme(int sig) { - // Send only to main thread in case the ID was initilized by signalsInit() + // Send only to main thread in case the ID was initialized by signalsInit() if (main_thread) pthread_kill(main_thread, sig); else @@ -198,9 +198,17 @@ char *vstrcatf(char **dest, const char *fmt, va_list ap) { int n = *dest ? strlen(*dest) : 0; int i = vasprintf(&tmp, fmt, ap); - *dest = (char *)(realloc(*dest, n + i + 1)); - if (*dest != nullptr) - strncpy(*dest + n, tmp, i + 1); + if (i < 0) + return *dest; + + char *p = (char *)realloc(*dest, n + i + 1); + if (p == nullptr) { + free(tmp); + return *dest; + } + + *dest = p; + strncpy(*dest + n, tmp, i + 1); free(tmp); diff --git a/doc/openapi/components/schemas/config/hooks/pmu_dft.yaml b/doc/openapi/components/schemas/config/hooks/pmu_dft.yaml index 5ffb574f2..d79bcc8fd 100644 --- a/doc/openapi/components/schemas/config/hooks/pmu_dft.yaml +++ b/doc/openapi/components/schemas/config/hooks/pmu_dft.yaml @@ -84,7 +84,7 @@ allOf: - center - right default: center - description: The timestamp alignment in respect to the the window. + description: The timestamp alignment in respect to the window. phase_offset: type: number default: 0.0 diff --git a/doc/openapi/components/schemas/config/http.yaml b/doc/openapi/components/schemas/config/http.yaml index f8ecfd215..44c896f2f 100644 --- a/doc/openapi/components/schemas/config/http.yaml +++ b/doc/openapi/components/schemas/config/http.yaml @@ -4,12 +4,20 @@ --- type: object properties: + enabled: + type: boolean + default: true + title: Enable HTTP/WebSocket server + description: | + Whether the HTTP & WebSocket server listens on a port. + port: type: integer - default: 80 + default: 8080 title: Listening port description: | - The TCP port number on which HTTP & WebSocket server. + The TCP port number on which the HTTP & WebSocket server listens. + Defaults to 80 when running as root, otherwise 8080. ssl_cert: type: string diff --git a/doc/openapi/components/schemas/config/nodes/websocket.yaml b/doc/openapi/components/schemas/config/nodes/websocket.yaml index 236b1559e..1c74f92ad 100644 --- a/doc/openapi/components/schemas/config/nodes/websocket.yaml +++ b/doc/openapi/components/schemas/config/nodes/websocket.yaml @@ -29,5 +29,12 @@ allOf: format: uri description: A WebSocket URI + wait_connected: + type: boolean + default: true + description: | + Wait until all configured client connections in `destinations` are + established before finishing node startup. + - $ref: ../node_signals.yaml - $ref: ../node.yaml diff --git a/doc/openapi/components/schemas/config/nodes/zeromq.yaml b/doc/openapi/components/schemas/config/nodes/zeromq.yaml index f263689be..a0cf9add5 100644 --- a/doc/openapi/components/schemas/config/nodes/zeromq.yaml +++ b/doc/openapi/components/schemas/config/nodes/zeromq.yaml @@ -14,6 +14,15 @@ allOf: - pubsub - radiodish + pattern: + type: string + enum: + - pubsub + - radiodish + default: pubsub + description: | + The ZeroMQ socket pattern to use. + publish: type: string format: uri @@ -49,10 +58,10 @@ allOf: description: | The public key of the server. - private_key: + secret_key: type: string description: | - The private key of the server. + The secret (private) key of the server. out: type: object diff --git a/doc/openapi/components/schemas/config/path.yaml b/doc/openapi/components/schemas/config/path.yaml index 783e17897..c57f9bb25 100644 --- a/doc/openapi/components/schemas/config/path.yaml +++ b/doc/openapi/components/schemas/config/path.yaml @@ -64,7 +64,7 @@ properties: mask: description: | - This setting allows masking the the input nodes which can trigger the path. + This setting allows masking the input nodes which can trigger the path. See also `mode` setting. @@ -107,7 +107,7 @@ properties: A boolean flag which enables the poll-based mode for reading samples from multiple path sources. **Note:** This is an advanced setting. - Most users should use the the default value which will always do the right thing based on the number and type of input nodes for this path. + Most users should use the default value which will always do the right thing based on the number and type of input nodes for this path. type: boolean diff --git a/etc/examples/hooks/skip_first.conf b/etc/examples/hooks/skip_first.conf index 8df3549fe..55e6c33f1 100644 --- a/etc/examples/hooks/skip_first.conf +++ b/etc/examples/hooks/skip_first.conf @@ -13,7 +13,7 @@ paths = ( type = "skip_first" seconds = 10 - # sequence = 10 + # samples = 10 } ) } diff --git a/etc/examples/nodes/file.conf b/etc/examples/nodes/file.conf index 6a5c2ab42..a68522371 100644 --- a/etc/examples/nodes/file.conf +++ b/etc/examples/nodes/file.conf @@ -5,7 +5,7 @@ nodes = { file_node = { type = "file" - # These options specify the URI where the the files are stored + # These options specify the URI where the files are stored # The URI accepts all format tokens of (see strftime(3)) uri = "logs/input.log" # uri = "logs/output_%F_%T.log" diff --git a/etc/examples/nodes/ngsi.conf b/etc/examples/nodes/ngsi.conf index ad367571c..edb85b52b 100644 --- a/etc/examples/nodes/ngsi.conf +++ b/etc/examples/nodes/ngsi.conf @@ -5,7 +5,7 @@ nodes = { ngsi_node = { type = "ngsi" - # The HTTP REST API endpoint of the FIRWARE context broker + # The HTTP REST API endpoint of the FIWARE context broker endpoint = "http://46.101.131.212:1026" # Add an 'Auth-Token' token header to each request diff --git a/etc/examples/nodes/redis.conf b/etc/examples/nodes/redis.conf index 2816de3cd..648a44737 100644 --- a/etc/examples/nodes/redis.conf +++ b/etc/examples/nodes/redis.conf @@ -12,7 +12,7 @@ nodes = { # The Redis key to be used for mode = 'key' or 'hash' (default is the node name) key = "my_key" - # The Redis channel tp be used for mode = 'channel' (default is the node name) + # The Redis channel to be used for mode = 'channel' (default is the node name) channel = "my_channel" # One of: diff --git a/include/villas/kernel/tc.hpp b/include/villas/kernel/tc.hpp index 51de653d3..5dd8266bf 100644 --- a/include/villas/kernel/tc.hpp +++ b/include/villas/kernel/tc.hpp @@ -1,9 +1,9 @@ -/* Setup interface queuing desciplines for network emulation. +/* Setup interface queuing disciplines for network emulation. * * We use the firewall mark to apply individual netem qdiscs * per node. Every node uses an own BSD socket. * By using so SO_MARK socket option (see socket(7)) - * we can classify traffic originating from a node seperately. + * we can classify traffic originating from a node separately. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/include/villas/kernel/tc_netem.hpp b/include/villas/kernel/tc_netem.hpp index f2368bb5a..2e7006765 100644 --- a/include/villas/kernel/tc_netem.hpp +++ b/include/villas/kernel/tc_netem.hpp @@ -3,7 +3,7 @@ * We use the firewall mark to apply individual netem qdiscs * per node. Every node uses an own BSD socket. * By using so SO_MARK socket option (see socket(7)) - * we can classify traffic originating from a node seperately. + * we can classify traffic originating from a node separately. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/include/villas/node/config.hpp.in b/include/villas/node/config.hpp.in index 2ea3cb756..0fd3b4f5d 100644 --- a/include/villas/node/config.hpp.in +++ b/include/villas/node/config.hpp.in @@ -18,7 +18,7 @@ #define MAX_SAMPLE_LENGTH 512u #define DEFAULT_FORMAT_BUFFER_LENGTH 4096u -/* Number of hugepages which are requested from the the kernel. +/* Number of hugepages which are requested from the kernel. * @see https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt */ #define DEFAULT_NR_HUGEPAGES 100 diff --git a/include/villas/node_compat.hpp b/include/villas/node_compat.hpp index caa5039e8..0b9f5de57 100644 --- a/include/villas/node_compat.hpp +++ b/include/villas/node_compat.hpp @@ -1,4 +1,4 @@ -/* Node compatability layer for C++. +/* Node compatibility layer for C++. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University diff --git a/include/villas/nodes/comedi.hpp b/include/villas/nodes/comedi.hpp index 81881c5d8..c1e263d51 100644 --- a/include/villas/nodes/comedi.hpp +++ b/include/villas/nodes/comedi.hpp @@ -34,7 +34,7 @@ struct comedi_direction { int sample_rate_hz; // Sample rate in Hz bool present; // Config present bool enabled; // Card is started successfully - bool running; // Card is actively transfering samples + bool running; // Card is actively transferring samples struct timespec started; // Timestamp when sampling started struct timespec last_debug; // Timestamp of last debug output size_t counter; // Number of villas samples transfered diff --git a/include/villas/nodes/infiniband.hpp b/include/villas/nodes/infiniband.hpp index b21c76b44..4935c39fb 100644 --- a/include/villas/nodes/infiniband.hpp +++ b/include/villas/nodes/infiniband.hpp @@ -76,11 +76,11 @@ struct infiniband { // Counter to keep track of available recv. WRs unsigned available_recv_wrs; - /* Fixed number to substract from min. number available + /* Fixed number to subtract from min. number available * WRs in receive queue */ unsigned buffer_subtraction; - // Unrealiable connectionless data + // Unreliable connectionless data struct ud_s { ::rdma_ud_param ud; ::ibv_ah *ah; diff --git a/include/villas/shmem.hpp b/include/villas/shmem.hpp index 17119deeb..3be6fe15f 100644 --- a/include/villas/shmem.hpp +++ b/include/villas/shmem.hpp @@ -56,7 +56,7 @@ struct ShmemInterface { * calls will be written to this pointer. * @param[in] conf Configuration parameters for the output queue. * @retval 0 The objects were opened and initialized successfully. - * @retval <0 An error occured; errno is set accordingly. + * @retval <0 An error occurred; errno is set accordingly. */ int shmem_int_open(const char *wname, const char *rname, struct ShmemInterface *shm, struct ShmemConfig *conf); diff --git a/include/villas/socket_addr.hpp b/include/villas/socket_addr.hpp index d648cf64b..8dd83bc90 100644 --- a/include/villas/socket_addr.hpp +++ b/include/villas/socket_addr.hpp @@ -40,7 +40,7 @@ enum class SocketLayer { ETH, IP, UDP, UNIX, TCP_CLIENT, TCP_SERVER }; /* Generate printable socket address depending on the address family * * A IPv4 address is formatted as dotted decimals followed by the port/protocol number - * A link layer address is formatted in hexadecimals digits seperated by colons and the inferface name + * A link layer address is formatted in hexadecimals digits separated by colons and the interface name * * @param sa A pointer to the socket address. * @return The buffer containing the textual representation of the address. The caller is responsible to free() this buffer! diff --git a/include/villas/web.hpp b/include/villas/web.hpp index 6fd649d72..894feb1e7 100644 --- a/include/villas/web.hpp +++ b/include/villas/web.hpp @@ -67,7 +67,7 @@ class Web final { Api *getApi() { return api; } - // for C-compatability + // for C-compatibility lws_context *getContext() { return context; } lws_vhost *getVHost() { return vhost; } diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt index 1a0cdd2d8..908230663 100644 --- a/lib/api/CMakeLists.txt +++ b/lib/api/CMakeLists.txt @@ -14,7 +14,7 @@ set(API_SRC requests/path.cpp requests/status.cpp - requests/capabiltities.cpp + requests/capabilities.cpp requests/config.cpp requests/shutdown.cpp requests/restart.cpp diff --git a/lib/api/requests/capabiltities.cpp b/lib/api/requests/capabilities.cpp similarity index 89% rename from lib/api/requests/capabiltities.cpp rename to lib/api/requests/capabilities.cpp index 6a7861862..2d47f7780 100644 --- a/lib/api/requests/capabiltities.cpp +++ b/lib/api/requests/capabilities.cpp @@ -1,4 +1,4 @@ -/* The "capabiltities" API ressource. +/* The "capabilities" API resource. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University @@ -35,8 +35,7 @@ class CapabilitiesRequest : public Request { // Register API request static char n[] = "capabilities"; static char r[] = "/capabilities"; -static char d[] = - "get capabiltities and details about this VILLASnode instance"; +static char d[] = "get capabilities and details about this VILLASnode instance"; static RequestPlugin p; } // namespace api diff --git a/lib/api/requests/node.cpp b/lib/api/requests/node.cpp index 89fab17f9..be1fd7e43 100644 --- a/lib/api/requests/node.cpp +++ b/lib/api/requests/node.cpp @@ -25,6 +25,6 @@ void NodeRequest::prepare() { node = nodes.lookup(uuid); if (!node) throw Error::badRequest(json_pack("{ s: s }", "uuid", matches[1].c_str()), - "No node found with with matching UUID"); + "No node found with matching UUID"); } } diff --git a/lib/api/requests/path.cpp b/lib/api/requests/path.cpp index b3ed3c5d1..91322f37c 100644 --- a/lib/api/requests/path.cpp +++ b/lib/api/requests/path.cpp @@ -23,5 +23,5 @@ void PathRequest::prepare() { path = paths.lookup(uuid); if (!path) throw Error::badRequest(json_pack("{ s: s }", "uuid", matches[1].c_str()), - "No path found with with matching UUID"); + "No path found with matching UUID"); } diff --git a/lib/dumper.cpp b/lib/dumper.cpp index 4bc56664b..d2a005c8a 100644 --- a/lib/dumper.cpp +++ b/lib/dumper.cpp @@ -40,7 +40,9 @@ int Dumper::openSocket() { sockaddr_un socketaddrUn; socketaddrUn.sun_family = AF_UNIX; - strcpy(socketaddrUn.sun_path, socketPath.c_str()); + strncpy(socketaddrUn.sun_path, socketPath.c_str(), + sizeof(socketaddrUn.sun_path) - 1); + socketaddrUn.sun_path[sizeof(socketaddrUn.sun_path) - 1] = '\0'; int ret = connect(socketFd, (struct sockaddr *)&socketaddrUn, sizeof(socketaddrUn)); diff --git a/lib/formats/line.cpp b/lib/formats/line.cpp index 1e15715a8..b4af854d2 100644 --- a/lib/formats/line.cpp +++ b/lib/formats/line.cpp @@ -92,7 +92,7 @@ int LineFormat::scan(FILE *f, struct Sample *const smps[], unsigned cnt) { if (!first_line_skipped) { bytes = getdelim(&in.buffer, &in.buflen, delimiter, f); if (bytes < 0) - return -1; // An error or eof occured + return -1; // An error or EOF occurred first_line_skipped = true; } @@ -107,7 +107,7 @@ int LineFormat::scan(FILE *f, struct Sample *const smps[], unsigned cnt) { if (feof(f)) break; else if (bytes < 0) - return -1; // An error or eof occured + return -1; // An error or EOF occurred // Skip whitespaces, empty and comment lines for (ptr = in.buffer; isspace(*ptr); ptr++) diff --git a/lib/hooks/digest.cpp b/lib/hooks/digest.cpp index 4b81ae0c8..59295a7c8 100644 --- a/lib/hooks/digest.cpp +++ b/lib/hooks/digest.cpp @@ -193,8 +193,8 @@ class DigestHook : public Hook { Hook::parse(json); char const *uri_str; - char const *mode_str; - char const *algorithm_str; + char const *mode_str = nullptr; + char const *algorithm_str = nullptr; json_error_t err; int ret = diff --git a/lib/hooks/gate.cpp b/lib/hooks/gate.cpp index 265eac9ab..194b603a5 100644 --- a/lib/hooks/gate.cpp +++ b/lib/hooks/gate.cpp @@ -43,7 +43,7 @@ class GateHook : public SingleSignalHook { json_error_t err; - const char *mode_str; + const char *mode_str = nullptr; assert(state != State::STARTED); diff --git a/lib/hooks/ma.cpp b/lib/hooks/ma.cpp index fee09b7fc..1609d8929 100644 --- a/lib/hooks/ma.cpp +++ b/lib/hooks/ma.cpp @@ -57,7 +57,7 @@ class MovingAverageHook : public MultiSignalHook { ret = json_unpack_ex(json, &err, 0, "{ s?: i }", "window_size", &windowSize); if (ret) - throw ConfigError(json, err, "node-config-hook-rms"); + throw ConfigError(json, err, "node-config-hook-ma"); state = State::PARSED; } diff --git a/lib/hooks/pmu_dft.cpp b/lib/hooks/pmu_dft.cpp index 37402e2cc..b307e49d2 100644 --- a/lib/hooks/pmu_dft.cpp +++ b/lib/hooks/pmu_dft.cpp @@ -253,8 +253,8 @@ class PmuDftHook : public MultiSignalHook { json, &err, 0, "{ s?: i, s?: F, s?: F, s?: F, s?: i, s?: i, s?: s, s?: s, s?: s, s?: " "i, s?: s, s?: b, s?: s, s?: F, s?: F, s?: F, s?: F}", - "sample_rate", &sampleRate, "start_freqency", &startFrequency, - "end_freqency", &endFreqency, "frequency_resolution", + "sample_rate", &sampleRate, "start_frequency", &startFrequency, + "end_frequency", &endFreqency, "frequency_resolution", &frequencyResolution, "dft_rate", &rate, "window_size_factor", &windowSizeFactor, "window_type", &windowTypeC, "padding_type", &paddingTypeC, "estimate_type", &estimateTypeC, "pps_index", &ppsIndex, @@ -265,6 +265,14 @@ class PmuDftHook : public MultiSignalHook { if (ret) throw ConfigError(json, err, "node-config-hook-dft"); + // Backward-compatibility: accept the previously misspelled keys. + json_t *json_start = json_object_get(json, "start_freqency"); + if (json_start) + startFrequency = json_number_value(json_start); + json_t *json_end = json_object_get(json, "end_freqency"); + if (json_end) + endFreqency = json_number_value(json_end); + windowSize = sampleRate * windowSizeFactor / (double)rate; logger->info( "Set windows size to {} samples which fits {} times the rate {}s", diff --git a/lib/kernel/if.cpp b/lib/kernel/if.cpp index 71ae1a9d5..bf83dd472 100644 --- a/lib/kernel/if.cpp +++ b/lib/kernel/if.cpp @@ -182,18 +182,16 @@ int Interface::setAffinity(int affinity) { file = fopen(filename.c_str(), "w"); if (file) { if (fprintf(file, "%8lx", (unsigned long)cset_pin) < 0) - throw SystemError( - "Failed to set affinity for for IRQ {} on interface '{}'", irq, - getName()); + throw SystemError("Failed to set affinity for IRQ {} on interface '{}'", + irq, getName()); fclose(file); logger->debug("Set affinity of IRQ {} to {} {}", irq, cset_pin.count() == 1 ? "core" : "cores", (std::string)cset_pin); } else - throw SystemError( - "Failed to set affinity for for IRQ {} on interface '{}'", irq, - getName()); + throw SystemError("Failed to set affinity for IRQ {} on interface '{}'", + irq, getName()); } return 0; diff --git a/lib/nodes/amqp.cpp b/lib/nodes/amqp.cpp index 07da7a5a6..4eb7df2d1 100644 --- a/lib/nodes/amqp.cpp +++ b/lib/nodes/amqp.cpp @@ -398,7 +398,7 @@ static NodeCompatType p; __attribute__((constructor(110))) static void register_plugin() { p.name = "amqp"; - p.description = "Advanced Message Queueing Protoocl (rabbitmq-c)"; + p.description = "Advanced Message Queueing Protocol (rabbitmq-c)"; p.vectorize = 0; p.size = sizeof(struct amqp); p.init = amqp_init; diff --git a/lib/nodes/can.cpp b/lib/nodes/can.cpp index 7191f36f5..2f44857f7 100644 --- a/lib/nodes/can.cpp +++ b/lib/nodes/can.cpp @@ -189,7 +189,8 @@ int villas::node::can_start(NodeCompat *n) { if (c->socket < 0) throw SystemError("Error while opening CAN socket"); - strcpy(ifr.ifr_name, c->interface_name); + strncpy(ifr.ifr_name, c->interface_name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; ret = ioctl(c->socket, SIOCGIFINDEX, &ifr); if (ret != 0) diff --git a/lib/nodes/example.cpp b/lib/nodes/example.cpp index 579d659e4..670c3b10d 100644 --- a/lib/nodes/example.cpp +++ b/lib/nodes/example.cpp @@ -165,7 +165,7 @@ class ExampleNode : public Node { // Register node static char n[] = "example"; -static char d[] = "An example for staring new node-type implementations"; +static char d[] = "An example for starting new node-type implementations"; static NodePluginuri ? f->uri : f->uri_tmpl, f->flush ? "yes" : "no", f->skip_lines, - eof_str, epoch_str, time_to_double(&f->epoch)); + strcatf(&buf, + "uri=%s, out.flush=%s, in.skip=%d, in.eof=%s, in.epoch=%s, " + "in.epoch_value=%.2f", + f->uri ? f->uri : f->uri_tmpl, f->flush ? "yes" : "no", f->skip_lines, + eof_str, epoch_str, time_to_double(&f->epoch)); if (f->rate) strcatf(&buf, ", in.rate=%.1f", f->rate); diff --git a/lib/nodes/infiniband.cpp b/lib/nodes/infiniband.cpp index 65f973a4f..ab56d3af9 100644 --- a/lib/nodes/infiniband.cpp +++ b/lib/nodes/infiniband.cpp @@ -320,14 +320,14 @@ int villas::node::ib_parse(NodeCompat *n, json_t *json) { int villas::node::ib_check(NodeCompat *n) { auto *ib = n->getData(); - // Check if read substraction makes sense + // Check if read subtraction makes sense if (ib->conn.buffer_subtraction < 2 * n->in.vectorize) throw RuntimeError( - "The buffer substraction value must be bigger than 2 * in.vectorize"); + "The buffer subtraction value must be bigger than 2 * in.vectorize"); if (ib->conn.buffer_subtraction >= ib->qp_init.cap.max_recv_wr - n->in.vectorize) - throw RuntimeError("The buffer substraction value cannot be bigger than " + throw RuntimeError("The buffer subtraction value cannot be bigger than " "in.max_wrs - in.vectorize"); // Check if the set value is a power of 2, and warn the user if this is not the case @@ -644,7 +644,7 @@ int villas::node::ib_start(NodeCompat *n) { } /* Several events should occur on the event channel, to make - * sure the nodes are succesfully connected. + * sure the nodes are successfully connected. */ n->logger->debug("Starting to monitor events on rdma_cm_id"); @@ -829,12 +829,12 @@ int villas::node::ib_read(NodeCompat *n, struct Sample *const smps[], throw RuntimeError("Was unable to post receive WR: {}, bad WR ID: {:#x}", ret, bad_wr->wr_id); - n->logger->debug("Succesfully posted receive Work Requests"); + n->logger->debug("Successfully posted receive Work Requests"); // Doesn't start if wcs == 0 for (int j = 0; j < wcs; j++) { if (!((wc[j].opcode & IBV_WC_RECV) && wc[j].status == IBV_WC_SUCCESS)) { - // Drop all values, we don't know where the error occured + // Drop all values, we don't know where the error occurred read_values = 0; } @@ -844,9 +844,9 @@ int villas::node::ib_read(NodeCompat *n, struct Sample *const smps[], n->logger->warn("Work Completion status was not IBV_WC_SUCCESS: {}", (int)wc[j].status); - /* 32 byte of meta data is always transferred. We should substract it. + /* 32 byte of meta data is always transferred. We should subtract it. * Furthermore, in case of an unreliable connection, a 40 byte - * global routing header is transferred. This should be substracted as well. + * global routing header is transferred. This should be subtracted as well. */ int correction = (ib->conn.port_space == RDMA_PS_UDP) ? META_GRH_SIZE : META_SIZE; @@ -967,7 +967,7 @@ int villas::node::ib_write(NodeCompat *n, struct Sample *const smps[], * and prepare them to be released */ n->logger->debug( - "Bad WR occured with ID: {:#x} and S/G address: {:p}: {}", + "Bad WR occurred with ID: {:#x} and S/G address: {:p}: {}", bad_wr->wr_id, (void *)bad_wr->sg_list, ret); while (1) { diff --git a/lib/nodes/temper.cpp b/lib/nodes/temper.cpp index 9849657e7..662f2f8ce 100644 --- a/lib/nodes/temper.cpp +++ b/lib/nodes/temper.cpp @@ -388,7 +388,7 @@ int villas::node::temper_read(NodeCompat *n, struct Sample *const smps[], __attribute__((constructor(110))) static void register_plugin() { p.name = "temper"; - p.description = "An temper for staring new node-type implementations"; + p.description = "A template for starting new node-type implementations"; p.vectorize = 1; p.flags = (int)NodeFactory::Flags::PROVIDES_SIGNALS; p.size = sizeof(struct temper); diff --git a/lib/nodes/test_rtt.cpp b/lib/nodes/test_rtt.cpp index efa884330..2959ca6c1 100644 --- a/lib/nodes/test_rtt.cpp +++ b/lib/nodes/test_rtt.cpp @@ -116,17 +116,17 @@ int TestRTT::prepare() { } static enum TestRTT::Mode parseMode(const char *mode_str) { - if (strcmp(mode_str, "min")) + if (strcmp(mode_str, "min") == 0) return TestRTT::Mode::MIN; - else if (strcmp(mode_str, "max")) - return TestRTT::Mode::MIN; - else if (strcmp(mode_str, "stop_after_count")) + else if (strcmp(mode_str, "max") == 0) + return TestRTT::Mode::MAX; + else if (strcmp(mode_str, "stop_after_count") == 0) return TestRTT::Mode::STOP_COUNT; - else if (strcmp(mode_str, "stop_after_duration")) + else if (strcmp(mode_str, "stop_after_duration") == 0) return TestRTT::Mode::STOP_DURATION; - else if (strcmp(mode_str, "at_least_count")) + else if (strcmp(mode_str, "at_least_count") == 0) return TestRTT::Mode::AT_LEAST_COUNT; - else if (strcmp(mode_str, "at_least_duration")) + else if (strcmp(mode_str, "at_least_duration") == 0) return TestRTT::Mode::AT_LEAST_DURATION; else return TestRTT::Mode::UNKNOWN; diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index 0a8aa6b53..bf6b78bb5 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -206,7 +206,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, websocket_connection_close(c, wsi, LWS_CLOSE_STATUS_POLICY_VIOLATION, "Internal error"); c->node->logger->warn( - "Failed to intialize WebSocket connection: reason={}", ret); + "Failed to initialize WebSocket connection: reason={}", ret); return -1; } @@ -230,11 +230,12 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, return -1; - case LWS_CALLBACK_CLOSED: + case LWS_CALLBACK_CLOSED: { + auto old_state = c->state; c->state = websocket_connection::State::CLOSED; c->node->logger->debug("Closed WebSocket connection: {}", c->toString()); - if (c->state != websocket_connection::State::CLOSING) { + if (old_state != websocket_connection::State::CLOSING) { // TODO: Attempt reconnect here } @@ -251,6 +252,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, delete c; break; + } case LWS_CALLBACK_CLIENT_WRITEABLE: case LWS_CALLBACK_SERVER_WRITEABLE: { diff --git a/lib/path.cpp b/lib/path.cpp index a23e63ede..353449005 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -673,7 +673,8 @@ json_t *Path::toJson() const { json_string(pd->node->getNameShort().c_str())); json_t *json_path = json_pack( - "{ s: s, s: s, s: s, s: b, s: b s: b, s: b, s: b, s: b s: i, s: o, s: o, " + "{ s: s, s: s, s: s, s: b, s: b, s: b, s: b, s: b, s: b, s: i, s: o, s: " + "o, " "s: o, s: o }", "uuid", uuid::toString(uuid).c_str(), "state", stateToString(state).c_str(), "mode", mode == Mode::ANY ? "any" : "all", diff --git a/lua/hooks/test.lua b/lua/hooks/test.lua index 9a1fcd765..766c8dc0a 100644 --- a/lua/hooks/test.lua +++ b/lua/hooks/test.lua @@ -15,14 +15,14 @@ Reason = { } SampleFlags = { - HAS_TS_ORIGIN = 1, -- "(1 << 1)" Include origin timestamp in output. - HAS_TS_RECEIVED = 2, -- "(1 << 2)" Include receive timestamp in output. - HAS_OFFSET = 4, -- "(1 << 3)" Include offset (received - origin timestamp) in output. - HAS_SEQUENCE = 8, -- "(1 << 4)" Include sequence number in output. - HAS_DATA = 16, -- "(1 << 5)" Include values in output. - - NEW_FRAME = 65536, -- "(1 << 16)" This sample is the first of a new simulation case - NEW_SIMULATION = 131072, -- "(1 << 16)" This sample is the first of a new simulation case + HAS_TS_ORIGIN = 1, -- "(1 << 0)" Include origin timestamp in output. + HAS_TS_RECEIVED = 2, -- "(1 << 1)" Include receive timestamp in output. + HAS_OFFSET = 4, -- "(1 << 2)" Include offset (received - origin timestamp) in output. + HAS_SEQUENCE = 8, -- "(1 << 3)" Include sequence number in output. + HAS_DATA = 16, -- "(1 << 4)" Include values in output. + + NEW_FRAME = 65536, -- "(1 << 16)" This sample is the first of a new frame + NEW_SIMULATION = 131072, -- "(1 << 17)" This sample is the first of a new simulation case ALL = 2147483647, -- "INT_MAX" Enable all output options. } diff --git a/packaging/deps.sh b/packaging/deps.sh index d3270a27a..c11ab556a 100644 --- a/packaging/deps.sh +++ b/packaging/deps.sh @@ -23,7 +23,7 @@ should_build() { optional) ;; required) ;; *) - echo >&2 "Error: invalid parameter '$2' for should_build. should be one of 'optional' and 'required', default is 'optional'" + echo >&2 "Error: invalid parameter '$3' for should_build. should be one of 'optional' and 'required', default is 'optional'" exit 1 ;; esac @@ -31,7 +31,7 @@ should_build() { local deps="${@:4}" if [[ -n "${DEPS_SCAN+x}" ]]; then - echo "${requirement} dependendency ${id} should be installed ${use}." + echo "${requirement} dependency ${id} should be installed ${use}." [[ -n "${deps[*]}" ]] && echo " transitive dependencies: ${deps}" echo return 1 @@ -45,7 +45,7 @@ should_build() { if [[ -z "${DEPS_NONINTERACTIVE+x}" ]] && [[ -t 1 ]]; then echo - read -p "Do you wan't to install '${id}' into '${PREFIX}'? This is used ${use}. (y/N) " + read -p "Do you want to install '${id}' into '${PREFIX}'? This is used ${use}. (y/N) " case "${REPLY}" in y | Y) echo "Installing '${id}'" diff --git a/python/villas/node/communicate.py b/python/villas/node/communicate.py index f01a05146..df6b92053 100644 --- a/python/villas/node/communicate.py +++ b/python/villas/node/communicate.py @@ -67,17 +67,21 @@ def communicate( send_cb: SendCallback | None = None, wait: bool = True, ): + rt = None if recv_cb is not None: rt = RecvThread(recv_cb) rt.start() + st = None if send_cb is not None: st = SendThread(send_cb, rate) st.start() if wait: try: - rt.join() - st.join() + if rt is not None: + rt.join() + if st is not None: + st.join() except KeyboardInterrupt: logger.info("Received Ctrl+C. Stopping send/recv threads") diff --git a/python/villas/node/formats.py b/python/villas/node/formats.py index c5e7b355a..5596f6a47 100644 --- a/python/villas/node/formats.py +++ b/python/villas/node/formats.py @@ -120,7 +120,7 @@ def loads(self, s: str) -> list[Sample]: Load samples from a string. """ - s.strip(self.separator + self.delimiter) + s = s.strip(self.separator + self.delimiter) sample_strs = s.split(sep=self.delimiter) samples = (self.load_sample(sample) for sample in sample_strs) return [s for s in samples if s is not None] diff --git a/python/villas/node/node.py b/python/villas/node/node.py index e17740dd1..c8eb9510a 100644 --- a/python/villas/node/node.py +++ b/python/villas/node/node.py @@ -25,13 +25,14 @@ def __init__( api_url=None, log_filename=None, config_filename=None, - config={}, + config=None, executable="villas-node", **kwargs, ): self.api_url = api_url self.log_filename = log_filename self.executable = executable + self.child = None if config_filename and config: raise RuntimeError( @@ -42,11 +43,11 @@ def __init__( with open(config_filename) as f: self.config = json.load(f) else: - self.config = config + self.config = config if config is not None else {} # Try to deduct api_url from config if self.api_url is None: - port = config.get("http", {}).get("port") + port = self.config.get("http", {}).get("port") if port is None: port = 80 if os.getuid() == 0 else 8080 diff --git a/python/villas/node/test_formats.py b/python/villas/node/test_formats.py index 366281a24..b422f40fe 100644 --- a/python/villas/node/test_formats.py +++ b/python/villas/node/test_formats.py @@ -6,7 +6,7 @@ from cmath import sqrt -from villas.node.formats import SignalList, VillasHuman, Protobuf +from villas.node.formats import Protobuf, SignalList, VillasHuman from villas.node.sample import Sample, Timestamp diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index 24e33d33f..79e743036 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -1,4 +1,4 @@ -/* Receive messages from server snd print them on stdout. +/* Receive messages from server and print them on stdout. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University @@ -199,7 +199,7 @@ class Hook : public Tool { ret = pool_init(&p, 10 * cnt, SAMPLE_LENGTH(DEFAULT_SAMPLE_LENGTH)); if (ret) - throw RuntimeError("Failed to initilize memory pool"); + throw RuntimeError("Failed to initialize memory pool"); // Initialize IO struct desc { diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index ca800d7a5..ef293b32a 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -1,4 +1,4 @@ -/* Receive messages from server snd print them on stdout. +/* Receive messages from server and print them on stdout. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University @@ -447,7 +447,7 @@ class Pipe : public Tool { ret = node->getFactory()->start(&sn); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", + throw RuntimeError("Failed to initialize node type {}: reason={}", node->getFactory()->getName(), ret); sn.startInterfaces(); diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index f5161cf73..1eeeb4b3d 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -80,6 +80,13 @@ class Signal : public Tool { << std::endl << " -o OFF the DC bias" << std::endl << " -l NUM only send LIMIT messages and stop" << std::endl + << " -p FLT the phase of the signal" << std::endl + << " -w FLT the pulse width (for 'square'/'pulse' signals)" + << std::endl + << " -L FLT the low level (for 'square'/'pulse' signals)" + << std::endl + << " -H FLT the high level (for 'square'/'pulse' signals)" + << std::endl << std::endl; printCopyright(); @@ -105,7 +112,7 @@ class Signal : public Tool { // Parse optional command line arguments int c; char *endptr; - while ((c = getopt(argc, argv, "v:r:F:f:l:a:D:no:d:hVp:")) != -1) { + while ((c = getopt(argc, argv, "v:r:F:f:l:a:D:no:d:hVp:w:L:H:")) != -1) { switch (c) { case 'n': rt = 0; @@ -241,7 +248,7 @@ class Signal : public Tool { ret = node->getFactory()->start(nullptr); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", + throw RuntimeError("Failed to initialize node type {}: reason={}", node->getFactory()->getName(), ret); ret = node->check(); @@ -295,7 +302,7 @@ class Signal : public Tool { ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to de-intialize node type {}: reason={}", + throw RuntimeError("Failed to de-initialize node type {}: reason={}", node->getFactory()->getName(), ret); delete node; diff --git a/src/villas-test-config.cpp b/src/villas-test-config.cpp index 5b0dc8557..c1933fb07 100644 --- a/src/villas-test-config.cpp +++ b/src/villas-test-config.cpp @@ -50,7 +50,7 @@ class TestConfig : public Tool { << std::endl << " -d LVL set debug level" << std::endl << " -V show version and exit" << std::endl - << " -c perform plausability checks on config" + << " -c perform plausibility checks on config" << std::endl << " -D dump config in JSON format" << std::endl << " -h show usage and exit" << std::endl @@ -61,12 +61,16 @@ class TestConfig : public Tool { void parse() override { int c; - while ((c = getopt(argc, argv, "hcVD")) != -1) { + while ((c = getopt(argc, argv, "hcVDd:")) != -1) { switch (c) { case 'c': check = true; break; + case 'd': + Log::getInstance().setLevel(optarg); + break; + case 'D': dump = true; break; diff --git a/tools/format-all.sh b/tools/format-all.sh index 0d90f377f..9c16d7ad0 100755 --- a/tools/format-all.sh +++ b/tools/format-all.sh @@ -6,5 +6,5 @@ # SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University # SPDX-License-Identifier: Apache-2.0 -git ls-files -c -z -- "*.c" ".h" "*.hpp" "*.cpp" ":!:fpga/thirdparty" |\ +git ls-files -c -z -- "*.c" "*.h" "*.hpp" "*.cpp" ":!:fpga/thirdparty" |\ xargs -0 clang-format --verbose -i diff --git a/tools/git-pre-commit-hook.sh b/tools/git-pre-commit-hook.sh index f6237b56a..fbfe8934c 100755 --- a/tools/git-pre-commit-hook.sh +++ b/tools/git-pre-commit-hook.sh @@ -8,12 +8,13 @@ format_file() { FILE="${1}" - if [ -f ${FILE} ]; then - if ! clang-format --Werror --dry-run ${FILE}; then - clang-format -i ${FILE} + if [ -f "${FILE}" ]; then + if ! clang-format --Werror --dry-run "${FILE}"; then + clang-format -i "${FILE}" return 1 fi fi + return 0 } case "${1}" in @@ -37,7 +38,7 @@ case "${1}" in if (( ${CHANGES} > 0 )); then echo "Formatting of ${CHANGES} files has been fixed. Please stage and commit again." - exit -1 + exit 1 fi ;; esac diff --git a/tools/hwdef-parse.py b/tools/hwdef-parse.py index b3ca7c7ec..bb5f8e9ce 100755 --- a/tools/hwdef-parse.py +++ b/tools/hwdef-parse.py @@ -6,7 +6,7 @@ Author: Daniel Krebs Author: Hatim Kanchwala Author: Pascal Bauer -Author: Niklas Eiling SPDX-FileCopyrightText: 2017-2022 Steffen Vogel SPDX-FileCopyrightText: 2017-2022 Daniel Krebs SPDX-FileCopyrightText: 2017-2022 Hatim Kanchwala @@ -63,7 +63,7 @@ ["acs.eonerc.rwth-aachen.de", "sysgen"], ] -# List of VLNI ids of AXI4-Stream infrastructure IP cores +# List of VLNV ids of AXI4-Stream infrastructure IP cores # which do not alter data see # PG085 (AXI4-Stream Infrastructure IP Suite v2.2) axi_converter_whitelist = [ @@ -71,7 +71,6 @@ ["xilinx.com", "ip", "axis_clock_converter"], ["xilinx.com", "ip", "axis_register_slice"], ["xilinx.com", "ip", "axis_dwidth_converter"], - ["xilinx.com", "ip", "axis_register_slice"], ["xilinx.com", "ip", "axis_data_fifo"], ["xilinx.com", "ip", "floating_point"], ["xilinx.com", "module_ref", "prepend_seqnum"], @@ -160,7 +159,7 @@ def sanitize_name(name): instance = module.get("INSTANCE") vlnv = module.get("VLNV") - # Ignroing unkown + # Ignoring IPs not present in the whitelist if not vlnv_match(vlnv, whitelist): continue diff --git a/tools/integration-tests.sh b/tools/integration-tests.sh index d1d531f1f..b267a9459 100755 --- a/tools/integration-tests.sh +++ b/tools/integration-tests.sh @@ -59,7 +59,7 @@ export NUM_SAMPLES TESTS=${SRCDIR}/tests/integration/${FILTER}.sh -# Preperations +# Preparations mkdir -p ${LOGDIR} PASSED=0 @@ -105,7 +105,7 @@ for TEST in ${TESTS}; do SKIPPED=$((${SKIPPED} + 1)) ;; 124) - echo -e "\e[33m[TIME] \e[39m ${TESTNAME} (ran for more then ${TIMEOUT})" + echo -e "\e[33m[TIME] \e[39m ${TESTNAME} (ran for more than ${TIMEOUT})" TIMEDOUT=$((${TIMEDOUT} + 1)) FAILED=$((${FAILED} + 1)) ;; diff --git a/tools/tc-netem.sh b/tools/tc-netem.sh index b8241feda..2a734b3c1 100755 --- a/tools/tc-netem.sh +++ b/tools/tc-netem.sh @@ -9,7 +9,7 @@ # SPDX-License-Identifier: Apache-2.0 set -e # Abort on error -die() { echo "$1"; exit -1; } +die() { echo "$1"; exit 1; } # Apply netem qdisc also for reverse path REVERSE=0 @@ -75,7 +75,7 @@ if (( $REVERSE )); then $NF -t nat -I PREROUTING $FILTER_REV -j mark --mark-set 124 --mark-target CONTINUE $NF -t nat -I PREROUTING $FILTER_REV -j dnat --to-dst $SRC --dnat-target CONTINUE - $NF -t nat -I POSTROUTING --mark 123 -j snat --to-src $MY + $NF -t nat -I POSTROUTING --mark 124 -j snat --to-src $MY # Add classful qdisc to egress (outgoing) network device $TC qdisc replace dev $SRC_IF root handle 4000 prio bands 4 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 @@ -92,7 +92,7 @@ if (( $REVERSE )); then fi # Some debug and status output -if [ -n $DEBUG ]; then +if [ -n "$DEBUG" ]; then if [ "$SRC_IF" == "$DST_IF" ]; then IFNS="$SRC_IF" else @@ -101,7 +101,7 @@ if [ -n $DEBUG ]; then for inf in $IFNS; do for cmd in qdisc filter class; do - echo -e "\nTC ==> $if: $cmd" + echo -e "\nTC ==> $inf: $cmd" tc -d -p $cmd show dev $inf done done diff --git a/tools/tc-netem2.sh b/tools/tc-netem2.sh index e4f59592c..cb08a23d6 100755 --- a/tools/tc-netem2.sh +++ b/tools/tc-netem2.sh @@ -56,8 +56,6 @@ modprobe sch_netem || die "The netem qdisc is not compiled in this kernel!" $NF -t nat -F $NF -t nat -X -exit - # Add new chain, mark packets from $SRC and redirect them to $DEST # Insert new chain into flow @@ -67,8 +65,6 @@ $NF -t nat -A PREROUTING -i $SRC_IF -s $SRC -j dnat --to-dst $DST --dnat-target $NF -t nat -A PREROUTING -i $DST_IF -s $DST -j mark --mark-set $MARK --mark-target CONTINUE $NF -t nat -A PREROUTING -i $DST_IF -s $DST -j dnat --to-dst $SRC --dnat-target ACCEPT -exit - # Clean traffic control $TC qdisc delete dev $DST_IF root || true @@ -86,7 +82,7 @@ if (( $REVERSE )); then echo -e " $NETEM_REV" fi -if [ -n $DEBUG ]; then +if [ -n "$DEBUG" ]; then if [ "$SRC_IF" == "$DST_IF" ]; then IFNS="$SRC_IF" else @@ -95,7 +91,7 @@ if [ -n $DEBUG ]; then for inf in $IFNS; do for cmd in qdisc filter class; do - echo -e "\nTC ==> $if: $cmd" + echo -e "\nTC ==> $inf: $cmd" tc -d -p $cmd show dev $inf done done diff --git a/tools/villas-api.sh b/tools/villas-api.sh index 82c9543ac..20a5f1623 100755 --- a/tools/villas-api.sh +++ b/tools/villas-api.sh @@ -21,13 +21,25 @@ fi ACTION=$1 REQUEST=${2:-\{\}} -ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) -ENDPOINT=${ENDPOINT:-http://localhost:80/api/v1} +ENDPOINT=${ENDPOINT:-http://localhost:8080/api/v2} -echo "Issuing API request: action=${ACTION}, id=${ID}, request=${REQUEST}, endpoint=${ENDPOINT}" +# GET actions have no body; actions carrying a request body use POST +case "${ACTION}" in + status|capabilities|config|nodes|paths) + METHOD=GET + ;; + *) + METHOD=POST + ;; +esac -curl -s -X POST --data "{ - \"action\" : \"${ACTION}\", - \"id\": \"${ID}\", - \"request\": ${REQUEST} -}" ${ENDPOINT} | jq . +echo "Issuing API request: ${METHOD} ${ENDPOINT}/${ACTION}, request=${REQUEST}" + +if [ "${METHOD}" = "GET" ]; then + curl -s "${ENDPOINT}/${ACTION}" | jq . +else + curl -s -X POST \ + -H "Content-Type: application/json" \ + --data "${REQUEST}" \ + "${ENDPOINT}/${ACTION}" | jq . +fi diff --git a/tools/villas-helper.sh b/tools/villas-helper.sh index bd1867e5d..a9b781659 100755 --- a/tools/villas-helper.sh +++ b/tools/villas-helper.sh @@ -35,5 +35,5 @@ function colorize() { function villas() { VILLAS_LOG_PREFIX=${VILLAS_LOG_PREFIX:-$(colorize "[$1-$((${RANDOM} % 100))} ")} \ - command villas $@ + command villas "$@" }