Difference between revisions of "Unit Serial"
(21 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Ultibo Serial | + | '''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 | + | 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 |
− | 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. | 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. | 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 | + | Reads from and writes to serial devices are buffered so that varying data transfer rates can be accommodated 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. |
− | 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. | This unit also implements the serial logging device which can be configured via parameters in the GlobalConfig unit or from the command line. | ||
Line 29: | Line 27: | ||
| <code>SERIAL_NAME_PREFIX = 'Serial';</code> | | <code>SERIAL_NAME_PREFIX = 'Serial';</code> | ||
| Name prefix for Serial Devices | | Name prefix for Serial Devices | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_LOGGING_DESCRIPTION = 'Serial Logging';</code> | ||
+ | | | ||
|- | |- | ||
|colspan="2"| | |colspan="2"| | ||
Line 35: | Line 38: | ||
| Default receive buffer size in bytes | | Default receive buffer size in bytes | ||
|- | |- | ||
− | | <code> | + | | <code>SERIAL_TRANSMIT_DEPTH_DEFAULT = SIZE_2K;</code> |
| Default transmit buffer size in bytes | | Default transmit buffer size in bytes | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_PUSH_TIMEOUT = 50;</code> | ||
+ | | Timeout (Milliseconds) for Push RX/TX (Implementation specific) | ||
|- | |- | ||
|} | |} | ||
Line 42: | Line 50: | ||
<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 53: | Line 61: | ||
|- | |- | ||
| <code>SERIAL_TYPE_USB = 2;</code> | | <code>SERIAL_TYPE_USB = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_TYPE_MAX = 2;</code> | ||
| | | | ||
|- | |- | ||
Line 59: | Line 72: | ||
<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 73: | Line 86: | ||
|- | |- | ||
| <code>SERIAL_STATE_OPEN = 3;</code> | | <code>SERIAL_STATE_OPEN = 3;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_STATE_MAX = 3;</code> | ||
| | | | ||
|- | |- | ||
Line 79: | Line 97: | ||
<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 124: | Line 142: | ||
| <code>SERIAL_FLAG_FLOW_DSR_DTR = $00001000;</code> | | <code>SERIAL_FLAG_FLOW_DSR_DTR = $00001000;</code> | ||
| Device supports DSR/DTR flow control | | Device supports DSR/DTR flow control | ||
+ | |- | ||
+ | | <code>SERIAL_FLAG_PUSH_RX = $00002000;</code> | ||
+ | | Device requires pushed receive (Implementation specific) | ||
+ | |- | ||
+ | | <code>SERIAL_FLAG_PUSH_TX = $00004000;</code> | ||
+ | | Device requires pushed transmit (Implementation specific) | ||
|- | |- | ||
|} | |} | ||
Line 129: | Line 153: | ||
<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 146: | Line 170: | ||
<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 163: | Line 187: | ||
<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 wait directions''' <code> SERIAL_WAIT_* </code></div> |
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>SERIAL_WAIT_NONE = 0;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SERIAL_WAIT_RECEIVE = 1;</code> | ||
+ | | Wait for data to be available in the receive buffer | ||
+ | |- | ||
+ | | <code>SERIAL_WAIT_TRANSMIT = 2;</code> | ||
+ | | Wait for space to be available in the transmit buffer | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <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 flush flag''' <code> SERIAL_FLUSH_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>SERIAL_FLUSH_NONE = $00000000;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SERIAL_FLUSH_RECEIVE = $00000001;</code> | ||
+ | | Flush the receive buffer | ||
+ | |- | ||
+ | | <code>SERIAL_FLUSH_TRANSMIT = $00000002;</code> | ||
+ | | Flush the transmit buffer | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <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''' <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 219: | Line 277: | ||
<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 228: | Line 286: | ||
| <code>SERIAL_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | | <code>SERIAL_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | ||
| Serial informational messages, such as a device being attached or detached | | Serial informational messages, such as a device being attached or detached | ||
+ | |- | ||
+ | | <code>SERIAL_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code> | ||
+ | | Serial warning messages | ||
|- | |- | ||
| <code>SERIAL_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | | <code>SERIAL_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | ||
Line 234: | Line 295: | ||
| <code>SERIAL_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code> | | <code>SERIAL_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code> | ||
| No Serial messages | | No Serial messages | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_LOGGING_LINE_END = Chr(13) + Chr(10);</code> | ||
+ | | CR LF | ||
|- | |- | ||
|} | |} | ||
Line 242: | Line 308: | ||
---- | ---- | ||
− | '' | + | |
+ | '''Serial properties''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PSerialProperties = ^TSerialProperties;</code> | ||
+ | |||
+ | <code>TSerialProperties = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Flags:LongWord;</code> | ||
+ | | Device flags (eg SERIAL_FLAG_DATA_8BIT) | ||
+ | |- | ||
+ | | <code>MinRate:LongWord;</code> | ||
+ | | Minimum supported baud rate (0 for any rate supported) | ||
+ | |- | ||
+ | | <code>MaxRate:LongWord;</code> | ||
+ | | Maximum supported baud rate (0 for any rate supported) | ||
+ | |- | ||
+ | | <code>BaudRate:LongWord;</code> | ||
+ | | Current baud rate setting | ||
+ | |- | ||
+ | | <code>DataBits:LongWord;</code> | ||
+ | | Current data bits setting | ||
+ | |- | ||
+ | | <code>StopBits:LongWord;</code> | ||
+ | | Current stop bits setting | ||
+ | |- | ||
+ | | <code>Parity:LongWord;</code> | ||
+ | | Current parity setting | ||
+ | |- | ||
+ | | <code>FlowControl:LongWord;</code> | ||
+ | | Current flow control setting | ||
+ | |- | ||
+ | | <code>ReceiveDepth:LongWord;</code> | ||
+ | | Current receive depth setting | ||
+ | |- | ||
+ | | <code>TransmitDepth:LongWord;</code> | ||
+ | | Current transmit depth setting | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''Serial buffer''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PSerialBuffer = ^TSerialBuffer;</code> | ||
+ | |||
+ | <code>TSerialBuffer = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Wait:TEventHandle;</code> | ||
+ | | Data ready/Buffer free event | ||
+ | |- | ||
+ | | <code>Start:LongWord;</code> | ||
+ | | Index of first byte in buffer | ||
+ | |- | ||
+ | | <code>Count:LongWord;</code> | ||
+ | | Number of bytes in buffer | ||
+ | |- | ||
+ | | <code>Size:LongWord;</code> | ||
+ | | Size of buffer | ||
+ | |- | ||
+ | | <code>Data:Pointer;</code> | ||
+ | | Buffered data | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''Serial enumeration callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialEnumerate = function(Serial:PSerialDevice; Data:Pointer):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial notification callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device open''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceOpen = function(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device close''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceClose = function(Serial:PSerialDevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device read''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceRead = function(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device write''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceWrite = function(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device wait''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceWait = function(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device flush''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceFlush = function(Serial:PSerialDevice;Flags:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device get status''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceGetStatus = function(Serial:PSerialDevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device set status''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceSetStatus = function(Serial:PSerialDevice; Status:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device get properties''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceGetProperties = function(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device set properties''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSerialDeviceSetProperties = function(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''Serial device''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PSerialDevice = ^TSerialDevice;</code> | ||
+ | |||
+ | <code>TSerialDevice = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''Device Properties'' | ||
+ | |- | ||
+ | | <code>Device:TDevice;</code> | ||
+ | | The Device entry for this Serial | ||
+ | |- | ||
+ | |colspan="2"|''Serial Properties'' | ||
+ | |- | ||
+ | | <code>SerialId:LongWord;</code> | ||
+ | | Unique Id of this Serial device in the Serial device table | ||
+ | |- | ||
+ | | <code>SerialState:LongWord;</code> | ||
+ | | Serial state (eg SERIAL_STATE_OPEN) | ||
+ | |- | ||
+ | | <code>SerialStatus:LongWord;</code> | ||
+ | | Serial status (eg SERIAL_STATUS_RX_FULL)(May not be real time status depending on the driver) | ||
+ | |- | ||
+ | | <code>DeviceOpen:TSerialDeviceOpen;</code> | ||
+ | | A Device specific DeviceOpen method implementing the standard Serial device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceClose:TSerialDeviceClose;</code> | ||
+ | | A Device specific DeviceClose method implementing the standard Serial device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceRead:TSerialDeviceRead;</code> | ||
+ | | A Device specific DeviceRead method implementing the standard Serial device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceWrite:TSerialDeviceWrite;</code> | ||
+ | | A Device specific DeviceWrite method implementing the standard Serial device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceWait:TSerialDeviceWait;</code> | ||
+ | | A Device specific DeviceWait method implementing the standard Serial device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceFlush:TSerialDeviceFlush;</code> | ||
+ | | A Device specific DeviceFlush method implementing the standard Serial device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceGetStatus:TSerialDeviceGetStatus;</code> | ||
+ | | A Device specific DeviceGetStatus method implementing the standard Serial device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceSetStatus:TSerialDeviceSetStatus;</code> | ||
+ | | A Device specific DeviceSetStatus method implementing the standard Serial device interface (Optional) | ||
+ | |- | ||
+ | | <code>DeviceGetProperties:TSerialDeviceGetProperties;</code> | ||
+ | | A Device specific DeviceGetProperties method implementing the standard Serial device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceSetProperties:TSerialDeviceSetProperties;</code> | ||
+ | | A Device specific DeviceSetProperties method implementing the standard Serial device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | |colspan="2"|''Driver Properties'' | ||
+ | |- | ||
+ | | <code>Lock:TMutexHandle;</code> | ||
+ | | Device lock | ||
+ | |- | ||
+ | | <code>Receive:TSerialBuffer;</code> | ||
+ | | Serial receive buffer | ||
+ | |- | ||
+ | | <code>Transmit:TSerialBuffer;</code> | ||
+ | | Serial transmit buffer | ||
+ | |- | ||
+ | | <code>Properties:TSerialProperties;</code> | ||
+ | | Device properties | ||
+ | |- | ||
+ | |colspan="2"|''Statistics Properties'' | ||
+ | |- | ||
+ | | <code>ReceiveCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>ReceiveErrors:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>ReceiveOverruns:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>TransmitCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>TransmitErrors:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>TransmitOverruns:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''Internal Properties'' | ||
+ | |- | ||
+ | | <code>Prev:PSerialDevice;</code> | ||
+ | | Previous entry in Serial table | ||
+ | |- | ||
+ | | <code>Next:PSerialDevice;</code> | ||
+ | | Next entry in Serial table | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''Serial logging''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PSerialLogging = ^TSerialLogging;</code> | ||
+ | |||
+ | <code>TSerialLogging = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''Logging Properties'' | ||
+ | |- | ||
+ | | <code>Logging:TLoggingDevice;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|''Serial Properties'' | ||
+ | |- | ||
+ | | <code>Serial:PSerialDevice;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BaudRate:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>DataBits:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>StopBits:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>Parity:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FlowControl:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
---- | ---- | ||
− | '' | + | |
+ | '''Serial logging''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>SERIAL_DEFAULT_LOG_LEVEL:LongWord = SERIAL_LOG_LEVEL_DEBUG;</code> | ||
+ | | style="width: 40%;"|Minimum level for Serial messages. Only messages with level greater than or equal to this will be printed. | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>SERIAL_LOG_ENABLED:Boolean;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | <br /> | ||
=== Function declarations === | === Function declarations === | ||
Line 261: | Line 656: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 272: | Line 667: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Open a Serial device ready for sending and receiving</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The Serial device to open |
+ | |- | ||
+ | ! BaudRate | ||
+ | | Baud rate for the connection (eg 9600, 57600, 115200 etc) | ||
+ | |- | ||
+ | ! DataBits | ||
+ | | Size of the data (eg SERIAL_DATA_8BIT) | ||
+ | |- | ||
+ | ! StopBits | ||
+ | | Number of stop bits (eg SERIAL_STOP_1BIT) | ||
+ | |- | ||
+ | ! Parity | ||
+ | | Parity type for the data (eg SERIAL_PARITY_NONE) | ||
+ | |- | ||
+ | ! FlowControl | ||
+ | | Flow control for the connection (eg SERIAL_FLOW_NONE) | ||
+ | |- | ||
+ | ! ReceiveDepth | ||
+ | | Size of the receive buffer (0 = Default size) | ||
+ | |- | ||
+ | ! TransmitDepth | ||
+ | | Size of the transmit buffer (0 = Default size) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 284: | Line 703: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceClose(Serial:PSerialDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceClose(Serial:PSerialDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Close a Serial device and terminate sending and receiving</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The Serial device to close |
+ | |- | ||
+ | ! Note | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 296: | Line 718: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read data from a Serial device</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The Serial device to read from |
+ | |- | ||
+ | ! Buffer | ||
+ | | Pointer to a buffer to receive the data | ||
+ | |- | ||
+ | ! Size | ||
+ | | The size of the buffer | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control reading (eg SERIAL_READ_NON_BLOCK) | ||
+ | |- | ||
+ | ! Count | ||
+ | | The number of bytes read on return | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 308: | Line 745: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to a Serial device</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The Serial device to write to |
+ | |- | ||
+ | ! Buffer | ||
+ | | Pointer to a buffer of data to transmit | ||
+ | |- | ||
+ | ! Size | ||
+ | | The size of the buffer | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control writing (eg SERIAL_WRITE_NON_BLOCK) | ||
+ | |- | ||
+ | ! Count | ||
+ | | The number of bytes written on return | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 319: | Line 771: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function | + | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;</pre> |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Wait for data to be available in the receive or transmit buffers of a Serial device</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The Serial device to wait for |
+ | |- | ||
+ | ! Direction | ||
+ | | The direction of data to wait for (eg SERIAL_WAIT_RECEIVE) | ||
+ | |- | ||
+ | ! Timeout | ||
+ | | The number of milliseconds to wait for data (INFINITE to wait forever) | ||
+ | |- | ||
+ | ! Count | ||
+ | | The number of bytes available on return | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 331: | Line 795: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function | + | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceFlush(Serial:PSerialDevice; Flags:LongWord):LongWord;</pre> |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Discard the contents of the receive and/or transmit buffers of a Serial device</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;" | ||
|- | |- | ||
− | ! '''Note''' | + | ! Serial |
− | | | + | | The Serial device to flush |
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to indicate what to flush (eg SERIAL_FLUSH_RECEIVE) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current line status of a Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to get the status from | ||
+ | |- | ||
+ | ! Return | ||
+ | | A set of flags containing the device status (eg SERIAL_STATUS_RTS) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceGetStatus(Serial:PSerialDevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current line status of a Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to get the status from | ||
+ | |- | ||
+ | ! Return | ||
+ | | A set of flags containing the device status (eg SERIAL_STATUS_RTS) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current line status of a Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to set the status for | ||
+ | |- | ||
+ | ! Status | ||
+ | | The device status flags to be set (eg SERIAL_STATUS_RTS) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not all SERIAL_STATUS_* flags can be set, the device may ignore invalid values. | ||
+ | Not all serial devices support set status, returns ERROR_CALL_NOT_IMPLEMENTED if not supported. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to get properties from | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a PSerialProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Replaced by SerialDeviceGetProperties for consistency | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceGetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to get properties from | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a PSerialProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceSetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the properties for the specified Serial device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The Serial device to set properties for | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a PSerialProperties structure to use | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 348: | Line 927: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new Serial entry or nil if Serial could not be created | | Pointer to new Serial entry or nil if Serial could not be created | ||
|- | |- | ||
Line 360: | Line 939: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Size |
| Size in bytes to allocate for new Serial (Including the Serial entry) | | Size in bytes to allocate for new Serial (Including the Serial entry) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new Serial entry or nil if Serial could not be created | | Pointer to new Serial entry or nil if Serial could not be created | ||
|- | |- | ||
Line 375: | Line 954: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The serial device to destroy |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 387: | Line 969: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The serial device to register |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 399: | Line 984: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The serial device to deregister |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 407: | Line 995: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceFind(SerialId:LongWord):PSerialDevice;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceFind(SerialId:LongWord):PSerialDevice;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a serial device by Id in the serial table</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;" | ||
|- | |- | ||
− | ! | + | ! SerialId |
− | | | + | | The Id number of the serial to find |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to serial device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 419: | Line 1,010: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a serial device by name in the serial table</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;" | ||
|- | |- | ||
− | ! | + | ! Name |
− | | | + | | The name of the serial to find (eg Serial0) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to serial device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 431: | Line 1,025: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a serial device by description in the serial table</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;" | ||
|- | |- | ||
− | ! | + | ! Description |
− | | | + | | The description of the serial to find (eg BCM2836 PL011 UART) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to serial device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 443: | Line 1,040: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumerate all serial devices in the serial table</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;" | ||
|- | |- | ||
− | ! | + | ! Callback |
− | | | + | | The callback function to call for each serial in the table |
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback for each serial in the table | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 455: | Line 1,058: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a notification for serial device changes</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;" | ||
|- | |- | ||
− | ! | + | ! Serial |
− | | | + | | The serial device to notify changes for (Optional, pass nil for all serial devices) |
+ | |- | ||
+ | ! Callback | ||
+ | | The function to call when a notification event occurs | ||
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback when a notification event occurs | ||
+ | |- | ||
+ | ! Notification | ||
+ | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
|- | |- | ||
|} | |} | ||
Line 470: | Line 1,085: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingStart(Logging:PLoggingDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingStart(Logging:PLoggingDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of LoggingDeviceStart API for Serial Logging</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use LoggingDeviceStart instead. |
|- | |- | ||
|} | |} | ||
Line 482: | Line 1,097: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingStop(Logging:PLoggingDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingStop(Logging:PLoggingDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of LoggingDeviceStop API for Serial Logging</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use LoggingDeviceStop instead. |
|- | |- | ||
|} | |} | ||
Line 494: | Line 1,109: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of LoggingDeviceOutput API for Serial Logging</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;" | ||
|- | |- | ||
− | ! '''Note''' | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use LoggingDeviceOutput instead. |
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingSetTarget(Logging:PLoggingDevice; const Target:String):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of LoggingDeviceSetTarget API for Serial Logging</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use LoggingDeviceSetTarget instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RTL text IO functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysTextIOReadChar(var ACh:Char; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for platform TextIOReadChar function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysTextIOWriteChar(ACh:Char; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for platform TextIOWriteChar function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysTextIOWriteBuffer(ABuffer:PChar; ACount:LongInt; AUserData:Pointer):LongInt;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for platform TextIOWriteBuffer function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications | ||
|- | |- | ||
|} | |} | ||
Line 513: | Line 1,179: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 525: | Line 1,191: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! BaudRate |
− | | Baud rate for the connection (eg 9600, 57600, 115200 etc | + | | Baud rate for the connection (eg 9600, 57600, 115200 etc) |
|- | |- | ||
− | ! | + | ! DataBits |
| Size of the data (eg SERIAL_DATA_8BIT) | | Size of the data (eg SERIAL_DATA_8BIT) | ||
|- | |- | ||
− | ! | + | ! StopBits |
| Number of stop bits (eg SERIAL_STOP_1BIT) | | Number of stop bits (eg SERIAL_STOP_1BIT) | ||
|- | |- | ||
− | ! | + | ! Parity |
| Parity type for the data (eg SERIAL_PARITY_NONE) | | Parity type for the data (eg SERIAL_PARITY_NONE) | ||
|- | |- | ||
− | ! | + | ! FlowControl |
| Flow control for the connection (eg SERIAL_FLOW_NONE) | | Flow control for the connection (eg SERIAL_FLOW_NONE) | ||
|- | |- | ||
− | ! | + | ! ReceiveDepth |
| Size of the receive buffer (0 = Default size) | | Size of the receive buffer (0 = Default size) | ||
|- | |- | ||
− | ! | + | ! TransmitDepth |
| Size of the transmit buffer (0 = Default size) | | Size of the transmit buffer (0 = Default size) | ||
|- | |- | ||
Line 555: | Line 1,221: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 567: | Line 1,233: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to receive the data | | Pointer to a buffer to receive the data | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes read on return | | The number of bytes read on return | ||
|- | |- | ||
Line 585: | Line 1,251: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer of data to transmit | | Pointer to a buffer of data to transmit | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes written on return | | The number of bytes written on return | ||
|- | |- | ||
Line 601: | Line 1,267: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function SerialGetCount:LongWord | + | <pre style="border: 0; padding-bottom:0px;">function SerialGetCount:LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current Serial count</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current Serial count</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 613: | Line 1,279: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceGetDefault:PSerialDevice | + | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceGetDefault:PSerialDevice;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default Serial device</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default Serial device</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 630: | Line 1,296: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 642: | Line 1,308: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialTypeToString(SerialType:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Serial type value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialStateToString(SerialState:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Serial state value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceRedirectInput(Serial:PSerialDevice):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Redirect standard input to the serial device specified by Serial</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The serial device to redirect input to (or nil to stop redirection) | ||
+ | |- | ||
+ | ! Return | ||
+ | | True if completed successfully or False if an error occurred | ||
+ | |- | ||
+ | ! Note | ||
+ | | Redirects the input of the text file Input which also redirects the input of Read, ReadLn and the standard C library. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDeviceRedirectOutput(Serial:PSerialDevice):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Redirect standard output to the serial device specified by Serial</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Serial | ||
+ | | The serial device to redirect output to (or nil to stop redirection) | ||
+ | |- | ||
+ | ! Return | ||
+ | | True if completed successfully or False if an error occurred | ||
+ | |- | ||
+ | ! Note | ||
+ | | Redirects the output of the text files Output, ErrOutput, StdOut and StdErr which also redirects the output of Write, WriteLn and the standard C library. | ||
|- | |- | ||
|} | |} | ||
Line 654: | Line 1,380: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must hold the lock on the serial device which owns the buffer | | Caller must hold the lock on the serial device which owns the buffer | ||
|- | |- | ||
Line 666: | Line 1,392: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must hold the lock on the serial device which owns the buffer | | Caller must hold the lock on the serial device which owns the buffer | ||
|- | |- | ||
Line 678: | Line 1,404: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must hold the lock on the serial device which owns the buffer | | Caller must hold the lock on the serial device which owns the buffer | ||
|- | |- | ||
Line 690: | Line 1,416: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must hold the lock on the serial device which owns the buffer | | Caller must hold the lock on the serial device which owns the buffer | ||
|- | |- | ||
Line 702: | Line 1,428: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 714: | Line 1,440: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! ''' | + | ! Note |
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure SerialLogWarn(Serial:PSerialDevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
| None documented | | None documented | ||
|- | |- | ||
Line 726: | Line 1,464: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 738: | Line 1,476: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! '''Note''' | + | ! Note |
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialDataBitsToString(Parity:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SerialStopBitsToString(Parity:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
| None documented | | None documented | ||
|- | |- | ||
Line 750: | Line 1,512: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 762: | Line 1,524: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 773: | Line 1,535: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceAdd(Serial:PSerialDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceAdd(Serial:PSerialDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Add a new serial logging device on receipt of a device register notification</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 785: | Line 1,547: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceRemove(Serial:PSerialDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceRemove(Serial:PSerialDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Remove a serial logging device on receipt of a device deregister notification</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 801: | Line 1,563: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| The parameters must be in the form 'BaudRate,Parity,DataBits,StopBits' (eg '115200,N,8,1') | | The parameters must be in the form 'BaudRate,Parity,DataBits,StopBits' (eg '115200,N,8,1') | ||
|- | |- | ||
Line 813: | Line 1,575: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 821: | Line 1,583: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceEnum(Serial:PSerialDevice; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceEnum(Serial:PSerialDevice; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumeration callback for serial logging initialization</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications |
|- | |- | ||
|} | |} | ||
Line 833: | Line 1,595: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SerialLoggingDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Notification callback for serial logging device creation or remove</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;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications |
|- | |- | ||
|} | |} |
Latest revision as of 03:35, 15 December 2022
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 accommodated 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_WAIT_*
SERIAL_FLUSH_*
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 wait
TSerialDeviceWait = function(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;
|
Serial device flush
TSerialDeviceFlush = function(Serial:PSerialDevice;Flags:LongWord):LongWord;
|
Serial device get status
TSerialDeviceGetStatus = function(Serial:PSerialDevice):LongWord;
|
Serial device set status
TSerialDeviceSetStatus = function(Serial:PSerialDevice; Status:LongWord):LongWord;
|
Serial device get properties
TSerialDeviceGetProperties = function(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
|
Serial device set properties
TSerialDeviceSetProperties = 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 SerialDeviceClose(Serial:PSerialDevice):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 SerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;
function SerialDeviceFlush(Serial:PSerialDevice; Flags:LongWord):LongWord;
function SerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;
function SerialDeviceGetStatus(Serial:PSerialDevice):LongWord;
function SerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;
function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord; inline;
function SerialDeviceGetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
function SerialDeviceSetProperties(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 SerialDeviceFind(SerialId:LongWord):PSerialDevice;
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 SerialLoggingStop(Logging:PLoggingDevice):LongWord;
function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
function SerialLoggingSetTarget(Logging:PLoggingDevice; const Target:String):LongWord;
RTL text IO functions
function SysTextIOReadChar(var ACh:Char; AUserData:Pointer):Boolean;
function SysTextIOWriteChar(ACh:Char; AUserData:Pointer):Boolean;
function SysTextIOWriteBuffer(ABuffer:PChar; ACount:LongInt; AUserData:Pointer):LongInt;
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;
function SerialDeviceSetDefault(Serial:PSerialDevice):LongWord;
function SerialDeviceCheck(Serial:PSerialDevice):PSerialDevice;
function SerialTypeToString(SerialType:LongWord):String;
function SerialStateToString(SerialState:LongWord):String;
function SerialDeviceRedirectInput(Serial:PSerialDevice):Boolean;
function SerialDeviceRedirectOutput(Serial:PSerialDevice):Boolean;
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 SerialLogWarn(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