|
arduino-audio-tools
|
High-Level Data Link Control (HDLC) is a bit-oriented code-transparent synchronous data link layer protocol for reliable, framed, and error-checked communication. More...
#include <HDLCStream.h>
Public Member Functions | |
| HDLCStream ()=default | |
| HDLCStream (int maxFrameSize) | |
| HDLCStream (Print &stream, size_t maxFrameSize) | |
| Construct a new HDLCStream object using a Print for output only. | |
| HDLCStream (Stream &stream, size_t maxFrameSize) | |
| Construct a new HDLCStream object using a Stream for input and output. | |
| int | available () override |
| Get the number of bytes available to read from the frame buffer. | |
| virtual int | availableForWrite () |
| virtual int | availableForWrite () |
| void | flush () override |
| Flush the output buffer of the underlying stream. | |
| operator bool () | |
| operator bool () | |
| int | peek () override |
| Not supported. | |
| int | read () override |
| Not supported. | |
| size_t | readBytes (uint8_t *buffer, size_t length) |
| Read a full frame from the stream into a buffer. | |
| bool | resize (size_t size) |
| void | setPrint (Print &stream) |
| void | setStream (Stream &stream) |
| size_t | write (const uint8_t *data, size_t len) override |
| Write multiple bytes to the stream. | |
| size_t | write (uint8_t b) override |
| Not supported. | |
Protected Types | |
| enum | RxState { IDLE , RECEIVING , ESCAPED } |
Protected Member Functions | |
| uint16_t | _crc16 (uint8_t data, uint16_t crc) |
| Calculate CRC-CCITT (16-bit). | |
| void | _processInput () |
| Process incoming bytes, detect frames, validate CRC and prepare data for reading. | |
| void | _writeEscaped (uint8_t b) |
| Write a byte with proper HDLC byte stuffing if needed. | |
| size_t | writeFrame (const uint8_t *data, size_t len) |
| Write a complete HDLC frame with proper framing and CRC. | |
Protected Attributes | |
| size_t | _frameLen = 0 |
| bool | _frameReady = false |
| size_t | _maxFrameSize = 0 |
| Vector< uint8_t > | _rxBuffer |
| size_t | _rxLen = 0 |
| size_t | _rxPos = 0 |
| enum audio_tools::HDLCStream::RxState | _rxState = IDLE |
| int | _timeout = 10 |
| Print * | p_print = nullptr |
| Stream * | p_stream = nullptr |
| SingleBuffer< uint8_t > | rx_frame_buffer |
| SingleBuffer< uint8_t > | tx_frame_buffer |
Static Protected Attributes | |
| static constexpr uint8_t | HDLC_ESC = 0x7D |
| static constexpr uint8_t | HDLC_ESC_XOR = 0x20 |
| static constexpr uint8_t | HDLC_FLAG = 0x7E |
High-Level Data Link Control (HDLC) is a bit-oriented code-transparent synchronous data link layer protocol for reliable, framed, and error-checked communication.
This class implements HDLC framing with:
|
protected |
|
default |
|
inline |
|
inline |
Construct a new HDLCStream object using a Stream for input and output.
| stream | The underlying Stream for both reading and writing |
| maxFrameSize | Maximum size of a single HDLC frame |
|
inline |
Construct a new HDLCStream object using a Print for output only.
| stream | The underlying Print for writing |
| maxFrameSize | Maximum size of a single HDLC frame |
|
inlineprotected |
Calculate CRC-CCITT (16-bit).
| data | Byte to include in CRC calculation |
| crc | Current CRC value |
|
inlineprotected |
Process incoming bytes, detect frames, validate CRC and prepare data for reading.
|
inlineprotected |
Write a byte with proper HDLC byte stuffing if needed.
| b | Byte to write |
|
inlineoverridevirtual |
Get the number of bytes available to read from the frame buffer.
Reimplemented from Stream.
|
inlinevirtualinherited |
Reimplemented in A2DPStream, AbstractURLStream, AdapterAudioStreamToAudioOutput, AnalogAudioStream, AdapterAudioStreamToAudioOutput, AudioOutput, AudioOutput, AudioStreamWrapper, AudioStreamWrapper, BaseStream, BaseStream, ConverterStream< T >, ConverterStream< T >, CsvOutput< T >, CsvOutput< T >, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioOutput, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, MemoryOutput, MemoryOutput, MemoryStream, MemoryStream, OutputMixer< T >, OutputMixer< T >, ProgressStream, ProgressStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, Throttle, Throttle, TimedStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, AudioBLEServer, AudioEffectStream, AudioEffectStreamT< T >, AudioESP32ULP, AudioFFTBase, AudioLoRa, AudioOutput, AudioServerEx, AudioStreamWrapper, AudioSyncWriter, AutomaticGainControlStream, BaseStream, ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, ConverterStream< T >, CsvOutput< T >, DynamicMemoryStream, EncodedAudioOutput, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, ESPNowStream, FadeStream, FaustStream< DSP >, FileOutput, FilteredStream< T, TF >, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, HammingFEC< bytecount, block_t >, I2SCodecStream, I2SStream, MeasuringStream, MemoryOutput, MemoryStream, MiniAudioStream, NRF24Stream, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, OutputMixer< T >, Pipeline, ProgressStream, PWMAudioOutput< PWMDriverT >, QualityAnalysisStream, QueueStream< T >, ReadioHeadStream, ReedSolomonFEC< bytecount, additional_bytes >, ReformatBaseStream, RingBufferStream, RTSPOutput< Platform >, SPIAudioMaster, SPIAudioSlave, StdioStream, SupportedRatesStream, SynchronizedStream, Throttle, TimedStream, UDPStream, URLStreamESP32, USBAudioStreamBase, VBANStream, and VolumeStream.
|
inlinevirtualinherited |
Reimplemented in A2DPStream, AbstractURLStream, AdapterAudioStreamToAudioOutput, AnalogAudioStream, AdapterAudioStreamToAudioOutput, AudioOutput, AudioOutput, AudioStreamWrapper, AudioStreamWrapper, BaseStream, BaseStream, ConverterStream< T >, ConverterStream< T >, CsvOutput< T >, CsvOutput< T >, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioOutput, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, MemoryOutput, MemoryOutput, MemoryStream, MemoryStream, OutputMixer< T >, OutputMixer< T >, ProgressStream, ProgressStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, Throttle, Throttle, TimedStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, AudioBLEServer, AudioEffectStream, AudioEffectStreamT< T >, AudioESP32ULP, AudioFFTBase, AudioLoRa, AudioOutput, AudioServerEx, AudioStreamWrapper, AudioSyncWriter, AutomaticGainControlStream, BaseStream, ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, ConverterStream< T >, CsvOutput< T >, DynamicMemoryStream, EncodedAudioOutput, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, ESPNowStream, FadeStream, FaustStream< DSP >, FileOutput, FilteredStream< T, TF >, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, HammingFEC< bytecount, block_t >, I2SCodecStream, I2SStream, MeasuringStream, MemoryOutput, MemoryStream, MiniAudioStream, NRF24Stream, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, OutputMixer< T >, Pipeline, ProgressStream, PWMAudioOutput< PWMDriverT >, QualityAnalysisStream, QueueStream< T >, ReadioHeadStream, ReedSolomonFEC< bytecount, additional_bytes >, ReformatBaseStream, RingBufferStream, RTSPOutput< Platform >, SPIAudioMaster, SPIAudioSlave, StdioStream, SupportedRatesStream, SynchronizedStream, Throttle, TimedStream, UDPStream, URLStreamESP32, USBAudioStreamBase, VBANStream, and VolumeStream.
|
inlineoverridevirtual |
Flush the output buffer of the underlying stream.
Reimplemented from Print.
|
inlineinherited |
|
inlineinherited |
|
inlineoverride |
Not supported.
|
inlineoverride |
Not supported.
|
inlinevirtual |
Read a full frame from the stream into a buffer.
| buffer | Destination buffer to hold the data |
| length | Maximum number of bytes to read |
Reimplemented from Stream.
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Write multiple bytes to the stream.
| data | Pointer to the data buffer |
| len | Number of bytes to write |
Reimplemented from Print.
|
inlineoverride |
Not supported.
| b | The byte to write |
|
inlineprotected |
Write a complete HDLC frame with proper framing and CRC.
| data | Data to be framed |
| len | Length of data |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |