Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
Telemetry.h File Reference

Packs SensorDataHandler values into a fixed-size byte packet and streams them over a Stream (UART). More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "ArduinoHAL.h"
#include "UARTCommandHandler.h"
#include "data_handling/SensorDataHandler.h"
Include dependency graph for Telemetry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SendableSensorData
 Declares one telemetry "stream" to include in packets. More...
class  Telemetry
 Packetizes telemetry streams and sends them out over a Stream. More...

Namespaces

namespace  TelemetryFmt

Functions

void TelemetryFmt::writeU32Be (std::uint8_t *dst, std::uint32_t v)
 Write a 32-bit value in big-endian order to dst[0..3].
std::uint16_t TelemetryFmt::hzToPeriod_ms (std::uint16_t frequency_hz)
 Convert frequency (Hz) to period (ms), using integer math.

Variables

constexpr std::size_t TelemetryFmt::kPacketCapacity_bytes = 120
constexpr std::size_t TelemetryFmt::kSyncZeroCount_bytes = 3
constexpr std::size_t TelemetryFmt::kBytesInU32_bytes = 4
constexpr std::size_t TelemetryFmt::kStartByteIndex = kSyncZeroCount_bytes
constexpr std::size_t TelemetryFmt::kTimestampIndex = kStartByteIndex + 1
constexpr std::size_t TelemetryFmt::kPacketCounterIndex = kTimestampIndex + kBytesInU32_bytes
constexpr std::size_t TelemetryFmt::kHeaderSize_bytes = kSyncZeroCount_bytes + 1 + kBytesInU32_bytes + kBytesInU32_bytes
constexpr std::size_t TelemetryFmt::kEndMarkerSize_bytes = kSyncZeroCount_bytes + 1
constexpr std::uint8_t TelemetryFmt::kStartByteValue = 51
constexpr std::uint8_t TelemetryFmt::kEndByteValue = 52
constexpr unsigned TelemetryFmt::kBitsPerByte_bits = 8
constexpr std::uint32_t TelemetryFmt::kCommandModeInactivityTimeout_ms = 10000
constexpr std::size_t TelemetryFmt::kCommandEntrySequenceLength = 3
constexpr char TelemetryFmt::kCommandEntryChar = 'c'

Detailed Description

Packs SensorDataHandler values into a fixed-size byte packet and streams them over a Stream (UART).

Design goals:

  • Keep Telemetry as a normal class (non-templated) so implementation lives in Telemetry.cpp.
  • Allow callers to provide the list of telemetry streams as either:
    • pointer + count (most general)
    • std::array (compile-time sized, convenient)
    • C array (compile-time sized, convenient)

Lifetime rule:

  • Telemetry stores a non-owning pointer to the caller-provided stream list. The stream list must outlive the Telemetry instance (use static storage in embedded code).

Definition in file Telemetry.h.