From 730db713439cfb8be2c8e8ef9b64d32c398025fd Mon Sep 17 00:00:00 2001 From: Ryan howard Date: Mon, 1 Jul 2024 12:45:10 -0400 Subject: [PATCH] format lint --- include/can/core/ids.hpp | 2 +- include/motor-control/core/motor_messages.hpp | 2 ++ .../stepper_motor/motor_interrupt_handler.hpp | 15 ++++++--------- .../sensors/core/sensor_hardware_interface.hpp | 12 +++++------- .../sensors/core/tasks/pressure_sensor_task.hpp | 4 ++-- include/sensors/firmware/sensor_hardware.hpp | 1 - include/sensors/tests/mock_hardware.hpp | 7 +++++-- sensors/tests/test_sensor_hardware.cpp | 5 ++--- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/can/core/ids.hpp b/include/can/core/ids.hpp index 66a1ac2e3..50232ad3f 100644 --- a/include/can/core/ids.hpp +++ b/include/can/core/ids.hpp @@ -215,7 +215,7 @@ enum class SensorOutputBinding { sync = 0x1, report = 0x2, max_threshold_sync = 0x4, - auto_baseline_report = 0x8, + auto_baseline_report = 0x08, multi_sensor_sync = 0x10, }; diff --git a/include/motor-control/core/motor_messages.hpp b/include/motor-control/core/motor_messages.hpp index 0f77c5dc7..62035d439 100644 --- a/include/motor-control/core/motor_messages.hpp +++ b/include/motor-control/core/motor_messages.hpp @@ -91,6 +91,7 @@ struct SensorSyncMove { // NOLINT(cppcoreguidelines-pro-type-member-init) uint16_t usage_key; can::ids::SensorId sensor_id; can::ids::SensorType sensor_type; + uint8_t binding_flags; auto build_ack(uint32_t position, int32_t pulses, uint8_t flags, AckMessageId _id) -> Ack { @@ -121,6 +122,7 @@ struct GearMotorMove // NOLINT(cppcoreguidelines-pro-type-member-init) can::ids::GearMotorId gear_motor_id; can::ids::SensorId sensor_id; can::ids::SensorType sensor_type; + uint8_t binding_flags; auto build_ack(uint32_t position, int32_t pulses, uint8_t flags, AckMessageId _id) -> GearMotorAck { return GearMotorAck{message_index, group_id, diff --git a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp index f79bd79c5..5196a7f2d 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -408,20 +408,17 @@ class MotorInterruptHandler { hardware.get_encoder_pulses(); #ifdef USE_SENSOR_MOVE if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) { - auto binding = - static_cast(can::ids::SensorOutputBinding::sync) | - static_cast( - can::ids::SensorOutputBinding::report) | - static_cast( - can::ids::SensorOutputBinding::auto_baseline_report); if (buffered_move.sensor_id == can::ids::SensorId::BOTH) { send_bind_message(buffered_move.sensor_type, - can::ids::SensorId::S0, binding); + can::ids::SensorId::S0, + buffered_move.binding_flags); send_bind_message(buffered_move.sensor_type, - can::ids::SensorId::S1, binding); + can::ids::SensorId::S1, + buffered_move.binding_flags); } else { send_bind_message(buffered_move.sensor_type, - buffered_move.sensor_id, binding); + buffered_move.sensor_id, + buffered_move.binding_flags); } } #endif diff --git a/include/sensors/core/sensor_hardware_interface.hpp b/include/sensors/core/sensor_hardware_interface.hpp index 0718889b8..ef432a77a 100644 --- a/include/sensors/core/sensor_hardware_interface.hpp +++ b/include/sensors/core/sensor_hardware_interface.hpp @@ -56,35 +56,32 @@ class SensorHardwareBase { virtual auto check_tip_presence() -> bool = 0; auto mask_satisfied() -> bool { - if (set_sync_required_mask != static_cast(SensorIdBitMask::UNUSED)) { + if (set_sync_required_mask != + static_cast(SensorIdBitMask::UNUSED)) { // if anything is "required" only sync when they are all triggered - return (sync_state_mask & set_sync_required_mask) == set_sync_required_mask; + return (sync_state_mask & set_sync_required_mask) == + set_sync_required_mask; } return sync_state_mask & set_sync_enabled_mask; } auto set_sync(can::ids::SensorId sensor) -> void { - printf("Set sync sensor called\n"); // force the bit for this sensor to 1 sync_state_mask |= get_mask_from_id(sensor); if (mask_satisfied()) { - printf("satisfied calling sync\n"); set_sync(); } } auto reset_sync(can::ids::SensorId sensor) -> void { // force the bit for this sensor to 0 - printf("reset sync sensor called\n"); sync_state_mask &= 0xFF ^ get_mask_from_id(sensor); if (!mask_satisfied()) { - printf("No longer satisfied calling reset\n"); reset_sync(); } } auto set_sync_enabled(can::ids::SensorId sensor, bool enabled) -> void { - printf("Set sync required called %d\n", enabled); uint8_t applied_mask = get_mask_from_id(sensor); if (!enabled) { // force enabled bit to 0 @@ -117,6 +114,7 @@ class SensorHardwareBase { reset_sync(); } } + private: uint8_t set_sync_required_mask = 0x00; uint8_t set_sync_enabled_mask = 0x00; diff --git a/include/sensors/core/tasks/pressure_sensor_task.hpp b/include/sensors/core/tasks/pressure_sensor_task.hpp index af9bf9f05..7c0d72023 100644 --- a/include/sensors/core/tasks/pressure_sensor_task.hpp +++ b/include/sensors/core/tasks/pressure_sensor_task.hpp @@ -131,8 +131,8 @@ class PressureMessageHandler { m.binding & static_cast(can::ids::SensorOutputBinding::report)); driver.set_multi_sensor_sync( - m.binding & - static_cast(can::ids::SensorOutputBinding::multi_sensor_sync)); + m.binding & static_cast( + can::ids::SensorOutputBinding::multi_sensor_sync)); driver.set_bind_sync( m.binding & static_cast(can::ids::SensorOutputBinding::sync)); diff --git a/include/sensors/firmware/sensor_hardware.hpp b/include/sensors/firmware/sensor_hardware.hpp index 846f1351d..b6ccc774b 100644 --- a/include/sensors/firmware/sensor_hardware.hpp +++ b/include/sensors/firmware/sensor_hardware.hpp @@ -7,7 +7,6 @@ namespace sensors { namespace hardware { - class SensorHardware : public SensorHardwareBase { public: SensorHardware(sensors::hardware::SensorHardwareConfiguration hardware) diff --git a/include/sensors/tests/mock_hardware.hpp b/include/sensors/tests/mock_hardware.hpp index 889de06a8..56b7d839f 100644 --- a/include/sensors/tests/mock_hardware.hpp +++ b/include/sensors/tests/mock_hardware.hpp @@ -25,11 +25,14 @@ class MockSensorHardware : public sensors::hardware::SensorHardwareBase { sensors::hardware::SensorHardwareBase::reset_sync(sensor); } auto set_sync_enabled(can::ids::SensorId sensor, bool enabled) -> void { - sensors::hardware::SensorHardwareBase::set_sync_enabled(sensor, enabled); + sensors::hardware::SensorHardwareBase::set_sync_enabled(sensor, + enabled); } auto set_sync_required(can::ids::SensorId sensor, bool required) -> void { - sensors::hardware::SensorHardwareBase::set_sync_required(sensor, required); + sensors::hardware::SensorHardwareBase::set_sync_required(sensor, + required); } + private: bool sync_state = false; uint32_t sync_set_calls = 0; diff --git a/sensors/tests/test_sensor_hardware.cpp b/sensors/tests/test_sensor_hardware.cpp index 6f6d6b657..d885eaf5d 100644 --- a/sensors/tests/test_sensor_hardware.cpp +++ b/sensors/tests/test_sensor_hardware.cpp @@ -1,9 +1,9 @@ #include -#include "catch2/catch.hpp" #include "can/core/messages.hpp" -#include "sensors/tests/mock_hardware.hpp" +#include "catch2/catch.hpp" #include "sensors/core/sensor_hardware_interface.hpp" +#include "sensors/tests/mock_hardware.hpp" constexpr auto sensor_id_primary = can::ids::SensorId::S0; constexpr auto sensor_id_secondary = can::ids::SensorId::S1; @@ -79,7 +79,6 @@ SCENARIO("Multiple Sensors connected") { mock_hw.set_sync_enabled(sensor_id_secondary, false); REQUIRE(mock_hw.get_sync_state_mock() == false); } - } GIVEN("Two sensors required") { mock_hw.set_sync_required(sensor_id_primary, true);