BSL430.NET  1.2.1
Public Member Functions | Protected Member Functions | Properties | Events | List of all members
RJCP.IO.Ports.Native.SerialBuffer Class Reference

Manages two buffers, for reading and writing, between a Stream and a Native Serial object. More...

Inheritance diagram for RJCP.IO.Ports.Native.SerialBuffer:
RJCP.IO.Ports.Native.ISerialBufferSerialData RJCP.IO.Ports.Native.ISerialBufferStreamData

Public Member Functions

 SerialBuffer (int readBuffer, int writeBuffer)
 Initializes a new instance of the SerialBuffer class, where the buffer is not pinned. More...
 
 SerialBuffer (int readBuffer, int writeBuffer, bool pinned)
 Initializes a new instance of the SerialBuffer class. More...
 
void Dispose ()
 Releases unmanaged and - optionally - managed resources. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Releases unmanaged and - optionally - managed resources. More...
 

Properties

ISerialBufferSerialData Serial [get]
 Access to properties and methods specific to the native serial object. More...
 
ISerialBufferStreamData Stream [get]
 Access to properties and methods specific to the native serial object. More...
 
object ReadLock [get]
 Object to use for locking access to the byte read buffer. More...
 
object WriteLock [get]
 Object to use for locking access to the byte write buffer. More...
 
- Properties inherited from RJCP.IO.Ports.Native.ISerialBufferSerialData
CircularBuffer< byte > ReadBuffer [get]
 Access the read buffer directly. More...
 
IntPtr ReadBufferOffsetEnd [get]
 Gets the read buffer offset end, used for giving to native API's. More...
 
CircularBuffer< byte > WriteBuffer [get]
 Access the write buffer directly. More...
 
IntPtr WriteBufferOffsetStart [get]
 Gets the write buffer offset start, used for giving to native API's. More...
 
bool IsPinnedBuffer [get]
 Gets a value indicating whether this instance uses a pinned buffer. More...
 
WaitHandle ReadBufferNotFull [get]
 Gets the event handle that is signalled when the read buffer is not full. More...
 
WaitHandle WriteBufferNotEmpty [get]
 Gets the event handle that is signalled when data is in the write buffer. More...
 
- Properties inherited from RJCP.IO.Ports.Native.ISerialBufferStreamData
int BytesToRead [get]
 Gets the number of bytes in the internal read buffer only. More...
 
int BytesToWrite [get]
 Gets the number of bytes in the internal write buffer only. More...
 

Events

EventHandler WriteEvent
 Event raised when data is available to write. This could be used to abort an existing connection. More...
 

Detailed Description

Manages two buffers, for reading and writing, between a Stream and a Native Serial object.

This class is used to help implement streams with time out functionality when the actual object that reads and writes data doesn't support streams, but simply reads and writes data using low level APIs.

It is to be expected that this object is only used by one reader and one writer. The reader and writer may be different threads. That is, the properties under SerialData are accessed only by one thread, the properties under StreamData are accessed only by one single (but may be different to SerialData) thread.

Constructor & Destructor Documentation

◆ SerialBuffer() [1/2]

RJCP.IO.Ports.Native.SerialBuffer.SerialBuffer ( int  readBuffer,
int  writeBuffer 
)

Initializes a new instance of the SerialBuffer class, where the buffer is not pinned.

Parameters
readBufferThe read buffer size in bytes.
writeBufferThe write buffer size in bytes.

Allocates buffer space for reading and writing (accessible via the Serial and Stream properties). The buffers are not pinned, meaning they should not be used for native methods (unless pinned explicitly).

◆ SerialBuffer() [2/2]

RJCP.IO.Ports.Native.SerialBuffer.SerialBuffer ( int  readBuffer,
int  writeBuffer,
bool  pinned 
)

Initializes a new instance of the SerialBuffer class.

Parameters
readBufferThe read buffer size in bytes.
writeBufferThe write buffer size in bytes.
pinnedif set to true then the read and write buffers are pinned.

Allocates buffer space for reading and writing (accessible via the Serial and Stream properties). If specified, the buffers can be pinned. THis causes the buffers to not move for the duration of the program. The usual warnings apply with pinning buffers, you must be careful to avoid memory problems as the GC will not be able to reallocate or free space. Note, you must pin the buffers if you intend to use overlapped I/O.

Member Function Documentation

◆ Dispose() [1/2]

void RJCP.IO.Ports.Native.SerialBuffer.Dispose ( )

Releases unmanaged and - optionally - managed resources.

◆ Dispose() [2/2]

virtual void RJCP.IO.Ports.Native.SerialBuffer.Dispose ( bool  disposing)
protectedvirtual

Releases unmanaged and - optionally - managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Property Documentation

◆ ReadLock

object RJCP.IO.Ports.Native.SerialBuffer.ReadLock
get

Object to use for locking access to the byte read buffer.

The object to use for locking access to the byte read buffer.

◆ Serial

ISerialBufferSerialData RJCP.IO.Ports.Native.SerialBuffer.Serial
get

Access to properties and methods specific to the native serial object.

Access to properties and methods specific to the native serial object.

◆ Stream

ISerialBufferStreamData RJCP.IO.Ports.Native.SerialBuffer.Stream
get

Access to properties and methods specific to the native serial object.

Access to properties and methods specific to the native serial object.

◆ WriteLock

object RJCP.IO.Ports.Native.SerialBuffer.WriteLock
get

Object to use for locking access to the byte write buffer.

The object to use for locking access to the byte write buffer.

Event Documentation

◆ WriteEvent

EventHandler RJCP.IO.Ports.Native.SerialBuffer.WriteEvent

Event raised when data is available to write. This could be used to abort an existing connection.


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