Arduino PulseWire Transceiver Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
pulsewire::RecorderCodec Class Reference

Codec Wrapper that records all edges passed to decodeEdge() for later analysis or testing. More...

#include <RecorderCodec.h>

Inheritance diagram for pulsewire::RecorderCodec:
Inheritance graph
[legend]
Collaboration diagram for pulsewire::RecorderCodec:
Collaboration graph
[legend]

Public Member Functions

 RecorderCodec (Codec &ref)
 
void init (Preamble &detector, uint32_t shortPulseUs=600, uint32_t longPulseUs=1200, uint32_t toleranceUs=200) override
 
void setFrameSize (uint16_t size)
 
bool decodeEdge (uint32_t durationUs, bool level, uint8_t &result) override
 Edge-based decoding for protocol-agnostic RX drivers.
 
bool begin (uint16_t bitFrequencyHz)
 initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines).
 
CodecEnum getCodecType () const override
 instance.
 
virtual size_t getEdgeCount () const
 Get the number of protocol symbols (bits, pulses, etc.) per encoded byte.
 
Vector< OutputEdge > & getRecordedEdges ()
 
void clear ()
 
size_t encodeBit (bool bit, Vector< OutputEdge > &output)
 Fill output vector with protocol-specific OutputSpec(s) for a bit.
 
bool decodeByte (Vector< OutputEdge > &edges, uint8_t &result) override
 Decode edges into a byte.
 
void encodeByte (uint8_t byte, std::vector< bool > &bits) const override
 Encode a byte to protocol bitstream. Default implementation encodes to raw bits (MSB first), but can be overridden by protocols that require different bit formatting (e.g., Manchester). The output bits are stored in.
 
int getEndOfFrameDelayUs () override
 Provide the end of frame delay in microseconds for this protocol, used by RX driver to.
 
virtual void reset ()
 
PreamblegetPreamble ()
 Get the preamble detector associated with this codec.
 
void setPreamble (Preamble &preamble)
 Set the Preamble Detector object.
 
size_t encodePreamble (Vector< OutputEdge > &output)
 
virtual size_t encode (uint8_t byte, Vector< OutputEdge > &output)
 Fill output vector with protocol-specific OutputSpec(s) for a byte.
 
virtual bool getIdleLevel () const
 Provides the initial ldle state (low or hith)
 
const charname () const
 Get the name of the codec type as a string (e.g., "PulseDistance", "Manchester").
 

Protected Attributes

Codec_ref
 
Vector< OutputEdge_recordedEdges
 
CustomPreambleUs _defaultPreamble
 
Preamble_preamble = &_defaultPreamble
 
uint16_t _bitFrequencyHz = 0
 
uint32_t _bitPeriodUs = 0
 
Vector< OutputEdge_decodeEdgeStream
 
volatile bool _inFrame = false
 

Detailed Description

Codec Wrapper that records all edges passed to decodeEdge() for later analysis or testing.

Definition at line 11 of file RecorderCodec.h.

Constructor & Destructor Documentation

◆ RecorderCodec()

pulsewire::RecorderCodec::RecorderCodec ( Codec ref)
inline

Definition at line 13 of file RecorderCodec.h.

Member Function Documentation

◆ begin()

bool pulsewire::RecorderCodec::begin ( uint16_t  bitFrequencyHz)
inlinevirtual

initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines).

Reimplemented from pulsewire::Codec.

Definition at line 28 of file RecorderCodec.h.

◆ clear()

void pulsewire::RecorderCodec::clear ( )
inline

Definition at line 39 of file RecorderCodec.h.

◆ decodeByte()

bool pulsewire::RecorderCodec::decodeByte ( Vector< OutputEdge > &  edges,
uint8_t result 
)
inlineoverridevirtual

Decode edges into a byte.

Implements pulsewire::Codec.

Definition at line 45 of file RecorderCodec.h.

◆ decodeEdge()

bool pulsewire::RecorderCodec::decodeEdge ( uint32_t  durationUs,
bool  level,
uint8_t result 
)
inlineoverridevirtual

Edge-based decoding for protocol-agnostic RX drivers.

Called on each signal edge (duration since last edge, new level, minUs, maxUs). The codec maintains its own state and assembles frames internally.

Parameters
durationUsTime in microseconds since last edge.
levelNew logic level after the edge (true = HIGH, false = LOW).
frameBufferOutput buffer for decoded frame (if available).
frameBufferSizeSize of frameBuffer (bytes).
frameLenSet to decoded frame length if a frame is available.
Returns
True if a complete frame is decoded and available in frameBuffer.

Reimplemented from pulsewire::Codec.

Definition at line 24 of file RecorderCodec.h.

◆ encode()

virtual size_t pulsewire::Codec::encode ( uint8_t  byte,
Vector< OutputEdge > &  output 
)
inlinevirtualinherited

Fill output vector with protocol-specific OutputSpec(s) for a byte.

Encodes the byte to protocol bits and appends OutputSpec(s) for each bit.

Parameters
byteThe byte to encode.
outputVector to append OutputSpec(s).
Returns
Number of OutputSpec entries added.

Reimplemented in pulsewire::NRZCodec.

Definition at line 162 of file Codec.h.

◆ encodeBit()

size_t pulsewire::RecorderCodec::encodeBit ( bool  bit,
Vector< OutputEdge > &  output 
)
inlinevirtual

Fill output vector with protocol-specific OutputSpec(s) for a bit.

Parameters
bitThe bit to encode (true/false).
outputVector to append OutputSpec(s).
Returns
Number of OutputSpec entries added.

Reimplemented from pulsewire::Codec.

Definition at line 41 of file RecorderCodec.h.

◆ encodeByte()

void pulsewire::RecorderCodec::encodeByte ( uint8_t  byte,
std::vector< bool > &  bits 
) const
inlineoverridevirtual

Encode a byte to protocol bitstream. Default implementation encodes to raw bits (MSB first), but can be overridden by protocols that require different bit formatting (e.g., Manchester). The output bits are stored in.

Parameters
byteThe input byte to encode.
bitsOutput buffer for encoded bits (protocol-specific format).

Reimplemented from pulsewire::Codec.

Definition at line 49 of file RecorderCodec.h.

◆ encodePreamble()

size_t pulsewire::Codec::encodePreamble ( Vector< OutputEdge > &  output)
inlineinherited

Definition at line 146 of file Codec.h.

◆ getCodecType()

CodecEnum pulsewire::RecorderCodec::getCodecType ( ) const
inlineoverridevirtual

instance.

Get the codec type (e.g., PulseDistance, Manchester) for this Codec

Implements pulsewire::Codec.

Definition at line 33 of file RecorderCodec.h.

◆ getEdgeCount()

virtual size_t pulsewire::RecorderCodec::getEdgeCount ( ) const
inlinevirtual

Get the number of protocol symbols (bits, pulses, etc.) per encoded byte.

Returns
Number of protocol symbols per byte.

Implements pulsewire::Codec.

Definition at line 35 of file RecorderCodec.h.

◆ getEndOfFrameDelayUs()

int pulsewire::RecorderCodec::getEndOfFrameDelayUs ( )
inlineoverridevirtual

Provide the end of frame delay in microseconds for this protocol, used by RX driver to.

Implements pulsewire::Codec.

Definition at line 53 of file RecorderCodec.h.

◆ getIdleLevel()

virtual bool pulsewire::Codec::getIdleLevel ( ) const
inlinevirtualinherited

Provides the initial ldle state (low or hith)

Reimplemented in pulsewire::DifferentialManchesterCodec.

Definition at line 208 of file Codec.h.

◆ getPreamble()

Preamble & pulsewire::Codec::getPreamble ( )
inlineinherited

Get the preamble detector associated with this codec.

Returns
Reference to the Preamble instance used for preamble detection.

Definition at line 77 of file Codec.h.

◆ getRecordedEdges()

Vector< OutputEdge > & pulsewire::RecorderCodec::getRecordedEdges ( )
inline

Definition at line 37 of file RecorderCodec.h.

◆ init()

void pulsewire::RecorderCodec::init ( Preamble detector,
uint32_t  shortPulseUs = 600,
uint32_t  longPulseUs = 1200,
uint32_t  toleranceUs = 200 
)
inlineoverridevirtual

Used by IRTransceiver to initialize codec with protocol-specific parameters

Reimplemented from pulsewire::Codec.

Definition at line 15 of file RecorderCodec.h.

◆ name()

const char * pulsewire::Codec::name ( ) const
inlineinherited

Get the name of the codec type as a string (e.g., "PulseDistance", "Manchester").

Definition at line 218 of file Codec.h.

◆ reset()

virtual void pulsewire::Codec::reset ( )
inlinevirtualinherited

Definition at line 67 of file Codec.h.

◆ setFrameSize()

void pulsewire::RecorderCodec::setFrameSize ( uint16_t  size)
inline

Definition at line 19 of file RecorderCodec.h.

◆ setPreamble()

void pulsewire::Codec::setPreamble ( Preamble preamble)
inlineinherited

Set the Preamble Detector object.

Parameters
preamble

Definition at line 84 of file Codec.h.

Field Documentation

◆ _bitFrequencyHz

uint16_t pulsewire::Codec::_bitFrequencyHz = 0
protectedinherited

Definition at line 224 of file Codec.h.

◆ _bitPeriodUs

uint32_t pulsewire::Codec::_bitPeriodUs = 0
protectedinherited

Definition at line 225 of file Codec.h.

◆ _decodeEdgeStream

Vector<OutputEdge> pulsewire::Codec::_decodeEdgeStream
protectedinherited

Definition at line 226 of file Codec.h.

◆ _defaultPreamble

CustomPreambleUs pulsewire::Codec::_defaultPreamble
protectedinherited

Definition at line 222 of file Codec.h.

◆ _inFrame

volatile bool pulsewire::Codec::_inFrame = false
protectedinherited

Definition at line 227 of file Codec.h.

◆ _preamble

Preamble* pulsewire::Codec::_preamble = &_defaultPreamble
protectedinherited

Definition at line 223 of file Codec.h.

◆ _recordedEdges

Vector<OutputEdge> pulsewire::RecorderCodec::_recordedEdges
protected

Definition at line 57 of file RecorderCodec.h.

◆ _ref

Codec& pulsewire::RecorderCodec::_ref
protected

Definition at line 56 of file RecorderCodec.h.


The documentation for this class was generated from the following file: