You are here: Start » Function Reference » System » Serial Port » SerialPort_Config
Header: | STD.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
Configures the serial port.
Syntax
void fil::SerialPort_Config ( SerialPortState& ioState, int inPortId, const ftl::String& inPort, const int inBaudRate, fil::SerialPortParity::Type inParity, const int inDataBits, fil::SerialPortFlowControl::Type inFlowControl, fil::SerialPortStopBits::Type inStopBits )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
![]() |
ioState | SerialPortState& | Object used to maintain state of the function. | ||
![]() |
inPortId | int | 0 - 7 | 0 | Identifies open port instance when working with multiple serial ports |
![]() |
inPort | const String& | \"COM1\" | Serial port name | |
![]() |
inBaudRate | const int | 1 - ![]() |
9600 | Serial baud rate |
![]() |
inParity | SerialPortParity::Type | Serial parity | ||
![]() |
inDataBits | const int | 5 - 8 | 8 | Serial character size |
![]() |
inFlowControl | SerialPortFlowControl::Type | Serial flow control | ||
![]() |
inStopBits | SerialPortStopBits::Type | Serial stop bits |
Description
Filter creates serial port connection and set its parameters.
Typically values for inBaudRate: 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200.
By using parameter inPortId up to 8 simultaneous connection can be handled. Trying to configure already created connection identified by inPortId will result in "Access denied" error.
Remarks
Using the SerialPort_Config filter is necessary before using other filters for serial communication.
Filter SerialPort_Config creates connection only on first execution all next execution will have no effect.
Errors
Trying to connect to port that is already opened will result in error "Could not initialize serial port. open: Access is denied".
Trying to connect to not existing port will result in error "Could not initialize serial port. open: The system cannot find the file specified".
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Empty port name in SerialPort_Config. Empty port name is invalid. Typical port names are COM1, COM2, etc. |
See Also
- SerialPort_WriteByte – Writes one character in binary mode to serial port.
- SerialPort_WriteBuffer – Writes raw binary data from a byte buffer to serial port.
- SerialPort_WriteString – Writes string characters to serial port.
- SerialPort_ReadByte – Reads one character in binary mode from serial port.
- SerialPort_ReadBuffer – Reads raw binary data from serial port.
- SerialPort_ReadChar – Reads single character from serial port.
- SerialPort_ReadString – Reads string characters from serial port.
- SerialPort_ReadStringUntil – Reads the string from the serial port to encounter a string delimiter.