Skip to content

Commit

Permalink
Update all dep (#593)
Browse files Browse the repository at this point in the history
* updating dependencies

* test publishing testing results

* try to fix flaky test

* fix segfault caused by indexing non set optional in glaze caused by us
  • Loading branch information
jbbjarnason authored Jun 26, 2024
1 parent a7cbd5e commit fb28ecd
Show file tree
Hide file tree
Showing 94 changed files with 5,719 additions and 225 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ jobs:
matrix:
presets: [ gcc-debug, gcc-release, clang-debug, clang-release, gcc-debug-dynamic, clang-debug-dynamic ]

# permissions to publish test results
permissions:
contents: read
issues: read
checks: write
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -58,3 +65,10 @@ jobs:
configurePreset: '${{ matrix.presets }}'
buildPreset: '${{ matrix.presets }}'
testPreset: '${{ matrix.presets }}'

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
*/**/test-results.xml
2 changes: 1 addition & 1 deletion cmake
2 changes: 1 addition & 1 deletion exes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ add_subdirectory(tfcctl)
add_subdirectory(ipc-ruler)
add_subdirectory(signal_source)
add_subdirectory(mqtt-bridge)
add_subdirectory(themis)
add_subdirectory(themis)
2 changes: 1 addition & 1 deletion exes/ethercat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_libraries(ec
tfc::soem_interface
tfc::stx
tfc::motor
mp-units::si
mp-units::systems
fmt::fmt
)

Expand Down
2 changes: 1 addition & 1 deletion exes/ethercat/inc/public/tfc/ec/devices/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <utility>

#include <fmt/format.h>
#include <mp-units/bits/quantity_concepts.h>
#include <mp-units/framework/quantity_concepts.h>

#include <tfc/ec/soem_interface.hpp>
#include <tfc/logger.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cstdint>
#include <string>

#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>
#include <mp-units/systems/si/units.h>
#include <glaze/util/string_literal.hpp>

Expand Down
2 changes: 1 addition & 1 deletion exes/ethercat/inc/public/tfc/ec/devices/eilersen/4x60a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <span>
#include <variant>

#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>
#include <boost/asio/io_context.hpp>

#include <tfc/confman/observable.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <mp-units/math.h>
#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>
#include <algorithm>
#include <memory>
#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <string>

#include <mp-units/chrono.h>
#include <mp-units/format.h>
#include <mp-units/quantity.h>
#include <mp-units/framework/quantity.h>
#include <mp-units/systems/si/chrono.h>
#include <boost/asio.hpp>
#include <boost/asio/experimental/parallel_group.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>

#include <tfc/ec/devices/schneider/atv320/enums.hpp>
#include <tfc/ec/devices/util.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <mp-units/math.h>
#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>

namespace tfc::ec::devices::schneider::atv320::detail {

Expand Down
4 changes: 2 additions & 2 deletions exes/ethercat/inc/public/tfc/ec/devices/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include <glaze/glaze.hpp>

#include <mp-units/bits/quantity_concepts.h>
#include <mp-units/bits/value_cast.h>
#include <mp-units/framework/quantity_concepts.h>
#include <mp-units/framework/value_cast.h>
#include <tfc/ec/soem_interface.hpp>
#include <tfc/stx/basic_fixed_string.hpp>
#include <tfc/stx/string_view_join.hpp>
Expand Down
6 changes: 3 additions & 3 deletions exes/ethercat/tests/test_ec_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstdint>
#include <type_traits>

#include <mp-units/systems/si/si.h>
#include <mp-units/systems/si.h>
#include <boost/ut.hpp>
#include <tfc/ec/devices/schneider/atv320.hpp>
#include <tfc/ec/devices/util.hpp>
Expand Down Expand Up @@ -49,8 +49,8 @@ auto main(int, char**) -> int {
"setting to json"_test = []() {
[[maybe_unused]] example::trivial_type_setting const test{};
auto const json = glz::write_json(test);
expect(json == "13") << "got: " << json;
auto const exp = glz::read_json<example::trivial_type_setting>(json);
expect(json == "13") << "got: " << json.value_or("");
auto const exp = glz::read_json<example::trivial_type_setting>(json.value_or(""));
expect(exp.has_value() >> fatal);
expect(exp.value() == test);
};
Expand Down
20 changes: 10 additions & 10 deletions exes/gpio/src/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void gpio::pin_direction_change(pin_index_t idx,
gpiod::line::direction new_value,
[[maybe_unused]] gpiod::line::direction old_value) noexcept {
try {
logger_.trace(R"(Got new direction change with new value: "{}", old value: "{}")", glz::write_json(new_value),
glz::write_json(old_value));
logger_.trace(R"(Got new direction change with new value: "{}", old value: "{}")",
glz::write_json(new_value).value_or(""), glz::write_json(old_value).value_or(""));
if (new_value == gpiod::line::direction::OUTPUT) {
pins_.at(idx).emplace<ipc_input_t>(ctx_, manager_client_, fmt::format("in.{}", idx),
std::bind_front(&gpio::ipc_event, this, idx));
Expand Down Expand Up @@ -46,8 +46,8 @@ void gpio::pin_direction_change(pin_index_t idx,
void gpio::pin_edge_change(pin_index_t idx,
gpiod::line::edge new_value,
[[maybe_unused]] gpiod::line::edge old_value) noexcept {
logger_.trace(R"(Got new edge change with new value: "{}", old value: "{}")", glz::write_json(new_value),
glz::write_json(old_value));
logger_.trace(R"(Got new edge change with new value: "{}", old value: "{}")", glz::write_json(new_value).value_or(""),
glz::write_json(old_value).value_or(""));
auto settings{ chip_.prepare_request().get_line_config().get_line_settings().at(idx) };
settings.set_edge_detection(new_value);
chip_.prepare_request().add_line_settings(idx, settings);
Expand All @@ -60,17 +60,17 @@ void gpio::pin_edge_change(pin_index_t idx,
void gpio::pin_bias_change(pin_index_t idx,
gpiod::line::bias new_value,
[[maybe_unused]] gpiod::line::bias old_value) noexcept {
logger_.trace(R"(Got new bias change with new value: "{}", old value: "{}")", glz::write_json(new_value),
glz::write_json(old_value));
logger_.trace(R"(Got new bias change with new value: "{}", old value: "{}")", glz::write_json(new_value).value_or(""),
glz::write_json(old_value).value_or(""));
auto settings{ chip_.prepare_request().get_line_config().get_line_settings().at(idx) };
settings.set_bias(new_value);
chip_.prepare_request().add_line_settings(idx, settings).do_request();
}
void gpio::pin_force_change(pin_index_t idx,
pin::out::force_e new_value,
[[maybe_unused]] pin::out::force_e old_value) noexcept {
logger_.trace(R"(Got new force change with new value: "{}", old value: "{}")", glz::write_json(new_value),
glz::write_json(old_value));
logger_.trace(R"(Got new force change with new value: "{}", old value: "{}")", glz::write_json(new_value).value_or(""),
glz::write_json(old_value).value_or(""));
auto settings{ chip_.prepare_request().get_line_config().get_line_settings().at(idx) };
switch (new_value) {
using enum pin::out::force_e;
Expand Down Expand Up @@ -104,8 +104,8 @@ void gpio::pin_force_change(pin_index_t idx,
void gpio::pin_drive_change(pin_index_t idx,
gpiod::line::drive new_value,
[[maybe_unused]] gpiod::line::drive old_value) noexcept {
logger_.trace(R"(Got new drive change with new value: "{}", old value: "{}")", glz::write_json(new_value),
glz::write_json(old_value));
logger_.trace(R"(Got new drive change with new value: "{}", old value: "{}")", glz::write_json(new_value).value_or(""),
glz::write_json(old_value).value_or(""));
auto settings{ chip_.prepare_request().get_line_config().get_line_settings().at(idx) };
settings.set_drive(new_value);
chip_.prepare_request().add_line_settings(idx, settings).do_request();
Expand Down
57 changes: 27 additions & 30 deletions exes/mqtt-bridge/inc/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <tuple>

#include <async_mqtt/all.hpp>
#include <async_mqtt/buffer.hpp>
#include <async_mqtt/error.hpp>
#include <boost/asio.hpp>

#include <tfc/logger.hpp>
Expand Down Expand Up @@ -67,7 +67,7 @@ class client {

logger_.trace("Sending MQTT connection packet...");

auto send_error = co_await endpoint_client_->send(connect_packet(), asio::use_awaitable);
auto [send_error] = co_await endpoint_client_->send(connect_packet(), as_tuple(asio::use_awaitable));

if (send_error) {
co_return false;
Expand Down Expand Up @@ -102,10 +102,10 @@ class client {
p_id = 0;
}

auto pub_packet = async_mqtt::v5::publish_packet{ p_id.value(), async_mqtt::allocate_buffer(topic),
async_mqtt::allocate_buffer(payload), qos };
auto pub_packet = async_mqtt::v5::publish_packet{ p_id.value(), topic, payload, qos };

co_return !(co_await endpoint_client_->send(pub_packet, asio::use_awaitable));
auto [error] = co_await endpoint_client_->send(pub_packet, as_tuple(asio::use_awaitable));
co_return !error;
}

auto subscribe_to_topic(std::string topic) -> asio::awaitable<bool> {
Expand All @@ -116,13 +116,11 @@ class client {

p_id = endpoint_client_->acquire_unique_packet_id();

std::string_view topic_view{ topic };
auto sub_packet =
async_mqtt::v5::subscribe_packet{ p_id.value(),
{ { topic, async_mqtt::qos::at_most_once | async_mqtt::sub::nl::yes } } };

auto sub_packet = async_mqtt::v5::subscribe_packet{
p_id.value(), { { async_mqtt::buffer(topic_view), async_mqtt::qos::at_most_once | async_mqtt::sub::nl::yes } }
};

auto send_error = co_await endpoint_client_->send(sub_packet, asio::use_awaitable);
auto [send_error] = co_await endpoint_client_->send(sub_packet, as_tuple(asio::use_awaitable));

if (send_error) {
co_return !send_error;
Expand All @@ -145,7 +143,7 @@ class client {
for (auto const& entry : suback_packet.entries()) {
if (entry != async_mqtt::suback_reason_code::granted_qos_0) {
logger_.error("Error subscribing to topic: {}, reason code: {}", topic.data(),
async_mqtt::suback_reason_code_to_str(entry));
async_mqtt::suback_reason_code_to_string(entry));
co_return false;
}
}
Expand Down Expand Up @@ -173,13 +171,13 @@ class client {

logger_.trace("Received PUBLISH packet. Parsing payload...");

for (uint64_t i = 0; i < publish_packet->payload().size(); i++) {
process_payload(publish_packet->payload()[i], *publish_packet);
for (auto const& itm : publish_packet->payload_as_buffer()) {
process_payload(itm, *publish_packet);
}
}
}

auto strand() -> asio::strand<asio::any_io_executor> { return endpoint_client_->strand(); }
auto get_executor() const -> asio::any_io_executor { return endpoint_client_->get_executor(); }

auto set_initial_message(std::string const& topic, std::string const& payload, async_mqtt::qos const& qos) -> void {
initial_message_ = std::tuple<std::string, std::string, async_mqtt::qos>{ topic, payload, qos };
Expand All @@ -195,26 +193,25 @@ class client {

auto connect_packet() -> async_mqtt::v5::connect_packet {
if (config_.value().username.empty() || config_.value().password.empty()) {
return async_mqtt::v5::connect_packet{ true,
std::chrono::seconds(100).count(),
async_mqtt::allocate_buffer(config_.value().client_id),
async_mqtt::will(
async_mqtt::allocate_buffer(mqtt_will_topic_),
async_mqtt::buffer(std::string_view{ mqtt_will_payload_ }),
{ async_mqtt::qos::at_least_once | async_mqtt::pub::retain::no }),
async_mqtt::nullopt,
async_mqtt::nullopt,
{ async_mqtt::property::session_expiry_interval{ 0 } } };
return async_mqtt::v5::connect_packet{
true,
std::chrono::seconds(100).count(),
config_.value().client_id,
async_mqtt::will(mqtt_will_topic_, async_mqtt::buffer(std::string_view{ mqtt_will_payload_ }),
{ async_mqtt::qos::at_least_once | async_mqtt::pub::retain::no }),
std::nullopt,
std::nullopt,
{ async_mqtt::property::session_expiry_interval{ 0 } }
};
}
return async_mqtt::v5::connect_packet{ true,
std::chrono::seconds(100).count(),
async_mqtt::allocate_buffer(config_.value().client_id),
config_.value().client_id,
async_mqtt::will(
async_mqtt::allocate_buffer(mqtt_will_topic_),
async_mqtt::buffer(std::string_view{ mqtt_will_payload_ }),
mqtt_will_topic_, async_mqtt::buffer(std::string_view{ mqtt_will_payload_ }),
{ async_mqtt::qos::at_least_once | async_mqtt::pub::retain::no }),
async_mqtt::allocate_buffer(config_.value().username),
async_mqtt::allocate_buffer(config_.value().password),
config_.value().username,
config_.value().password,
{ async_mqtt::property::session_expiry_interval{ 0 } } };
}

Expand Down
22 changes: 12 additions & 10 deletions exes/mqtt-bridge/inc/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#include <utility>

#include <openssl/ssl.h>
#include <async_mqtt/all.hpp>
#include <async_mqtt/endpoint.hpp>
#include <async_mqtt/packet/control_packet_type.hpp>
#include <async_mqtt/predefined_underlying_layer.hpp>
#include <async_mqtt/predefined_layer/mqtt.hpp>
#include <async_mqtt/predefined_layer/mqtts.hpp>
#include <async_mqtt/protocol_version.hpp>

#include <boost/asio.hpp>
Expand All @@ -35,34 +37,34 @@ class endpoint_client {
}
}

auto strand() -> asio::strand<asio::any_io_executor> {
auto get_executor() const -> asio::any_io_executor {
if (mqtts_client_) {
return mqtts_client_->strand();
return mqtts_client_->get_executor();
}
return mqtt_client_->strand();
return mqtt_client_->get_executor();
}

auto recv(async_mqtt::control_packet_type packet_t) {
if (mqtts_client_) {
return mqtts_client_->recv(async_mqtt::filter::match, { packet_t }, asio::use_awaitable);
return mqtts_client_->async_recv(async_mqtt::filter::match, { packet_t }, asio::use_awaitable);
}
return mqtt_client_->recv(async_mqtt::filter::match, { packet_t }, asio::use_awaitable);
return mqtt_client_->async_recv(async_mqtt::filter::match, { packet_t }, asio::use_awaitable);
}

template <typename... args_t>
auto send(args_t&&... args) {
if (mqtts_client_) {
return mqtts_client_->send(std::forward<decltype(args)>(args)...);
return mqtts_client_->async_send(std::forward<decltype(args)>(args)...);
}
return mqtt_client_->send(std::forward<decltype(args)>(args)...);
return mqtt_client_->async_send(std::forward<decltype(args)>(args)...);
}

template <typename... args_t>
auto close(args_t&&... args) {
if (mqtts_client_) {
return mqtts_client_->close(std::forward<decltype(args)>(args)...);
return mqtts_client_->async_close(std::forward<decltype(args)>(args)...);
}
return mqtt_client_->close(std::forward<decltype(args)>(args)...);
return mqtt_client_->async_close(std::forward<decltype(args)>(args)...);
}

auto acquire_unique_packet_id() {
Expand Down
5 changes: 3 additions & 2 deletions exes/mqtt-bridge/inc/run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class run {
bool restart_needed = false;

co_spawn(
sp_interface_.strand(),
sp_interface_.get_executor(),
sp_interface_.wait_for_payloads(std::bind_front(&spark_plug::process_payload, &sp_interface_), restart_needed),
bind_cancellation_slot(cancel_signal.slot(), asio::detached));

io_ctx_.run_for(std::chrono::seconds{ 1 });

while (!restart_needed) {
co_await asio::steady_timer{ sp_interface_.strand(), std::chrono::seconds{ 5 } }.async_wait(asio::use_awaitable);
co_await asio::steady_timer{ sp_interface_.get_executor(), std::chrono::seconds{ 5 } }.async_wait(
asio::use_awaitable);
}

cancel_signal.emit(asio::cancellation_type::all);
Expand Down
Loading

0 comments on commit fb28ecd

Please sign in to comment.