Difference between revisions of "Unit Serial"
(13 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 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 | 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 | ||
Line 12: | Line 12: | ||
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. |
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 27: | 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 33: | 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 51: | Line 61: | ||
|- | |- | ||
| <code>SERIAL_TYPE_USB = 2;</code> | | <code>SERIAL_TYPE_USB = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_TYPE_MAX = 2;</code> | ||
| | | | ||
|- | |- | ||
Line 71: | Line 86: | ||
|- | |- | ||
| <code>SERIAL_STATE_OPEN = 3;</code> | | <code>SERIAL_STATE_OPEN = 3;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SERIAL_STATE_MAX = 3;</code> | ||
| | | | ||
|- | |- | ||
Line 122: | 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 156: | Line 182: | ||
| <code>SERIAL_WRITE_PEEK_BUFFER = $00000002;</code> | | <code>SERIAL_WRITE_PEEK_BUFFER = $00000002;</code> | ||
| Return the number of bytes free in the transmit buffer without writing anything | | Return the number of bytes free in the transmit buffer without writing anything | ||
+ | |- | ||
+ | |} | ||
+ | </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 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 | ||
|- | |- | ||
|} | |} | ||
Line 226: | 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 369: | Line 432: | ||
|} | |} | ||
− | '''Serial device | + | '''Serial device wait''' |
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
|- | |- | ||
− | | <code> | + | | <code>TSerialDeviceWait = function(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;</code> |
| style="width: 40%;"| | | style="width: 40%;"| | ||
|- | |- | ||
|} | |} | ||
− | '''Serial device | + | '''Serial device flush''' |
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
|- | |- | ||
− | | <code> | + | | <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%;"| | | 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''' | '''Serial device''' | ||
Line 424: | Line 523: | ||
| A Device specific DeviceWrite method implementing the standard Serial device interface (Mandatory) | | A Device specific DeviceWrite method implementing the standard Serial device interface (Mandatory) | ||
|- | |- | ||
− | | <code> | + | | <code>DeviceWait:TSerialDeviceWait;</code> |
− | | A Device specific | + | | A Device specific DeviceWait method implementing the standard Serial device interface (Or nil if the default method is suitable) |
|- | |- | ||
− | | <code> | + | | <code>DeviceFlush:TSerialDeviceFlush;</code> |
− | | A Device specific | + | | 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'' | |colspan="2"|''Driver Properties'' | ||
Line 545: | Line 656: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 556: | 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 568: | 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 580: | 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 592: | 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 603: | 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 615: | 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 632: | 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 644: | 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 659: | 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 671: | 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 683: | 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 691: | 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 703: | 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 715: | 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 727: | 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 739: | 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 754: | 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 766: | 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 778: | 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 797: | 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 809: | 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 839: | 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 851: | 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 869: | 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 885: | 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 897: | 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 914: | 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 926: | 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 938: | 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 950: | 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 962: | 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 974: | 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 986: | 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 998: | 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 1,010: | 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 1,022: | 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 1,034: | 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 1,046: | 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 1,057: | 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 1,069: | 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 1,085: | 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 1,097: | 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 1,105: | 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 1,117: | 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
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_NAME_PREFIX = 'Serial';
|
Name prefix for Serial Devices |
SERIAL_LOGGING_DESCRIPTION = 'Serial Logging';
|
|
SERIAL_RECEIVE_DEPTH_DEFAULT = SIZE_2K;
|
Default receive buffer size in bytes |
SERIAL_TRANSMIT_DEPTH_DEFAULT = SIZE_2K;
|
Default transmit buffer size in bytes |
SERIAL_PUSH_TIMEOUT = 50;
|
Timeout (Milliseconds) for Push RX/TX (Implementation specific) |
SERIAL_TYPE_*
SERIAL_TYPE_NONE = 0;
|
|
SERIAL_TYPE_UART = 1;
|
|
SERIAL_TYPE_USB = 2;
|
|
SERIAL_TYPE_MAX = 2;
|
SERIAL_STATE_*
SERIAL_STATE_CLOSED = 0;
|
|
SERIAL_STATE_CLOSING = 1;
|
|
SERIAL_STATE_OPENING = 2;
|
|
SERIAL_STATE_OPEN = 3;
|
|
SERIAL_STATE_MAX = 3;
|
SERIAL_FLAG_*
SERIAL_FLAG_NONE = $00000000;
|
|
SERIAL_FLAG_DATA_8BIT = $00000001;
|
Device supports 8 data bits |
SERIAL_FLAG_DATA_7BIT = $00000002;
|
Device supports 7 data bits |
SERIAL_FLAG_DATA_6BIT = $00000004;
|
Device supports 6 data bits |
SERIAL_FLAG_DATA_5BIT = $00000008;
|
Device supports 5 data bits |
SERIAL_FLAG_STOP_1BIT = $00000010;
|
Device supports 1 stop bit |
SERIAL_FLAG_STOP_2BIT = $00000020;
|
Device supports 2 stop bits |
SERIAL_FLAG_STOP_1BIT5 = $00000040;
|
Device supports 1.5 stop bits |
SERIAL_FLAG_PARITY_ODD = $00000080;
|
Device supports odd parity |
SERIAL_FLAG_PARITY_EVEN = $00000100;
|
Device supports even parity |
SERIAL_FLAG_PARITY_MARK = $00000200;
|
Device supports mark parity |
SERIAL_FLAG_PARITY_SPACE = $00000400;
|
Device supports space parity |
SERIAL_FLAG_FLOW_RTS_CTS = $00000800;
|
Device supports RTS/CTS flow control |
SERIAL_FLAG_FLOW_DSR_DTR = $00001000;
|
Device supports DSR/DTR flow control |
SERIAL_FLAG_PUSH_RX = $00002000;
|
Device requires pushed receive (Implementation specific) |
SERIAL_FLAG_PUSH_TX = $00004000;
|
Device requires pushed transmit (Implementation specific) |
SERIAL_READ_*
SERIAL_READ_NONE = $00000000;
|
|
SERIAL_READ_NON_BLOCK = $00000001;
|
Do not block when reading, if the buffer is empty return immediately |
SERIAL_READ_PEEK_BUFFER = $00000002;
|
Return the number of bytes available in the receive buffer without reading them |
SERIAL_WRITE_*
SERIAL_WRITE_NONE = $00000000;
|
|
SERIAL_WRITE_NON_BLOCK = $00000001;
|
Do not block when writing, if the buffer is full return immediately |
SERIAL_WRITE_PEEK_BUFFER = $00000002;
|
Return the number of bytes free in the transmit buffer without writing anything |
SERIAL_WAIT_*
SERIAL_WAIT_NONE = 0;
|
|
SERIAL_WAIT_RECEIVE = 1;
|
Wait for data to be available in the receive buffer |
SERIAL_WAIT_TRANSMIT = 2;
|
Wait for space to be available in the transmit buffer |
SERIAL_FLUSH_*
SERIAL_FLUSH_NONE = $00000000;
|
|
SERIAL_FLUSH_RECEIVE = $00000001;
|
Flush the receive buffer |
SERIAL_FLUSH_TRANSMIT = $00000002;
|
Flush the transmit buffer |
SERIAL_STATUS_*
SERIAL_STATUS_NONE = $00000000;
|
|
SERIAL_STATUS_RTS = $00000001;
|
RTS (Request to Send) is set (If applicable) |
SERIAL_STATUS_CTS = $00000002;
|
CTS (Clear to Send) is set (If applicable) |
SERIAL_STATUS_DSR = $00000004;
|
DSR (Data Set Ready) is set (If applicable) |
SERIAL_STATUS_DTR = $00000008;
|
DTR (Data Terminal Ready) is set (If applicable) |
SERIAL_STATUS_RX_FULL = $00000010;
|
Receive buffer is full |
SERIAL_STATUS_RX_EMPTY = $00000020;
|
Receive buffer is empty |
SERIAL_STATUS_TX_FULL = $00000040;
|
Transmit buffer is full |
SERIAL_STATUS_TX_EMPTY = $00000080;
|
Transmit buffer is empty |
SERIAL_STATUS_BUSY = $00000100;
|
Device is busy |
SERIAL_STATUS_BREAK_ERROR = $00000200;
|
Break error reported |
SERIAL_STATUS_PARITY_ERROR = $00000400;
|
Parity error reported |
SERIAL_STATUS_FRAMING_ERROR = $00000800;
|
Framing error reported |
SERIAL_STATUS_OVERRUN_ERROR = $00001000;
|
Overrun error reported |
SERIAL_STATUS_DCD = $00002000;
|
DCD (Data Carrier Detect) is set (If applicable) |
SERIAL_STATUS_RI = $00004000;
|
RI (Ring Indicator) is set (If applicable) |
SERIAL_LOG_*
SERIAL_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
Serial debugging messages |
SERIAL_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
Serial informational messages, such as a device being attached or detached |
SERIAL_LOG_LEVEL_WARN = LOG_LEVEL_WARN;
|
Serial warning messages |
SERIAL_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
Serial error messages |
SERIAL_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No Serial messages |
SERIAL_LOGGING_LINE_END = Chr(13) + Chr(10);
|
CR LF |
Type definitions
Serial properties
PSerialProperties = ^TSerialProperties;
TSerialProperties = record
Flags:LongWord;
|
Device flags (eg SERIAL_FLAG_DATA_8BIT) |
MinRate:LongWord;
|
Minimum supported baud rate (0 for any rate supported) |
MaxRate:LongWord;
|
Maximum supported baud rate (0 for any rate supported) |
BaudRate:LongWord;
|
Current baud rate setting |
DataBits:LongWord;
|
Current data bits setting |
StopBits:LongWord;
|
Current stop bits setting |
Parity:LongWord;
|
Current parity setting |
FlowControl:LongWord;
|
Current flow control setting |
ReceiveDepth:LongWord;
|
Current receive depth setting |
TransmitDepth:LongWord;
|
Current transmit depth setting |
Serial buffer
PSerialBuffer = ^TSerialBuffer;
TSerialBuffer = record
Wait:TEventHandle;
|
Data ready/Buffer free event |
Start:LongWord;
|
Index of first byte in buffer |
Count:LongWord;
|
Number of bytes in buffer |
Size:LongWord;
|
Size of buffer |
Data:Pointer;
|
Buffered data |
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
PSerialDevice = ^TSerialDevice;
TSerialDevice = record
Device Properties | |
Device:TDevice;
|
The Device entry for this Serial |
Serial Properties | |
SerialId:LongWord;
|
Unique Id of this Serial device in the Serial device table |
SerialState:LongWord;
|
Serial state (eg SERIAL_STATE_OPEN) |
SerialStatus:LongWord;
|
Serial status (eg SERIAL_STATUS_RX_FULL)(May not be real time status depending on the driver) |
DeviceOpen:TSerialDeviceOpen;
|
A Device specific DeviceOpen method implementing the standard Serial device interface (Mandatory) |
DeviceClose:TSerialDeviceClose;
|
A Device specific DeviceClose method implementing the standard Serial device interface (Mandatory) |
DeviceRead:TSerialDeviceRead;
|
A Device specific DeviceRead method implementing the standard Serial device interface (Mandatory) |
DeviceWrite:TSerialDeviceWrite;
|
A Device specific DeviceWrite method implementing the standard Serial device interface (Mandatory) |
DeviceWait:TSerialDeviceWait;
|
A Device specific DeviceWait method implementing the standard Serial device interface (Or nil if the default method is suitable) |
DeviceFlush:TSerialDeviceFlush;
|
A Device specific DeviceFlush method implementing the standard Serial device interface (Or nil if the default method is suitable) |
DeviceGetStatus:TSerialDeviceGetStatus;
|
A Device specific DeviceGetStatus method implementing the standard Serial device interface (Or nil if the default method is suitable) |
DeviceSetStatus:TSerialDeviceSetStatus;
|
A Device specific DeviceSetStatus method implementing the standard Serial device interface (Optional) |
DeviceGetProperties:TSerialDeviceGetProperties;
|
A Device specific DeviceGetProperties method implementing the standard Serial device interface (Or nil if the default method is suitable) |
DeviceSetProperties:TSerialDeviceSetProperties;
|
A Device specific DeviceSetProperties method implementing the standard Serial device interface (Or nil if the default method is suitable) |
Driver Properties | |
Lock:TMutexHandle;
|
Device lock |
Receive:TSerialBuffer;
|
Serial receive buffer |
Transmit:TSerialBuffer;
|
Serial transmit buffer |
Properties:TSerialProperties;
|
Device properties |
Statistics Properties | |
ReceiveCount:LongWord;
|
|
ReceiveErrors:LongWord;
|
|
ReceiveOverruns:LongWord;
|
|
TransmitCount:LongWord;
|
|
TransmitErrors:LongWord;
|
|
TransmitOverruns:LongWord;
|
|
Internal Properties | |
Prev:PSerialDevice;
|
Previous entry in Serial table |
Next:PSerialDevice;
|
Next entry in Serial table |
Serial logging
PSerialLogging = ^TSerialLogging;
TSerialLogging = record
Logging Properties | |
Logging:TLoggingDevice;
|
|
Serial Properties | |
Serial:PSerialDevice;
|
|
BaudRate:LongWord;
|
|
DataBits:LongWord;
|
|
StopBits:LongWord;
|
|
Parity:LongWord;
|
|
FlowControl:LongWord;
|
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
procedure SerialInit;
Note | None documented |
---|
Serial functions
function SerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
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 |
function SerialDeviceClose(Serial:PSerialDevice):LongWord;
Serial | The Serial device to close |
---|---|
Note | ERROR_SUCCESS if completed or another error code on failure |
function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
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 |
function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
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 |
function SerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;
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 |
function SerialDeviceFlush(Serial:PSerialDevice; Flags:LongWord):LongWord;
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 |
function SerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;
Serial | The Serial device to get the status from |
---|---|
Return | A set of flags containing the device status (eg SERIAL_STATUS_RTS) |
function SerialDeviceGetStatus(Serial:PSerialDevice):LongWord;
Serial | The Serial device to get the status from |
---|---|
Return | A set of flags containing the device status (eg SERIAL_STATUS_RTS) |
function SerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;
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. |
function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord; inline;
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 |
function SerialDeviceGetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
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 |
function SerialDeviceSetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
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 |
function SerialDeviceCreate:PSerialDevice;
Return | Pointer to new Serial entry or nil if Serial could not be created |
---|
function SerialDeviceCreateEx(Size:LongWord):PSerialDevice;
Size | 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 |
function SerialDeviceDestroy(Serial:PSerialDevice):LongWord;
Serial | The serial device to destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function SerialDeviceRegister(Serial:PSerialDevice):LongWord;
Serial | The serial device to register |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function SerialDeviceDeregister(Serial:PSerialDevice):LongWord;
Serial | The serial device to deregister |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function SerialDeviceFind(SerialId:LongWord):PSerialDevice;
SerialId | The Id number of the serial to find |
---|---|
Return | Pointer to serial device entry or nil if not found |
function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;
Name | The name of the serial to find (eg Serial0) |
---|---|
Return | Pointer to serial device entry or nil if not found |
function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;
Description | The description of the serial to find (eg BCM2836 PL011 UART) |
---|---|
Return | Pointer to serial device entry or nil if not found |
function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;
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 |
function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
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) |
Serial logging functions
function SerialLoggingStart(Logging:PLoggingDevice):LongWord;
Note | Not intended to be called directly by applications, use LoggingDeviceStart instead. |
---|
function SerialLoggingStop(Logging:PLoggingDevice):LongWord;
Note | Not intended to be called directly by applications, use LoggingDeviceStop instead. |
---|
function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
Note | Not intended to be called directly by applications, use LoggingDeviceOutput instead. |
---|
function SerialLoggingSetTarget(Logging:PLoggingDevice; const Target:String):LongWord;
Note | Not intended to be called directly by applications, use LoggingDeviceSetTarget instead. |
---|
RTL text IO functions
function SysTextIOReadChar(var ACh:Char; AUserData:Pointer):Boolean;
Note | Not intended to be called directly by applications |
---|
function SysTextIOWriteChar(ACh:Char; AUserData:Pointer):Boolean;
Note | Not intended to be called directly by applications |
---|
function SysTextIOWriteBuffer(ABuffer:PChar; ACount:LongInt; AUserData:Pointer):LongInt;
Note | Not intended to be called directly by applications |
---|
RTL serial functions
function SysSerialAvailable:Boolean;
Note | None documented |
---|
function SysSerialOpen(BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
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) |
function SysSerialClose:LongWord;
Note | None documented |
---|
function SysSerialRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Buffer | Pointer to a buffer to receive the data |
---|---|
Size | The size of the buffer |
Count | The number of bytes read on return |
function SysSerialWrite(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Buffer | Pointer to a buffer of data to transmit |
---|---|
Size | The size of the buffer |
Count | The number of bytes written on return |
Serial helper functions
function SerialGetCount:LongWord;
Note | None documented |
---|
function SerialDeviceGetDefault:PSerialDevice;
Note | None documented |
---|
function SerialDeviceSetDefault(Serial:PSerialDevice):LongWord;
Note | None documented |
---|
function SerialDeviceCheck(Serial:PSerialDevice):PSerialDevice;
Note | None documented |
---|
function SerialTypeToString(SerialType:LongWord):String;
Note | None documented |
---|
function SerialStateToString(SerialState:LongWord):String;
Note | None documented |
---|
function SerialDeviceRedirectInput(Serial:PSerialDevice):Boolean;
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. |
function SerialDeviceRedirectOutput(Serial:PSerialDevice):Boolean;
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. |
function SerialBufferReadStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
Note | Caller must hold the lock on the serial device which owns the buffer |
---|
function SerialBufferReadComplete(Buffer:PSerialBuffer; Removed:LongWord):Boolean;
Note | Caller must hold the lock on the serial device which owns the buffer |
---|
function SerialBufferWriteStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
Note | Caller must hold the lock on the serial device which owns the buffer |
---|
function SerialBufferWriteComplete(Buffer:PSerialBuffer; Added:LongWord):Boolean;
Note | Caller must hold the lock on the serial device which owns the buffer |
---|
procedure SerialLog(Level:LongWord; Serial:PSerialDevice; const AText:String);
Note | None documented |
---|
procedure SerialLogInfo(Serial:PSerialDevice; const AText:String); inline;
Note | None documented |
---|
procedure SerialLogWarn(Serial:PSerialDevice; const AText:String); inline;
Note | None documented |
---|
procedure SerialLogError(Serial:PSerialDevice; const AText:String); inline;
Note | None documented |
---|
procedure SerialLogDebug(Serial:PSerialDevice; const AText:String); inline;
Note | None documented |
---|
function SerialDataBitsToString(Parity:LongWord):String;
Note | None documented |
---|
function SerialStopBitsToString(Parity:LongWord):String;
Note | None documented |
---|
function SerialParityToString(Parity:LongWord):String;
Note | None documented |
---|
function SerialFlowControlToString(Flow:LongWord):String;
Note | None documented |
---|
Serial logging helper functions
function SerialLoggingDeviceAdd(Serial:PSerialDevice):LongWord;
Note | None documented |
---|
function SerialLoggingDeviceRemove(Serial:PSerialDevice):LongWord;
Note | None documented |
---|
function SerialLoggingDeviceParameters(Serial:PSerialDevice; const Parameters:String; var BaudRate,Parity,DataBits,StopBits:LongWord):LongWord;
Note | The parameters must be in the form 'BaudRate,Parity,DataBits,StopBits' (eg '115200,N,8,1') |
---|
function SerialLoggingFirstWord(var Value:String;const Delimiter:String):String;
Note | None documented |
---|
function SerialLoggingDeviceEnum(Serial:PSerialDevice; Data:Pointer):LongWord;
Note | Not intended to be called directly by applications |
---|
function SerialLoggingDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
Note | Not intended to be called directly by applications |
---|
Return to Unit Reference