Difference between revisions of "Unit Serial"

From Ultibo.org
Jump to: navigation, search
 
(8 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo Serial interface unit'''
+
'''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 accomodated and both reads and writes allow for non blocking so that a caller can avoid waiting for received data to be available or the device to be ready to transmit.
+
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 61: Line 61:
 
|-
 
|-
 
| <code>SERIAL_TYPE_USB = 2;</code>
 
| <code>SERIAL_TYPE_USB = 2;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>SERIAL_TYPE_MAX = 2;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 81: Line 86:
 
|-
 
|-
 
| <code>SERIAL_STATE_OPEN = 3;</code>
 
| <code>SERIAL_STATE_OPEN = 3;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>SERIAL_STATE_MAX = 3;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 172: 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>
 +
| &nbsp;
 +
|-
 +
| <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
 
|-
 
|-
 
|}
 
|}
Line 259: 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 398: Line 428:
 
|-
 
|-
 
| <code>TSerialDeviceWrite = function(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</code>
 
| <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%;"|
 
| style="width: 40%;"|
 
|-
 
|-
Line 411: Line 450:
 
|}
 
|}
  
'''Serial device status'''
+
'''Serial device get status'''
  
 
{| 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>TSerialDeviceStatus = function(Serial:PSerialDevice):LongWord;</code>
+
| <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%;"|
 
| style="width: 40%;"|
 
|-
 
|-
Line 428: Line 476:
 
|-
 
|-
 
|}  
 
|}  
 +
 +
'''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 466: 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>DeviceStatus:TSerialDeviceStatus;</code>
+
| <code>DeviceWait:TSerialDeviceWait;</code>
| A Device specific DeviceStatus method implementing the standard Serial device interface (Or nil if the default method is suitable)
+
| 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>
 
| <code>DeviceGetProperties:TSerialDeviceGetProperties;</code>
 
| A Device specific DeviceGetProperties method implementing the standard Serial device interface (Or nil if the default method is suitable)
 
| 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 587: Line 656:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 602: Line 671:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to open
 
| The Serial device to open
 
|-
 
|-
! '''BaudRate'''
+
! BaudRate
| Baud rate for the connection (eg 9600, 57600, 115200 etc
+
| Baud rate for the connection (eg 9600, 57600, 115200 etc)
 
|-
 
|-
! '''DataBits'''
+
! DataBits
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
|-
 
|-
! '''StopBits'''
+
! StopBits
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
|-
 
|-
! '''Parity'''
+
! Parity
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
|-
 
|-
! '''FlowControl'''
+
! FlowControl
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
|-
 
|-
! '''ReceiveDepth'''
+
! ReceiveDepth
 
| Size of the receive buffer (0 = Default size)
 
| Size of the receive buffer (0 = Default size)
 
|-
 
|-
! '''Transmit Depth'''
+
! TransmitDepth
 
| Size of the transmit buffer (0 = Default size)
 
| Size of the transmit buffer (0 = Default size)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 638: Line 707:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to close
 
| The Serial device to close
 
|-
 
|-
! '''Note'''
+
! Note
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 653: Line 722:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to read from
 
| The Serial device to read from
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to receive the data
 
| Pointer to a buffer to receive the data
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control reading (eg SERIAL_READ_NON_BLOCK)
 
| The flags to control reading (eg SERIAL_READ_NON_BLOCK)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes read on return
 
| The number of bytes read on return
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 680: Line 749:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to write to
 
| The Serial device to write to
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer of data to transmit
 
| Pointer to a buffer of data to transmit
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control writing (eg SERIAL_WRITE_NON_BLOCK)
 
| The flags to control writing (eg SERIAL_WRITE_NON_BLOCK)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes written on return
 
| The number of bytes written on return
 
|-
 
|-
! '''Return'''
+
! 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 SerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;</pre>
 +
<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;">
 +
{| 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
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 707: Line 800:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to flush
 
| The Serial device to flush
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to indicate what to flush (eg SERIAL_FLUSH_RECEIVE)
 
| The flags to indicate what to flush (eg SERIAL_FLUSH_RECEIVE)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 720: Line 813:
 
<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 SerialDeviceStatus(Serial:PSerialDevice):LongWord;</pre>
+
<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 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;">
 
<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'''
+
! Serial
 
| The Serial device to get the status from
 
| The Serial device to get the status from
 
|-
 
|-
! '''Return'''
+
! Return
 
| A set of flags containing the device status (eg SERIAL_STATUS_RTS)
 
| 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.
 
|-
 
|-
 
|}
 
|}
Line 740: Line 870:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to get properties from
 
| The Serial device to get properties from
 
|-
 
|-
! '''Properties'''
+
! Properties
 
| Pointer to a PSerialProperties structure to fill in
 
| Pointer to a PSerialProperties structure to fill in
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Replaced by SerialDeviceGetProperties for consistency
 
| Replaced by SerialDeviceGetProperties for consistency
 
|-
 
|-
Line 761: Line 891:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The Serial device to get properties from
 
| The Serial device to get properties from
 
|-
 
|-
! '''Properties'''
+
! Properties
 
| Pointer to a PSerialProperties structure to fill in
 
| Pointer to a PSerialProperties structure to fill in
 
|-
 
|-
! '''Return'''
+
! 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
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 779: Line 927:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! 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 791: Line 939:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! 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 806: Line 954:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The serial device to destroy
 
| The serial device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 821: Line 969:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The serial device to register
 
| The serial device to register
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 836: Line 984:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The serial device to deregister
 
| The serial device to deregister
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 851: Line 999:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''SerialId'''
+
! SerialId
 
| The Id number of the serial to find
 
| The Id number of the serial to find
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to serial device entry or nil if not found
 
| Pointer to serial device entry or nil if not found
 
|-
 
|-
Line 866: Line 1,014:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Name'''
+
! Name
 
| The name of the serial to find (eg Serial0)
 
| The name of the serial to find (eg Serial0)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to serial device entry or nil if not found
 
| Pointer to serial device entry or nil if not found
 
|-
 
|-
Line 881: Line 1,029:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Description'''
+
! Description
 
| The description of the serial to find (eg BCM2836 PL011 UART)
 
| The description of the serial to find (eg BCM2836 PL011 UART)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to serial device entry or nil if not found
 
| Pointer to serial device entry or nil if not found
 
|-
 
|-
Line 896: Line 1,044:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The callback function to call for each serial in the table
 
| The callback function to call for each serial in the table
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback for each serial in the table
 
| A private data pointer to pass to callback for each serial in the table
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 914: Line 1,062:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Serial'''
+
! Serial
 
| The serial device to notify changes for (Optional, pass nil for all serial devices)
 
| The serial device to notify changes for (Optional, pass nil for all serial devices)
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The function to call when a notification event occurs
 
| The function to call when a notification event occurs
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback when a notification event occurs
 
| A private data pointer to pass to callback when a notification event occurs
 
|-
 
|-
! '''Notification'''
+
! Notification
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
|-
 
|-
Line 941: Line 1,089:
 
{| 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 LoggingDeviceStart instead
+
| Not intended to be called directly by applications, use LoggingDeviceStart instead.
 
|-
 
|-
 
|}
 
|}
Line 953: Line 1,101:
 
{| 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 LoggingDeviceStop instead
+
| Not intended to be called directly by applications, use LoggingDeviceStop instead.
 
|-
 
|-
 
|}
 
|}
Line 965: Line 1,113:
 
{| 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
+
| 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 980: Line 1,179:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 992: Line 1,191:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''BaudRate'''
+
! BaudRate
| Baud rate for the connection (eg 9600, 57600, 115200 etc
+
| Baud rate for the connection (eg 9600, 57600, 115200 etc)
 
|-
 
|-
! '''DataBits'''
+
! DataBits
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
|-
 
|-
! '''StopBits'''
+
! StopBits
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
|-
 
|-
! '''Parity'''
+
! Parity
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
|-
 
|-
! '''FlowControl'''
+
! FlowControl
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
|-
 
|-
! '''ReceiveDepth'''
+
! ReceiveDepth
 
| Size of the receive buffer (0 = Default size)
 
| Size of the receive buffer (0 = Default size)
 
|-
 
|-
! '''TransmitDepth'''
+
! TransmitDepth
 
| Size of the transmit buffer (0 = Default size)
 
| Size of the transmit buffer (0 = Default size)
 
|-
 
|-
Line 1,022: Line 1,221:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,034: Line 1,233:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to receive the data
 
| Pointer to a buffer to receive the data
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes read on return
 
| The number of bytes read on return
 
|-
 
|-
Line 1,052: Line 1,251:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer of data to transmit
 
| Pointer to a buffer of data to transmit
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes written on return
 
| The number of bytes written on return
 
|-
 
|-
Line 1,068: 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; inline;</pre>
+
<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'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,080: 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; inline;</pre>
+
<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'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,097: Line 1,296:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,109: Line 1,308:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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 1,121: Line 1,380:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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 1,133: Line 1,392:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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 1,145: Line 1,404:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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 1,157: Line 1,416:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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 1,169: Line 1,428:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,181: Line 1,440:
 
{| 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;">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,193: Line 1,464:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,205: 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,217: Line 1,512:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,229: Line 1,524:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,244: Line 1,539:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,256: Line 1,551:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,268: Line 1,563:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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,280: Line 1,575:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,292: Line 1,587:
 
{| 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
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 1,304: Line 1,599:
 
{| 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
 
| 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



[Expand]
Serial specific constants SERIAL_*


[Expand]
Serial device type SERIAL_TYPE_*


[Expand]
Serial device state SERIAL_STATE_*


[Expand]
Serial device flag SERIAL_FLAG_*


[Expand]
Serial read flag SERIAL_READ_*


[Expand]
Serial write flag SERIAL_WRITE_*


[Expand]
Serial wait directions SERIAL_WAIT_*


[Expand]
Serial flush flag SERIAL_FLUSH_*


[Expand]
Serial status flag SERIAL_STATUS_*


[Expand]
Serial logging SERIAL_LOG_*


Type definitions



Serial properties

[Expand]

PSerialProperties = ^TSerialProperties;

TSerialProperties = record

Serial buffer

[Expand]

PSerialBuffer = ^TSerialBuffer;

TSerialBuffer = record

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

[Expand]

PSerialDevice = ^TSerialDevice;

TSerialDevice = record

Serial logging

[Expand]

PSerialLogging = ^TSerialLogging;

TSerialLogging = record


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

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


Serial functions

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


[Expand]
function SerialDeviceClose(Serial:PSerialDevice):LongWord;
Description: Close a Serial device and terminate sending and receiving


[Expand]
function SerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read data from a Serial device


[Expand]
function SerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Write data to a Serial device


[Expand]
function SerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;
Description: Wait for data to be available in the receive or transmit buffers of a Serial device


[Expand]
function SerialDeviceFlush(Serial:PSerialDevice; Flags:LongWord):LongWord;
Description: Discard the contents of the receive and/or transmit buffers of a Serial device


[Expand]
function SerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;
Description: Get the current line status of a Serial device


[Expand]
function SerialDeviceGetStatus(Serial:PSerialDevice):LongWord;
Description: Get the current line status of a Serial device


[Expand]
function SerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;
Description: Set the current line status of a Serial device


[Expand]
function SerialDeviceProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord; inline;
Description: Get the properties for the specified Serial device


[Expand]
function SerialDeviceGetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
Description: Get the properties for the specified Serial device


[Expand]
function SerialDeviceSetProperties(Serial:PSerialDevice; Properties:PSerialProperties):LongWord;
Description: Set the properties for the specified Serial device


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


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


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


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


[Expand]
function SerialDeviceDeregister(Serial:PSerialDevice):LongWord;
Description: Deregister a Serial from the Serial table


[Expand]
function SerialDeviceFind(SerialId:LongWord):PSerialDevice;
Description: Find a serial device by Id in the serial table


[Expand]
function SerialDeviceFindByName(const Name:String):PSerialDevice; inline;
Description: Find a serial device by name in the serial table


[Expand]
function SerialDeviceFindByDescription(const Description:String):PSerialDevice; inline;
Description: Find a serial device by description in the serial table


[Expand]
function SerialDeviceEnumerate(Callback:TSerialEnumerate; Data:Pointer):LongWord;
Description: Enumerate all serial devices in the serial table


[Expand]
function SerialDeviceNotification(Serial:PSerialDevice; Callback:TSerialNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for serial device changes


Serial logging functions

[Expand]
function SerialLoggingStart(Logging:PLoggingDevice):LongWord;
Description: Implementation of LoggingDeviceStart API for Serial Logging


[Expand]
function SerialLoggingStop(Logging:PLoggingDevice):LongWord;
Description: Implementation of LoggingDeviceStop API for Serial Logging


[Expand]
function SerialLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
Description: Implementation of LoggingDeviceOutput API for Serial Logging


[Expand]
function SerialLoggingSetTarget(Logging:PLoggingDevice; const Target:String):LongWord;
Description: Implementation of LoggingDeviceSetTarget API for Serial Logging


RTL text IO functions

[Expand]
function SysTextIOReadChar(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for platform TextIOReadChar function


[Expand]
function SysTextIOWriteChar(ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for platform TextIOWriteChar function


[Expand]
function SysTextIOWriteBuffer(ABuffer:PChar; ACount:LongInt; AUserData:Pointer):LongInt;
Description: Handler for platform TextIOWriteBuffer function


RTL serial functions

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


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


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


[Expand]
function SysSerialRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Read data from the default Serial device


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


Serial helper functions

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


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


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


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


[Expand]
function SerialTypeToString(SerialType:LongWord):String;
Description: Convert a Serial type value to a string


[Expand]
function SerialStateToString(SerialState:LongWord):String;
Description: Convert a Serial state value to a string


[Expand]
function SerialDeviceRedirectInput(Serial:PSerialDevice):Boolean;
Description: Redirect standard input to the serial device specified by Serial


[Expand]
function SerialDeviceRedirectOutput(Serial:PSerialDevice):Boolean;
Description: Redirect standard output to the serial device specified by Serial


[Expand]
function SerialBufferReadStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
Description: Return a pointer to the next read from the buffer and the number of bytes that can be read


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


[Expand]
function SerialBufferWriteStart(Buffer:PSerialBuffer; var Available:LongWord):Pointer;
Description: Return a pointer to the next write to the buffer and the number of bytes that can be written


[Expand]
function SerialBufferWriteComplete(Buffer:PSerialBuffer; Added:LongWord):Boolean;
Description: Update the buffer to reflect the number of bytes added when writing


[Expand]
procedure SerialLog(Level:LongWord; Serial:PSerialDevice; const AText:String);
Description: To be documented


[Expand]
procedure SerialLogInfo(Serial:PSerialDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure SerialLogWarn(Serial:PSerialDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure SerialLogError(Serial:PSerialDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure SerialLogDebug(Serial:PSerialDevice; const AText:String); inline;
Description: To be documented


[Expand]
function SerialDataBitsToString(Parity:LongWord):String;
Description: To be documented


[Expand]
function SerialStopBitsToString(Parity:LongWord):String;
Description: To be documented


[Expand]
function SerialParityToString(Parity:LongWord):String;
Description: To be documented


[Expand]
function SerialFlowControlToString(Flow:LongWord):String;
Description: To be documented


Serial logging helper functions

[Expand]
function SerialLoggingDeviceAdd(Serial:PSerialDevice):LongWord;
Description: Add a new serial logging device on receipt of a device register notification


[Expand]
function SerialLoggingDeviceRemove(Serial:PSerialDevice):LongWord;
Description: Remove a serial logging device on receipt of a device deregister notification


[Expand]
function SerialLoggingDeviceParameters(Serial:PSerialDevice; const Parameters:String; var BaudRate,Parity,DataBits,StopBits:LongWord):LongWord;
Description: Break down the serial parameters value into component parts of baud rate, parity, data bits and stop bits


[Expand]
function SerialLoggingFirstWord(var Value:String;const Delimiter:String):String;
Description: To be documented


[Expand]
function SerialLoggingDeviceEnum(Serial:PSerialDevice; Data:Pointer):LongWord;
Description: Enumeration callback for serial logging initialization


[Expand]
function SerialLoggingDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
Description: Notification callback for serial logging device creation or remove


Return to Unit Reference