SerialPort
Description
The SerialPort object represents a serial port (UART) and allows reading and writing data from it.
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
baudRate
This property holds the data baud rate for this port.
- › Type:
- › Signal:
baudRateChanged()
- › Attributes:
Writable
dataBits
This property holds the data bits in a frame.
- › Type:
- › Signal:
dataBitsChanged()
- › Attributes:
Writable
description
This property holds the description of the serial port, if available.
- › Type:
String
- › Signal:
descriptionChanged()
- › Attributes:
Readonly
error
This property holds the most recently occurred error or SerialPort.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
- › Type:
- › Signal:
errorChanged()
- › Attributes:
Readonly
errorString
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
- › Type:
String
- › Signal:
errorStringChanged()
- › Attributes:
Readonly
manufacturer
This property holds the manufacturer string of the serial port, if available.
- › Type:
String
- › Signal:
manufacturerChanged()
- › Attributes:
Readonly
parity
This property holds the parity checking mode.
- › Type:
- › Signal:
parityChanged()
- › Attributes:
Writable
portName
This property holds the name of the serial port. The prefix “/dev/” from the system location can be omitted.
- › Type:
String
- › Signal:
portNameChanged()
- › Attributes:
Writable
productIdentifier
This property holds the product identifier of the serial port, if available.
- › Type:
UnsignedSmallInteger
- › Signal:
productIdentifierChanged()
- › Attributes:
Readonly
serialNumber
This property holds the serial number of the serial port, if available.
- › Type:
String
- › Signal:
serialNumberChanged()
- › Attributes:
Readonly
stopBits
This property holds the number of stop bits in a frame.
- › Type:
- › Signal:
stopBitsChanged()
- › Attributes:
Writable
usbLocation
This property holds the location of the serial port on the USB bus if the serial port is a virtual USB COM port or similar device.
This property was introduced in InCore 2.0.
- › Type:
String
- › Signal:
usbLocationChanged()
- › Attributes:
Readonly
vendorIdentifier
This property holds the vendor identifier of the serial port, if available.
- › Type:
UnsignedSmallInteger
- › Signal:
vendorIdentifierChanged()
- › Attributes:
Readonly
Methods
backplaneBusPortName()
- › Returns:
String
builtinRS485PortName()
This method returns the platform-specific name of the builtin RS485 port.
This method was introduced in InCore 2.0.
- › Returns:
String
configureBackplaneBusPort(Boolean enabled)
configureBuiltinRS485Port(Boolean enabled)
Signals
errorOccurred()
This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.
Enumerations
BaudRate
This enumeration describes the unit for symbol rate or modulation rate in symbols per second or pulses per second. It is the number of distinct symbol changes (signaling events) made to the transmission medium per second in a digitally modulated signal
Name |
Value |
Description |
|---|---|---|
|
|
1200 baud. |
|
|
2400 baud. |
|
|
4800 baud. |
|
|
9600 baud. |
|
|
19200 baud. |
|
|
38400 baud. |
|
|
57600 baud. |
|
|
115200 baud. |
|
|
230400 baud. |
|
|
250000 baud. |
|
|
500000 baud. |
|
|
1000000 baud. |
DataBits
This enumeration describes the number of data bits used.
Name |
Value |
Description |
|---|---|---|
|
|
The number of data bits in each character is 5. It is used for Baudot code. It generally only makes sense with older equipment such as teleprinters. |
|
|
The number of data bits in each character is 6. It is rarely used. |
|
|
The number of data bits in each character is 7. It is used for true ASCII. It generally only makes sense with older equipment such as teleprinters. |
|
|
The number of data bits in each character is 8. It is used for most kinds of data, as this size matches the size of a byte. It is almost universally used in newer applications. |
Error
This enumeration describes all errors which can occur in SerialPort objects. The most recently occurred error is stored in the error property.
Name |
Value |
Description |
|---|---|---|
|
|
No error occurred or was detected. |
|
|
An error occurred while attempting to open an non-existing device. |
|
|
An error occurred while attempting to open an already opened device by another process or a user not having enough permission and credentials to open. |
|
|
An error occurred while attempting to open an already opened device in this object. |
|
|
An I/O error occurred while writing the data. |
|
|
An I/O error occurred while reading the data. |
|
|
An I/O error occurred when a resource becomes unavailable, e.g. when the device is unexpectedly removed from the system. |
|
|
The requested device operation is not supported or prohibited by the running operating system. |
|
|
Unknown error: an unknown error occurred. |
|
|
A timeout error occurred. |
|
|
This error occurs when an operation is executed that can only be successfully performed if the device is open. |
Parity
This enumeration describes the parity scheme used.
Name |
Value |
Description |
|---|---|---|
|
|
No parity bit it sent. This is the most common parity setting. Error detection is handled by the communication protocol. |
|
|
The number of 1 bits in each character, including the parity bit, is always even. |
|
|
The number of 1 bits in each character, including the parity bit, is always odd. It ensures that at least one state transition occurs in each character. |
|
|
Space parity. The parity bit is sent in the space signal condition. It does not provide error detection information. |
|
|
Mark parity. The parity bit is always set to the mark signal condition (logical 1). It does not provide error detection information. |
StopBits
This enumeration describes the number of stop bits used.
Name |
Value |
Description |
|---|---|---|
|
|
1 stop bit. |
|
|
2 stop bits. |
|
|
1.5 stop bits. This is only for the Windows platform. |
Example
import InCore.Foundation 2.5
import InCore.IO 2.5
Application {
SerialPort {
portName: "ttyUSB0"
baudRate: SerialPort.Baud9600
onCompleted: {
console.log(usbLocation)
open();
write("Hello Serial Port!")
}
onReadyRead: console.log(readAll())
}
}