Skip to content

Commit

Permalink
add diff pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Oct 9, 2023
1 parent da85ade commit f29e407
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Udral/airspeed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// This software is distributed under the terms of the MIT License.
/// Copyright (c) 2023 Dmitry Ponomarev.
/// Author: Dmitry Ponomarev <[email protected]>

#include "airspeed.hpp"
#include "main.h"
#include "params.hpp"

void DiffPressurePublisher::publish(float pressure) {
uavcan_si_sample_pressure_Scalar_1_0 msg;
msg.pascal = pressure;
msg.timestamp.microsecond = 0;

static uint8_t buffer[uavcan_si_sample_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t buffer_size = uavcan_si_sample_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_;
int32_t result = uavcan_si_sample_pressure_Scalar_1_0_serialize_(&msg, buffer, &buffer_size);
if (NUNAVUT_SUCCESS == result) {
push(buffer_size, buffer);
}
}
17 changes: 17 additions & 0 deletions Udral/airspeed.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// This software is distributed under the terms of the MIT License.
/// Copyright (c) 2023 Dmitry Ponomarev.
/// Author: Dmitry Ponomarev <[email protected]>

#ifndef UDRAL_AIRSPEED_HPP_
#define UDRAL_AIRSPEED_HPP_

#include "cyphal.hpp"
#include "uavcan/si/sample/pressure/Scalar_1_0.h"

struct DiffPressurePublisher: public CyphalPublisher {
DiffPressurePublisher(Cyphal* driver_, CanardPortID port_id) : CyphalPublisher(driver_, port_id) {};
void publish(float pressure);
};


#endif // UDRAL_AIRSPEED_HPP_

0 comments on commit f29e407

Please sign in to comment.