OpenThread  1.05.03.02
Public Member Functions | Private Types | Private Attributes
MultiFrameBuffer< kSize > Class Template Reference

#include <hdlc.hpp>

+ Inheritance diagram for MultiFrameBuffer< kSize >:
+ Collaboration diagram for MultiFrameBuffer< kSize >:

Public Member Functions

void Clear (void)
 
void ClearSavedFrames (void)
 
void DiscardFrame (void)
 
uint8_t * GetFrame (void) const
 
uint16_t GetFrameMaxLength (void) const
 
uint16_t GetLength (void) const
 
otError GetNextSavedFrame (uint8_t *&aFrame, uint16_t &aLength)
 
uint16_t GetSkipLength (void) const
 
bool HasFrame (void) const
 
bool HasSavedFrame (void) const
 
 MultiFrameBuffer (void)
 
void SaveFrame (void)
 
otError SetLength (uint16_t aLength)
 
otError SetSkipLength (uint16_t aSkipLength)
 
- Public Member Functions inherited from FrameWritePointer
bool CanWrite (uint16_t aWriteLength) const
 
void UndoLastWrites (uint16_t aUndoLength)
 
otError WriteByte (uint8_t aByte)
 

Private Types

enum  { kHeaderTotalLengthOffset = 0, kHeaderSkipLengthOffset = sizeof(uint16_t), kHeaderSize = sizeof(uint16_t) + sizeof(uint16_t) }
 

Private Attributes

uint8_t mBuffer [kSize]
 
uint8_t * mWriteFrameStart
 

Additional Inherited Members

- Protected Member Functions inherited from FrameWritePointer
 FrameWritePointer (void)
 
- Protected Attributes inherited from FrameWritePointer
uint16_t mRemainingLength
 Number of remaining bytes available to write. More...
 
uint8_t * mWritePointer
 A pointer to current write position in the buffer. More...
 

Detailed Description

template<uint16_t kSize>
class ot::Hdlc::MultiFrameBuffer< kSize >

This class defines a template frame buffer of a given size for storing multiple frames.

The template parameter kSize specifies the total size of the buffer.

Unlike FrameBuffer class where a single frame can be stored, this class is capable of saving multiple frames in a FIFO queue format.

Member Enumeration Documentation

§ anonymous enum

anonymous enum
private
Enumerator
kHeaderTotalLengthOffset 
kHeaderSkipLengthOffset 
kHeaderSize 

Constructor & Destructor Documentation

§ MultiFrameBuffer()

MultiFrameBuffer ( void  )
inline

This constructor initializes the MultiFrameBuffer object.

Member Function Documentation

§ Clear()

void Clear ( void  )
inline

This method clears the buffer, removing current frame and all previously saved frames.

It moves the write pointer to the beginning of the buffer.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::RecoverFromRcpFailure().

§ HasFrame()

bool HasFrame ( void  ) const
inline

This method indicates whether the current frame (being written) is empty or not.

Return values
TRUECurrent frame is empty.
FALSECurrent frame is not empty.

§ SetLength()

otError SetLength ( uint16_t  aLength)
inline

This method sets the length (number of bytes) of the current frame being written.

param[in] aLength The length of current frame.

Return values
OT_ERROR_NONESuccessfully set the length of the current frame.
OT_ERROR_NO_BUFSInsufficient buffer space to hold a frame of length aLength.

§ GetLength()

uint16_t GetLength ( void  ) const
inline

This method gets the length (number of bytes) in the current frame being written into the buffer.

Returns
The length (number of bytes) in the frame.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::HandleNotification(), and RadioSpinel< InterfaceType, ProcessContextType >::HandleReceivedFrame().

§ SetSkipLength()

otError SetSkipLength ( uint16_t  aSkipLength)
inline

This method sets the length (number of bytes) of reserved buffer in front of the current frame being written.

param[in] aSkipLength The length of reserved buffer.

Return values
OT_ERROR_NONESuccessfully set the length of reserved buffer.
OT_ERROR_NO_BUFSInsufficient buffer space to hold a reserved buffer of length aLength.

§ GetSkipLength()

uint16_t GetSkipLength ( void  ) const
inline

This method gets the length (number of bytes) of reserved buffer in front of the current frame being written.

Returns
The length (number of bytes) of the reserved buffer.

§ GetFrame()

uint8_t* GetFrame ( void  ) const
inline

This method gets a pointer to the start of the current frame.

Returns
A pointer to the start of the frame.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::HandleNotification(), and RadioSpinel< InterfaceType, ProcessContextType >::HandleReceivedFrame().

§ GetFrameMaxLength()

uint16_t GetFrameMaxLength ( void  ) const
inline

This method gets the maximum length of the current frame.

Returns
The maximum length of the current frame.

§ SaveFrame()

void SaveFrame ( void  )
inline

This method saves the current frame and prepares the write pointer for a next frame to be written into the buffer.

Saved frame can be retrieved later using GetNextSavedFrame().

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::HandleNotification().

§ DiscardFrame()

void DiscardFrame ( void  )
inline

This method discards the current frame and prepares the write pointer for a next frame to be written into the buffer.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::HandleNotification(), and RadioSpinel< InterfaceType, ProcessContextType >::HandleReceivedFrame().

§ HasSavedFrame()

bool HasSavedFrame ( void  ) const
inline

This method indicates whether there are any saved frames in the buffer.

Return values
TRUEThere is at least one saved frame in the buffer.
FALSEThere is no saved frame in the buffer.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::HasPendingFrame(), and RadioSpinel< InterfaceType, ProcessContextType >::Process().

§ GetNextSavedFrame()

otError GetNextSavedFrame ( uint8_t *&  aFrame,
uint16_t &  aLength 
)
inline

This method iterates through previously saved frames in the buffer, getting a next frame in the queue.

Parameters
[in,out]aFrameOn entry, should point to a previous saved frame or nullptr to get the first frame. On exit, the pointer variable is updated to next frame or set to nullptr if there are none.
[in,out]aLengthOn entry, should be a reference to the frame length of the previous saved frame. On exit, the reference is updated to the frame length (number of bytes) of next frame.
Return values
OT_ERROR_NONEUpdated and successfully with the next saved frame.
OT_ERROR_NOT_FOUNDNo more saved frame in the buffer.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::ProcessFrameQueue().

§ ClearSavedFrames()

void ClearSavedFrames ( void  )
inline

This method clears all saved frames from the buffer and adjusts all the pointers.

Note
This method moves the pointers into the buffer and also copies the content. Any previously retrieved pointer to buffer (from GetFrame() or GetNextSavedFrame()) should be considered invalid after calling this method.

Referenced by RadioSpinel< InterfaceType, ProcessContextType >::ProcessFrameQueue().

Field Documentation

§ mBuffer

uint8_t mBuffer[kSize]
private

§ mWriteFrameStart

uint8_t* mWriteFrameStart
private

The documentation for this class was generated from the following file:
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale