HardFOC Core
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
HfCanFrameRecord.h File Reference

Frame-record tunnel codec (Vortex CANopen design §7.2), shared by the host pipe bus (PipePort), the Wi-Fi TLS tunnel and ESP-NOW. More...

#include <cstddef>
#include <cstdint>
#include "HfCanPort.h"

Go to the source code of this file.

Classes

struct  hf::can::record::Header
 Datagram header. More...
 

Namespaces

namespace  hf
 
namespace  hf::can
 
namespace  hf::can::record
 

Enumerations

enum class  hf::can::record::DecodeError : uint8_t {
  hf::can::record::None = 0 , hf::can::record::Truncated , hf::can::record::BadVersion , hf::can::record::BadLength ,
  hf::can::record::BadFrame
}
 Why a datagram was rejected. More...
 

Functions

void hf::can::record::PutU16 (uint8_t *p, uint16_t v) noexcept
 
void hf::can::record::PutU32 (uint8_t *p, uint32_t v) noexcept
 
uint16_t hf::can::record::GetU16 (const uint8_t *p) noexcept
 
uint32_t hf::can::record::GetU32 (const uint8_t *p) noexcept
 
std::size_t hf::can::record::EncodeHeader (uint8_t *out, const Header &h) noexcept
 Write the header; out has kHeaderSize bytes.
 
constexpr std::size_t hf::can::record::RecordSize (const CanFrame &f) noexcept
 Bytes the record of f takes.
 
std::size_t hf::can::record::EncodeRecord (uint8_t *out, std::size_t cap, const CanFrame &f) noexcept
 Append the record of f.
 
template<typename OnFrame >
DecodeError hf::can::record::DecodeDatagram (const uint8_t *p, std::size_t n, Header *header, OnFrame &&on_frame)
 Decode a datagram; on_frame(const CanFrame&) is called per record.
 

Variables

constexpr uint8_t hf::can::record::kVersion = 1U
 
constexpr std::size_t hf::can::record::kHeaderSize = 8U
 
constexpr std::size_t hf::can::record::kRecordHeaderSize = 6U
 
constexpr std::size_t hf::can::record::kMaxRecordSize = kRecordHeaderSize + kFdMaxLen
 
constexpr std::size_t hf::can::record::kMaxDatagram = 4096U
 
constexpr uint32_t hf::can::record::kIdExtBit = 0x80000000U
 
constexpr uint32_t hf::can::record::kIdRtrBit = 0x40000000U
 
constexpr uint8_t hf::can::record::kRecordFlagMask = frame_flag::kFdf | frame_flag::kBrs | frame_flag::kEsi
 
constexpr uint8_t hf::can::record::kDgramKeepAlive = 0x01U
 

Detailed Description

Frame-record tunnel codec (Vortex CANopen design §7.2), shared by the host pipe bus (PipePort), the Wi-Fi TLS tunnel and ESP-NOW.

Datagram, all fields little-endian:

         u8  ver = 1
         u8  flags        (HF_CAN_RECORD_DGRAM_*; 0 for data)
         u16 seq          (sender's datagram counter, wraps)
         u32 ack/epoch    (sender epoch; acknowledgement on reliable links)
         records...

     Record (the transport form of CanFrame):

         u32 id | EXT (bit 31) | RTR (bit 30)
         u8  flags        (FDF 0x04 | BRS 0x08 | ESI 0x10, same bits as CanFrame)
         u8  len          (payload bytes, 0..64)
         u8  data[len]

     On a byte stream (UNIX socket, TLS) each datagram is preceded by
     a u16 little-endian length. ESP-NOW carries one datagram per
     action frame. The Python twin is `vortex_canopen.frame_record`.

SPDX-License-Identifier: GPL-3.0-or-later