Difference between revisions of "Unit Serial"
Line 40: | Line 40: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial device type | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial device type''' <code> SERIAL_TYPE_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 57: | Line 57: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial device state | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial device state''' <code> SERIAL_STATE_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 77: | Line 77: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial device flag | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial device flag''' <code> SERIAL_FLAG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 127: | Line 127: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial read flag | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial read flag''' <code> SERIAL_READ_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 144: | Line 144: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial write flag | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial write flag''' <code> SERIAL_WRITE_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 161: | Line 161: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial status flag | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial status flag''' <code> SERIAL_STATUS_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 217: | Line 217: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Serial logging | + | <div style="font-size: 14px; padding-left: 12px;">'''Serial logging''' <code> SERIAL_LOG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 233: | Line 233: | ||
| No Serial messages | | No Serial messages | ||
|- | |- | ||
− | | | + | |colspan="2"| |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| <code>SERIAL_LOGGING_LINE_END = Chr(13) + Chr(10);</code> | | <code>SERIAL_LOGGING_LINE_END = Chr(13) + Chr(10);</code> | ||
Line 528: | Line 522: | ||
|- | |- | ||
| <code>SERIAL_DEFAULT_LOG_LEVEL:LongWord = SERIAL_LOG_LEVEL_DEBUG;</code> | | <code>SERIAL_DEFAULT_LOG_LEVEL:LongWord = SERIAL_LOG_LEVEL_DEBUG;</code> | ||
− | | style="width: | + | | style="width: 40%;"|Minimum level for Serial messages. Only messages with level greater than or equal to this will be printed. |
|- | |- | ||
|} | |} | ||
Line 534: | Line 528: | ||
|- | |- | ||
| <code>SERIAL_LOG_ENABLED:Boolean;</code> | | <code>SERIAL_LOG_ENABLED:Boolean;</code> | ||
− | | style="width: | + | | style="width: 40%;"| |
|- | |- | ||
|} | |} |
Revision as of 03:42, 27 March 2017
Return to Unit Reference
Contents
[hide]Description
Ultibo Serial interface unit
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
SERIAL_*
SERIAL_TYPE_*
SERIAL_STATE_*
SERIAL_FLAG_*
SERIAL_READ_*
SERIAL_WRITE_*
SERIAL_STATUS_*
SERIAL_LOG_*
Type definitions
Serial properties
Serial buffer
Serial enumeration callback
TSerialEnumerate = function(Serial:PSerialDevice; Data:Pointer):LongWord;
|
Serial notification callback
TSerialNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
Serial device open
TSerialDeviceOpen = function(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
|
Serial device close
TSerialDeviceClose = function(Serial:PSerialDevice):LongWord;
|
Serial device read
TSerialDeviceRead = function(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
Serial device write
TSerialDeviceWrite = function(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
Serial device status
TSerialDeviceStatus = function(Serial:PSerialDevice):LongWord;
|
Serial device properties
TSerialDeviceProperties = function(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
|
Serial device
Serial logging
Public variables
Serial logging
SERIAL_DEFAULT_LOG_LEVEL:LongWord = SERIAL_LOG_LEVEL_DEBUG;
|
Minimum level for Serial messages. Only messages with level greater than or equal to this will be printed. |
SERIAL_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
Serial functions
function SerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
function SerialDeviceCreateEx(Size:LongWord):PSerialDevice;
function SerialDeviceDestroy(Serial:PSerialDevice):LongWord;
function SerialDeviceRegister(Serial:PSerialDevice):LongWord;
function SerialDeviceDeregister(Serial:PSerialDevice):LongWord;
function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;
function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;
function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;
function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Serial logging functions
function SerialLoggingStart(Logging:PLoggingDevice):LongWord;
function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
RTL serial functions
function SysSerialOpen(BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
function SysSerialClose:LongWord;
function SysSerialRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
function SysSerialWrite(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Serial helper functions
function SerialDeviceGetDefault:PSerialDevice; inline;
function SerialDeviceSetDefault(Serial:PSerialDevice):LongWord;
function SerialDeviceCheck(Serial:PSerialDevice):PSerialDevice;
function SerialBufferReadStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
function SerialBufferReadComplete(Buffer:PSerialBuffer; Removed:LongWord):Boolean;
function SerialBufferWriteStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
function SerialBufferWriteComplete(Buffer:PSerialBuffer; Added:LongWord):Boolean;
procedure SerialLog(Level:LongWord; Serial:PSerialDevice; const AText:String);
procedure SerialLogInfo(Serial:PSerialDevice; const AText:String); inline;
procedure SerialLogError(Serial:PSerialDevice; const AText:String); inline;
procedure SerialLogDebug(Serial:PSerialDevice; const AText:String); inline;
Serial logging helper functions
function SerialLoggingDeviceAdd(Serial:PSerialDevice):LongWord;
function SerialLoggingDeviceRemove(Serial:PSerialDevice):LongWord;
function SerialLoggingDeviceParameters(Serial:PSerialDevice; const Parameters:String; var BaudRate,Parity,DataBits,StopBits:LongWord):LongWord;
function SerialLoggingFirstWord(var Value:String;const Delimiter:String):String;
function SerialLoggingDeviceEnum(Serial:PSerialDevice; Data:Pointer):LongWord;
function SerialLoggingDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
Return to Unit Reference