From 7e89b0f3b1b7d4402ebd11b3049f19c5937639b5 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Tue, 11 Jun 2024 17:10:18 -0400 Subject: [PATCH] make p buff sensor buff, change size to 500 --- gripper/core/CMakeLists.txt | 2 +- gripper/core/tasks.cpp | 10 +++++----- include/common/core/sensor_buffer.hpp | 4 ++-- .../sensors/core/tasks/capacitive_driver.hpp | 12 +++++------ .../core/tasks/capacitive_sensor_task.hpp | 8 ++++---- .../sensors/core/tasks/pressure_driver.hpp | 12 +++++------ .../core/tasks/pressure_sensor_task.hpp | 8 ++++---- pipettes/core/CMakeLists.txt | 8 ++++---- pipettes/core/sensor_tasks.cpp | 20 +++++++++---------- sensors/tests/test_capacitive_sensor.cpp | 10 +++++----- sensors/tests/test_pressure_driver.cpp | 4 ++-- sensors/tests/test_pressure_sensor.cpp | 4 ++-- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/gripper/core/CMakeLists.txt b/gripper/core/CMakeLists.txt index 9089fc917..75bb7155b 100644 --- a/gripper/core/CMakeLists.txt +++ b/gripper/core/CMakeLists.txt @@ -1,7 +1,7 @@ function(target_gripper_core TARGET) if(${USE_SENSOR_MOVE}) target_compile_definitions(${TARGET} PUBLIC USE_SENSOR_MOVE) - target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1700) + target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500) target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true) endif() target_sources(${TARGET} PUBLIC diff --git a/gripper/core/tasks.cpp b/gripper/core/tasks.cpp index da192c96d..9c9ea66ed 100644 --- a/gripper/core/tasks.cpp +++ b/gripper/core/tasks.cpp @@ -16,9 +16,9 @@ static auto tasks = gripper_tasks::AllTask{}; static auto queues = gripper_tasks::QueueClient{can::ids::NodeId::gripper}; -static std::array p_buff; +static std::array sensor_buffer; #ifdef USE_TWO_BUFFERS -static std::array p_buff_front; +static std::array sensor_buffer_front; #endif static auto eeprom_task_builder = @@ -101,14 +101,14 @@ void gripper_tasks::start_tasks( 5, "cap sensor S1", i2c2_task_client, i2c2_poll_client, sensor_hardware, queues, #ifdef USE_TWO_BUFFERS - p_buff_front); + sensor_buffer_front); #else - p_buff); + sensor_buffer); #endif auto& capacitive_sensor_task_rear = capacitive_sensor_task_builder_rear.start( 5, "cap sensor S0", i2c3_task_client, i2c3_poll_client, - sensor_hardware, queues, p_buff); + sensor_hardware, queues, sensor_buffer); tasks.i2c2_task = &i2c2_task; tasks.i2c3_task = &i2c3_task; diff --git a/include/common/core/sensor_buffer.hpp b/include/common/core/sensor_buffer.hpp index 978d86cca..287828582 100644 --- a/include/common/core/sensor_buffer.hpp +++ b/include/common/core/sensor_buffer.hpp @@ -1,7 +1,7 @@ #pragma once #ifdef USE_SENSOR_MOVE -constexpr size_t SENSOR_BUFFER_SIZE = P_BUFF_SIZE; +constexpr size_t SENSOR_BUFFER_SIZE = SENSOR_BUFF_SIZE; #else constexpr size_t SENSOR_BUFFER_SIZE = 0; -#endif +#endif \ No newline at end of file diff --git a/include/sensors/core/tasks/capacitive_driver.hpp b/include/sensors/core/tasks/capacitive_driver.hpp index ab5963ec5..a9cdfeae6 100644 --- a/include/sensors/core/tasks/capacitive_driver.hpp +++ b/include/sensors/core/tasks/capacitive_driver.hpp @@ -42,14 +42,14 @@ class FDC1004 { FDC1004(I2CQueueWriter &writer, I2CQueuePoller &poller, CanClient &can_client, OwnQueue &own_queue, sensors::hardware::SensorHardwareBase &hardware, bool shared_sensor, - std::array *p_buff) + std::array *sensor_buffer) : writer(writer), poller(poller), can_client(can_client), own_queue(own_queue), hardware(hardware), shared_sensor(shared_sensor), - p_buff(p_buff) {} + sensor_buffer(sensor_buffer) {} [[nodiscard]] auto initialized() const -> bool { return _initialized; } @@ -224,12 +224,12 @@ class FDC1004 { .sensor = can::ids::SensorType::capacitive, .sensor_id = sensor_id, .sensor_data = - convert_to_fixed_point((*p_buff).at(i), S15Q16_RADIX)}); + convert_to_fixed_point((*sensor_buffer).at(i), S15Q16_RADIX)}); if (i % 10 == 0) { // slow it down so the can buffer doesn't choke vTaskDelay(50); } - (*p_buff).at(i) = 0; + (*sensor_buffer).at(i) = 0; } #else std::ignore = message_index; @@ -306,7 +306,7 @@ class FDC1004 { // send a response with 9999 to make an overload of the buffer // visible if (sensor_buffer_index < SENSOR_BUFFER_SIZE) { - (*p_buff).at(sensor_buffer_index) = capacitance; + (*sensor_buffer).at(sensor_buffer_index) = capacitance; sensor_buffer_index++; } #else @@ -537,7 +537,7 @@ class FDC1004 { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return RG(*reinterpret_cast(&ret.value())); } - std::array *p_buff; + std::array *sensor_buffer; uint16_t sensor_buffer_index = 0; }; // end of FDC1004 class diff --git a/include/sensors/core/tasks/capacitive_sensor_task.hpp b/include/sensors/core/tasks/capacitive_sensor_task.hpp index 15943bdc1..abd7bc354 100644 --- a/include/sensors/core/tasks/capacitive_sensor_task.hpp +++ b/include/sensors/core/tasks/capacitive_sensor_task.hpp @@ -23,9 +23,9 @@ class CapacitiveMessageHandler { I2CQueueWriter &i2c_writer, I2CQueuePoller &i2c_poller, sensors::hardware::SensorHardwareBase &hardware, CanClient &can_client, OwnQueue &own_queue, bool shared_task, - std::array *p_buff) + std::array *sensor_buffer) : driver{i2c_writer, i2c_poller, can_client, own_queue, - hardware, shared_task, p_buff} {} + hardware, shared_task, sensor_buffer} {} CapacitiveMessageHandler(const CapacitiveMessageHandler &) = delete; CapacitiveMessageHandler(const CapacitiveMessageHandler &&) = delete; auto operator=(const CapacitiveMessageHandler &) @@ -213,14 +213,14 @@ class CapacitiveSensorTask { i2c::writer::Writer *writer, i2c::poller::Poller *poller, sensors::hardware::SensorHardwareBase *hardware, CanClient *can_client, - std::array *p_buff, + std::array *sensor_buffer, bool shared_task = false) { // On the 8 channel, there is a singular cap sensor but we're using // multiple channels. We will thus rely on the sensor id in this case // to determine which CIN configuration the sensor should be in. auto handler = CapacitiveMessageHandler{ *writer, *poller, *hardware, *can_client, - get_queue(), shared_task, p_buff}; + get_queue(), shared_task, sensor_buffer}; handler.initialize(); utils::TaskMessage message{}; for (;;) { diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index d77f2651f..67288763b 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -38,7 +38,7 @@ class MMR920 { sensors::hardware::SensorHardwareBase &hardware, const can::ids::SensorId &id, const sensors::mmr920::SensorVersion version, - std::array *p_buff) + std::array *sensor_buffer) : writer(writer), poller(poller), can_client(can_client), @@ -46,7 +46,7 @@ class MMR920 { hardware(hardware), sensor_id(id), sensor_version(version), - p_buff(p_buff) {} + sensor_buffer(sensor_buffer) {} /** * @brief Check if the MMR92 has been initialized. @@ -290,12 +290,12 @@ class MMR920 { .sensor = can::ids::SensorType::pressure, .sensor_id = sensor_id, .sensor_data = - mmr920::reading_to_fixed_point((*p_buff).at(i))}); + mmr920::reading_to_fixed_point((*sensor_buffer).at(i))}); if (i % 10 == 0) { // slow it down so the can buffer doesn't choke vTaskDelay(50); } - (*p_buff).at(i) = 0; + (*sensor_buffer).at(i) = 0; } #else std::ignore = message_index; @@ -362,7 +362,7 @@ class MMR920 { auto response_pressure = pressure - current_pressure_baseline_pa; #ifdef USE_SENSOR_MOVE if (sensor_buffer_index < SENSOR_BUFFER_SIZE) { - (*p_buff).at(sensor_buffer_index) = response_pressure; + (*sensor_buffer).at(sensor_buffer_index) = response_pressure; sensor_buffer_index++; } #else @@ -558,7 +558,7 @@ class MMR920 { value &= Reg::value_mask; return write(Reg::address, value); } - std::array *p_buff; + std::array *sensor_buffer; uint16_t sensor_buffer_index = 0; }; diff --git a/include/sensors/core/tasks/pressure_sensor_task.hpp b/include/sensors/core/tasks/pressure_sensor_task.hpp index a8ef5f6db..39b158c9d 100644 --- a/include/sensors/core/tasks/pressure_sensor_task.hpp +++ b/include/sensors/core/tasks/pressure_sensor_task.hpp @@ -24,9 +24,9 @@ class PressureMessageHandler { sensors::hardware::SensorHardwareBase &hardware, const can::ids::SensorId &id, const sensors::mmr920::SensorVersion &version, - std::array *p_buff) + std::array *sensor_buffer) : driver{i2c_writer, i2c_poller, can_client, own_queue, - hardware, id, version, p_buff} {} + hardware, id, version, sensor_buffer} {} PressureMessageHandler(const PressureMessageHandler &) = delete; PressureMessageHandler(const PressureMessageHandler &&) = delete; auto operator=(const PressureMessageHandler &) @@ -204,10 +204,10 @@ class PressureSensorTask { i2c::poller::Poller *poller, CanClient *can_client, sensors::hardware::SensorHardwareBase *hardware, sensors::mmr920::SensorVersion *sensor_version, - std::array *p_buff) { + std::array *sensor_buffer) { auto handler = PressureMessageHandler{ *writer, *poller, *can_client, get_queue(), - *hardware, sensor_id, *sensor_version, p_buff}; + *hardware, sensor_id, *sensor_version, sensor_buffer}; handler.initialize(); utils::TaskMessage message{}; for (;;) { diff --git a/pipettes/core/CMakeLists.txt b/pipettes/core/CMakeLists.txt index c0654d2ca..105c07d9d 100644 --- a/pipettes/core/CMakeLists.txt +++ b/pipettes/core/CMakeLists.txt @@ -18,7 +18,7 @@ function(target_pipettes_core_single TARGET REVISION) target_pipettes_core_common(${TARGET} ${REVISION}) target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=SINGLE_CHANNEL) if(${USE_SENSOR_MOVE}) - target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=2800) + target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500) endif() target_sources(${TARGET} PUBLIC ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/can_task_low_throughput.cpp) @@ -28,7 +28,7 @@ function(target_pipettes_core_multi TARGET REVISION) target_pipettes_core_common(${TARGET} ${REVISION}) target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=EIGHT_CHANNEL) if(${USE_SENSOR_MOVE}) - target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1700) + target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500) target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true) endif() target_sources(${TARGET} PUBLIC @@ -39,7 +39,7 @@ function(target_pipettes_core_96 TARGET REVISION) target_pipettes_core_common(${TARGET} ${REVISION}) target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=NINETY_SIX_CHANNEL) if(${USE_SENSOR_MOVE}) - target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=800) + target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=800) target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true) endif() target_sources(${TARGET} PUBLIC @@ -50,7 +50,7 @@ function(target_pipettes_core_384 TARGET REVISION) target_pipettes_core_common(${TARGET} ${REVISION}) target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=THREE_EIGHTY_FOUR_CHANNEL) if(${USE_SENSOR_MOVE}) - target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1500) + target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=1500) target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true) endif() target_sources(${TARGET} PUBLIC diff --git a/pipettes/core/sensor_tasks.cpp b/pipettes/core/sensor_tasks.cpp index 66fd489d6..f08e4a9a7 100644 --- a/pipettes/core/sensor_tasks.cpp +++ b/pipettes/core/sensor_tasks.cpp @@ -6,9 +6,9 @@ static auto tasks = sensor_tasks::Tasks{}; static auto queue_client = sensor_tasks::QueueClient{}; -static std::array p_buff; +static std::array sensor_buffer; #ifdef USE_TWO_BUFFERS -static std::array p_buff_front; +static std::array sensor_buffer_front; #endif static auto eeprom_task_builder = freertos_task::TaskStarter<512, eeprom::task::EEPromTask>{}; @@ -73,11 +73,11 @@ void sensor_tasks::start_tasks( 5, "enviro sensor", i2c3_task_client, i2c3_poller_client, queues); auto& pressure_sensor_task_rear = pressure_sensor_task_builder_rear.start( 5, "pressure sensor s0", pressure_i2c_client, pressure_i2c_poller, - queues, sensor_hardware_primary, sensor_version, p_buff); + queues, sensor_hardware_primary, sensor_version, sensor_buffer); auto& capacitive_sensor_task_rear = capacitive_sensor_task_builder_rear.start( 5, "capacitive sensor s0", i2c3_task_client, i2c3_poller_client, - sensor_hardware_primary, queues, p_buff); + sensor_hardware_primary, queues, sensor_buffer); auto& tip_notification_task_rear = tip_notification_task_builder_rear.start( 5, "tip notification sensor s0", queues, sensor_hardware_primary); @@ -139,23 +139,23 @@ void sensor_tasks::start_tasks( auto& pressure_sensor_task_rear = pressure_sensor_task_builder_rear.start( 5, "pressure sensor s0", primary_pressure_i2c_client, primary_pressure_i2c_poller, queues, sensor_hardware_primary, - sensor_version, p_buff); + sensor_version, sensor_buffer); auto& pressure_sensor_task_front = pressure_sensor_task_builder_front.start( 5, "pressure sensor s1", secondary_pressure_i2c_client, secondary_pressure_i2c_poller, queues, sensor_hardware_secondary, sensor_version, #ifdef USE_TWO_BUFFERS - p_buff_front); + sensor_buffer_front); #else // we don't want to build a second buffer for the single channel, but if // we dont pass in the correct sized array here, compilation fails // this doesn't matter though cause single channels will never call this - p_buff); + sensor_buffer); #endif auto& capacitive_sensor_task_rear = capacitive_sensor_task_builder_rear.start( 5, "capacitive sensor s0", i2c3_task_client, i2c3_poller_client, - sensor_hardware_primary, queues, p_buff, shared_cap_task); + sensor_hardware_primary, queues, sensor_buffer, shared_cap_task); auto& tip_notification_task_rear = tip_notification_task_builder_rear.start( 5, "tip notification sensor s0", queues, sensor_hardware_primary); @@ -190,9 +190,9 @@ void sensor_tasks::start_tasks( 5, "capacitive sensor s1", i2c2_task_client, i2c2_poller_client, sensor_hardware_secondary, queues, #ifdef USE_TWO_BUFFERS - p_buff_front); + sensor_buffer_front); #else - p_buff); + sensor_buffer); #endif tasks.capacitive_sensor_task_front = &capacitive_sensor_task_front; queues.capacitive_sensor_queue_front = diff --git a/sensors/tests/test_capacitive_sensor.cpp b/sensors/tests/test_capacitive_sensor.cpp index 25f220c5e..0945c6cfc 100644 --- a/sensors/tests/test_capacitive_sensor.cpp +++ b/sensors/tests/test_capacitive_sensor.cpp @@ -30,7 +30,7 @@ auto get_message_i2c(Queue& q) -> Message { auto sensor_id = can::ids::SensorId::S0; constexpr uint8_t sensor_id_int = 0x0; -static std::array p_buff; +static std::array sensor_buffer; SCENARIO("read capacitance sensor values without shared CINs") { test_mocks::MockSensorHardware mock_hw{}; @@ -55,7 +55,7 @@ SCENARIO("read capacitance sensor values without shared CINs") { poller.set_queue(&poller_queue); auto sensor_not_shared = sensors::tasks::CapacitiveMessageHandler{ - writer, poller, mock_hw, queue_client, response_queue, false, &p_buff}; + writer, poller, mock_hw, queue_client, response_queue, false, &sensor_buffer}; constexpr uint8_t capacitive_id = 0x1; GIVEN("a initialize sensor request") { @@ -383,7 +383,7 @@ SCENARIO("read capacitance sensor values supporting shared CINs") { poller.set_queue(&poller_queue); auto sensor_shared = sensors::tasks::CapacitiveMessageHandler{ - writer, poller, mock_hw, queue_client, response_queue, true, &p_buff}; + writer, poller, mock_hw, queue_client, response_queue, true, &sensor_buffer}; constexpr uint8_t capacitive_id = 0x1; GIVEN("a initialize sensor request") { @@ -581,7 +581,7 @@ SCENARIO("capacitance driver tests no shared CINs") { queue_client.set_queue(&can_queue); writer.set_queue(&i2c_queue); sensors::tasks::FDC1004 callback_host( - writer, poller, queue_client, response_queue, mock_hw, false, &p_buff); + writer, poller, queue_client, response_queue, mock_hw, false, &sensor_buffer); can::message_writer_task::TaskMessage empty_msg{}; @@ -771,7 +771,7 @@ SCENARIO("threshold configuration") { poller.set_queue(&poller_queue); auto sensor = sensors::tasks::CapacitiveMessageHandler{ - writer, poller, mock_hw, queue_client, response_queue, false, &p_buff}; + writer, poller, mock_hw, queue_client, response_queue, false, &sensor_buffer}; GIVEN("A request to set an autothreshold") { int NUM_READS = 10; diff --git a/sensors/tests/test_pressure_driver.cpp b/sensors/tests/test_pressure_driver.cpp index a1570b32c..a0a7aead0 100644 --- a/sensors/tests/test_pressure_driver.cpp +++ b/sensors/tests/test_pressure_driver.cpp @@ -38,7 +38,7 @@ auto get_message(Queue& q) -> Message { constexpr auto sensor_id = can::ids::SensorId::S0; constexpr uint8_t sensor_id_int = 0x0; -static std::array p_buff; +static std::array sensor_buffer; SCENARIO("Testing the pressure sensor driver") { test_mocks::MockMessageQueue i2c_queue{}; @@ -61,7 +61,7 @@ SCENARIO("Testing the pressure sensor driver") { poller.set_queue(&i2c_poll_queue); sensors::tasks::MMR920 driver( writer, poller, queue_client, pressure_queue, hardware, sensor_id, - sensors::mmr920::SensorVersion::mmr920c04, &p_buff); + sensors::mmr920::SensorVersion::mmr920c04, &sensor_buffer); can::message_writer_task::TaskMessage empty_can_msg{}; diff --git a/sensors/tests/test_pressure_sensor.cpp b/sensors/tests/test_pressure_sensor.cpp index 5a5aae5d0..ed34cc743 100644 --- a/sensors/tests/test_pressure_sensor.cpp +++ b/sensors/tests/test_pressure_sensor.cpp @@ -36,7 +36,7 @@ constexpr uint8_t pressure_temperature_id = static_cast(can::ids::SensorType::pressure_temperature); constexpr uint8_t sensor_id_int = 0x0; -static std::array p_buff; +static std::array sensor_buffer; SCENARIO("Receiving messages through the pressure sensor message handler") { test_mocks::MockMessageQueue i2c_queue{}; @@ -65,7 +65,7 @@ SCENARIO("Receiving messages through the pressure sensor message handler") { mock_hw, sensor_id, sensors::mmr920::SensorVersion::mmr920c04, - &p_buff}; + &sensor_buffer}; GIVEN("A TransactionResponse message") { can_queue.reset();