Skip to main content

UartControllerApiWrapper Class

Namespace: GHIElectronics.TinyCLR.Devices.Uart.Provider · Assembly: GHIElectronics.TinyCLR.Devices.Uart

Concrete IUartControllerProvider backed by the native TinyCLR UART HAL.

public sealed class UartControllerApiWrapper : IUartControllerProvider

Constructors

UartControllerApiWrapper(NativeApi api)

public UartControllerApiWrapper(NativeApi api)

Wraps the given native API as a provider.

ParameterTypeDescription
apiNativeApi

Properties

Api

public NativeApi Api { get; }

The underlying native API descriptor.

WriteBufferSize

public extern int WriteBufferSize { get; set; }

Size in bytes of the transmit buffer. (inherited)

ReadBufferSize

public extern int ReadBufferSize { get; set; }

Size in bytes of the receive buffer. (inherited)

BytesToWrite

public extern int BytesToWrite { get; }

The number of bytes that are in the process of being written. (inherited)

BytesToRead

public extern int BytesToRead { get; }

The number of bytes available to read. (inherited)

IsRequestToSendEnabled

public extern bool IsRequestToSendEnabled { get; set; }

Drives the RTS line when hardware handshaking is enabled. (inherited)

ClearToSendState

public extern bool ClearToSendState { get; }

Current state of the CTS line. (inherited)

Methods

Dispose()

public void Dispose()

Releases the native controller.

Enable()

public extern void Enable()

Re-enables interrupts after a matching Disable. (inherited)

Disable()

public extern void Disable()

Disables interrupts on the current core. Always pair with Enable. (inherited)

SetActiveSettings(int baudRate, int dataBits, UartParity parity, UartStopBitCount stopBits, UartHandshake handshaking, bool enableDePin, bool invertTxPolarity, bool invertRxPolarity, bool invertBinaryData, bool swapTxRxPin, bool invertDePolarity)

public extern void SetActiveSettings(int baudRate, int dataBits, UartParity parity, UartStopBitCount stopBits, UartHandshake handshaking, bool enableDePin, bool invertTxPolarity, bool invertRxPolarity, bool invertBinaryData, bool swapTxRxPin, bool invertDePolarity)

Applies a complete set of serial settings. (inherited)

ParameterTypeDescription
baudRateint
dataBitsint
parityUartParity
stopBitsUartStopBitCount
handshakingUartHandshake
enableDePinbool
invertTxPolaritybool
invertRxPolaritybool
invertBinaryDatabool
swapTxRxPinbool
invertDePolaritybool

Flush()

public extern void Flush()

Writes unwritten data to the file. (inherited)

Read(byte[] buffer, int offset, int length)

public extern int Read(byte[] buffer, int offset, int length)

Reads a block of bytes from the stream. (inherited)

ParameterTypeDescription
bufferbyte[]
offsetintThe byte offset in the array at which read bytes will be placed.
lengthint

Returns int

Write(byte[] buffer, int offset, int length, TimeSpan breakDuration)

public extern int Write(byte[] buffer, int offset, int length, TimeSpan breakDuration)

Writes length bytes; optional trailing break of breakDuration. (inherited)

ParameterTypeDescription
bufferbyte[]
offsetint
lengthint
breakDurationTimeSpan

Returns int

ClearWriteBuffer()

public extern void ClearWriteBuffer()

Empties the transmit buffer. (inherited)

ClearReadBuffer()

public extern void ClearReadBuffer()

Empties the receive buffer. (inherited)

Events

ClearToSendChanged

public event ClearToSendChangedEventHandler ClearToSendChanged

Raised when CTS changes state. (inherited)

DataReceived

public event DataReceivedEventHandler DataReceived

Raised when receive data becomes available. (inherited)

ErrorReceived

public event ErrorReceivedEventHandler ErrorReceived

Raised when a frame/parity/overrun error is detected. (inherited)