OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OSDP.Net.Tracing.PacketBuffer Class Reference

Buffers incoming OSDP data from a stream and extracts complete packets. More...

Public Member Functions

 PacketBuffer ()
 Creates a new PacketBuffer with the default buffer size (4096 bytes).
 PacketBuffer (int bufferSize)
 Creates a new PacketBuffer with a specified buffer size.
bool TryExtractPacket (out byte[]? packet)
 Attempts to extract a complete OSDP packet from the buffer.
void Append (byte[] data, int count)
 Appends data to the buffer.
void Clear ()
 Clears all data from the buffer.

Properties

int Length [get]
 Gets the number of bytes currently in the buffer.

Detailed Description

Buffers incoming OSDP data from a stream and extracts complete packets.

Use this for passive monitoring or any scenario where serial/TCP data arrives in fragments that need to be reassembled into complete OSDP packets.

Definition at line 13 of file PacketBuffer.cs.

Constructor & Destructor Documentation

◆ PacketBuffer() [1/2]

OSDP.Net.Tracing.PacketBuffer.PacketBuffer ( )
inline

Creates a new PacketBuffer with the default buffer size (4096 bytes).

Definition at line 25 of file PacketBuffer.cs.

◆ PacketBuffer() [2/2]

OSDP.Net.Tracing.PacketBuffer.PacketBuffer ( int bufferSize)
inline

Creates a new PacketBuffer with a specified buffer size.

Parameters
bufferSizeThe size of the internal buffer in bytes.

Definition at line 33 of file PacketBuffer.cs.

Member Function Documentation

◆ Append()

void OSDP.Net.Tracing.PacketBuffer.Append ( byte[] data,
int count )
inline

Appends data to the buffer.

Parameters
dataThe data to append.
countThe number of bytes to append from the data array.

Definition at line 95 of file PacketBuffer.cs.

References OSDP.Net.Messages.Message.StartOfMessage.

◆ Clear()

void OSDP.Net.Tracing.PacketBuffer.Clear ( )
inline

Clears all data from the buffer.

Definition at line 119 of file PacketBuffer.cs.

◆ TryExtractPacket()

bool OSDP.Net.Tracing.PacketBuffer.TryExtractPacket ( out byte?[] packet)
inline

Attempts to extract a complete OSDP packet from the buffer.

Parameters
packetWhen successful, contains the extracted packet bytes.
Returns
True if a complete packet was extracted, false otherwise.

Definition at line 43 of file PacketBuffer.cs.

References OSDP.Net.Messages.Message.StartOfMessage.

Property Documentation

◆ Length

int OSDP.Net.Tracing.PacketBuffer.Length
get

Gets the number of bytes currently in the buffer.

Definition at line 127 of file PacketBuffer.cs.


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