Unit Serial

From Ultibo.org
Revision as of 04:30, 2 September 2016 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


Description


Serial devices represent a communication device that can be both read and written and has a set of common properties and capabilities. The underlying device may be an actual UART or it may be some other form of device such as a USB to Serial converter. As long as the device can implement the common capabilities then it can be accessed as a serial device without regard to the actual implementation.

Each serial device returns a set of properties that describe the capabilities of the device and includes a set of flags that indicate what features are supported.

Reads from and writes to serial devices are buffered so that varying data transfer rates can be accomodated and both reads and writes allow for non blocking so that a caller can avoid waiting for received data to be available or the device to be ready to transmit.

This unit also implements the serial logging device which can be configured via parameters in the GlobalConfig unit or from the command line.

Constants


To be documented

Type definitions


To be documented

Public variables


To be documented

Function declarations



Initialization functions

[Expand]
procedure SerialInit;
Description: Initialize the Serial unit and Serial device table


Serial functions

[Expand]
function SerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
Description: To be documented


[Expand]
function SerialDeviceClose(Serial:PSerialDevice):LongWord;
Description: To be documented


[Expand]
function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: To be documented


[Expand]
function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: To be documented


[Expand]
function SerialDeviceStatus(Serial:PSerialDevice):LongWord;
Description: To be documented


[Expand]
function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
Description: To be documented


[Expand]
function SerialDeviceCreate:PSerialDevice;
Description: Create a new Serial entry


[Expand]
function SerialDeviceCreateEx(Size:LongWord):PSerialDevice;
Description: Create a new Serial entry


[Expand]
function SerialDeviceDestroy(Serial:PSerialDevice):LongWord;
Description: Destroy an existing Serial entry


[Expand]
function SerialDeviceRegister(Serial:PSerialDevice):LongWord;
Description: Register a new Serial in the Serial table


[Expand]
function SerialDeviceFind(SerialId:LongWord):PSerialDevice;
Description: To be documented


[Expand]
function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;
Description: To be documented


[Expand]
function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;
Description: To be documented


[Expand]
function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented


Serial logging functions

[Expand]
function SerialLoggingStart(Logging:PLoggingDevice):LongWord;
Description: To be documented


[Expand]
function SerialLoggingStop(Logging:PLoggingDevice):LongWord;
Description: To be documented


[Expand]
function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
Description: To be documented


RTL serial functions

[Expand]
function SysSerialAvailable:Boolean;
Description: Check if a Serial device is available


[Expand]
function SysSerialOpen(BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
Description: Open the default Serial device ready for sending and receiving


[Expand]
function SysSerialClose:LongWord;
Description: Close the default Serial device and terminate sending and receiving


[Expand]
function SysSerialWrite(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Write data to the default Serial device


Serial helper functions

[Expand]
function SerialGetCount:LongWord; inline;
Description: Get the current Serial count


[Expand]
function SerialDeviceGetDefault:PSerialDevice; inline;
Description: Get the current default Serial device


[Expand]
function SerialDeviceSetDefault(Serial:PSerialDevice):LongWord;
Description: Set the current default Serial device


[Expand]
function SerialDeviceCheck(Serial:PSerialDevice):PSerialDevice;
Description: Check if the supplied Serial is in the Serial table


[Expand]
function SerialBufferReadComplete(Buffer:PSerialBuffer; Removed:LongWord):Boolean;
Description: Update the buffer to reflect the number of bytes removed when reading


Return to Unit Reference