Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Mar 7, 2024
1 parent 0073d39 commit 5f76e1f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
1 change: 1 addition & 0 deletions include/can/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,7 @@ struct GetHepaUVStateResponse
-> bool = default;
};

// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct AddSensorMoveRequest : BaseMessage<MessageId::add_sensor_move_request> {
uint32_t message_index;
uint8_t group_id;
Expand Down
7 changes: 1 addition & 6 deletions include/sensors/core/tasks/capacitive_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ class CapacitiveMessageHandler {
}
}

void visit(const can::messages::SendAccumulatedPressureDataRequest &m) {
void visit(const can::messages::SendAccumulatedPressureDataRequest &) {
LOG("Received request to dump pressure data buffer %d", m.sensor_id);

if (m.message_index == 0)
return;
else
return;
}

void visit(can::messages::ReadFromSensorRequest &m) {
Expand Down
6 changes: 1 addition & 5 deletions include/sensors/core/tasks/environmental_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ class EnvironmentSensorMessageHandler {
driver.trigger_on_demand();
}

void visit(const can::messages::SendAccumulatedPressureDataRequest &m) {
void visit(const can::messages::SendAccumulatedPressureDataRequest &) {
LOG("Received request to dump pressure data buffer %d", sensor_id);
if (m.message_index == 0)
return;
else
return;
}

void visit(const can::messages::BindSensorOutputRequest &m) {
Expand Down
40 changes: 21 additions & 19 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "sensors/core/utils.hpp"

#if PIPETTE_TYPE_DEFINE == NINETY_SIX_CHANNEL
#define PRESSURE_SENSOR_BUFFER_SIZE 1800
constexpr size_t PRESSURE_SENSOR_BUFFER_SIZE = 1800;
#else
#define PRESSURE_SENSOR_BUFFER_SIZE 3000
constexpr size_t PRESSURE_SENSOR_BUFFER_SIZE = 3000;
#endif

namespace sensors {
Expand All @@ -42,14 +42,15 @@ class MMR920 {
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id,
const sensors::mmr920::SensorVersion version, std::array<float,PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
const sensors::mmr920::SensorVersion version,
std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
: writer(writer),
poller(poller),
can_client(can_client),
own_queue(own_queue),
hardware(hardware),
sensor_id(id),
sensor_version(version) {}
sensor_version(version),
p_buff(p_buff) {}

/**
Expand Down Expand Up @@ -285,12 +286,12 @@ class MMR920 {

void send_accumulated_pressure_data(uint32_t message_index) {
can_client.send_can_message(
can::ids::NodeId::host,
can::messages::ReadFromSensorResponse{
.message_index = pressure_buffer_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data = 9999});
can::ids::NodeId::host,
can::messages::ReadFromSensorResponse{
.message_index = pressure_buffer_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data = 9999});
for (int i = 0; i < pressure_buffer_index; i++) {
// send over buffer adn then clear buffer values
can_client.send_can_message(
Expand All @@ -300,9 +301,12 @@ class MMR920 {
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data =
mmr920C04::reading_to_fixed_point((*p_buff)[i])});
if (i%10 == 0) { vTaskDelay(50); } // slow it down so the can buffer doesn't choke
(*p_buff)[i] = 0;
mmr920::reading_to_fixed_point((*p_buff).at(i))});
if (i % 10 == 0) {
// slow it down so the can buffer doesn't choke
vTaskDelay(50);
}
(*p_buff).at(i) = 0;
}
}

Expand Down Expand Up @@ -366,17 +370,15 @@ class MMR920 {
// send a response with 9999 to make an overload of the buffer
// visible
if (pressure_buffer_index < PRESSURE_SENSOR_BUFFER_SIZE) {
(*p_buff)[pressure_buffer_index] = pressure;
(*p_buff).at(pressure_buffer_index) = pressure;
pressure_buffer_index++;
} else {
can_client.send_can_message(
can::ids::NodeId::host,
can::messages::ErrorMessage{
.message_index = 0,
.severity = can::ids::ErrorSeverity::warning,
.error_code = can::ids::ErrorCode::stop_requested
}
);
.message_index = 0,
.severity = can::ids::ErrorSeverity::warning,
.error_code = can::ids::ErrorCode::stop_requested});
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions include/sensors/core/tasks/pressure_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class PressureMessageHandler {
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id,
const sensors::mmr920::SensorVersion &version, std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
const sensors::mmr920::SensorVersion &version,
std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff)
: driver{i2c_writer, i2c_poller, can_client, own_queue,
hardware, id, version, p_buff)} {}
hardware, id, version, p_buff} {}
PressureMessageHandler(const PressureMessageHandler &) = delete;
PressureMessageHandler(const PressureMessageHandler &&) = delete;
auto operator=(const PressureMessageHandler &)
Expand Down Expand Up @@ -205,7 +206,7 @@ class PressureSensorTask {
sensors::mmr920::SensorVersion *sensor_version,
std::array<float, PRESSURE_SENSOR_BUFFER_SIZE> *p_buff) {
auto handler = PressureMessageHandler{
*writer, *poller, *can_client, get_queue(),
*writer, *poller, *can_client, get_queue(),
*hardware, sensor_id, *sensor_version, p_buff};
handler.initialize();
utils::TaskMessage message{};
Expand Down

0 comments on commit 5f76e1f

Please sign in to comment.