-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da85ade
commit f29e407
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |