The bps.AsyncIO class provides functionality for reading and writing asynchronous serial ports. More...
Public Types | |
| enum | AccessMode { ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = 0x0003 } |
| This enum is used with open() to describe the mode in which a port is opened. More... | |
Public Member Functions | |
| AsyncIO () | |
| Creates a serial port object with the with fileName. | |
| void | close () |
| Closes the port. | |
| void | open (AccessMode aAccessMode) |
| Opens the port in the specified access mode if possible; otherwise throws an exception. | |
| String | read () |
| Number | readByte () |
| Reads one byte from the port if possible; otherwise throws an exception. | |
| String | toString () const |
| void | write (String aData) |
| Writes data to the port if possible; otherwise throws an exception. | |
| void | writeByte (Number aByte) |
| Writes a byte to the port is possible; otherwise throws an exception. | |
Properties | |
| Number | bitRate |
| The transmission speed given as bits per second. | |
| Number | dataBits |
| The data bits per word. | |
| Number | defaultEncoding |
| Default encoding used for static text read/write methods, and initial encoding for files opened subsequently in script context. | |
| Number | encoding |
| Encoding for the non-static text read and write methods. | |
| Number | flowControl |
| The flow control to regulate transmission. | |
| Number | parity |
| The parity. | |
| String | portName |
| The serial port name. | |
| Array | portNames |
| List of all asynchronous serial ports available on the current computer. | |
| Number | stopBits |
| The stop bits per word. | |
| Number | writeTimeout |
| The write timeout in milliseconds. | |
The bps.AsyncIO class provides functionality for reading and writing asynchronous serial ports.
Asynchronous devices are often called COM device on windows, or tty character devices on unix based operating systems.
This enum is used with open() to describe the mode in which a port is opened.
| void bps::AsyncIO::open | ( | AccessMode | aAccessMode | ) |
Opens the port in the specified access mode if possible; otherwise throws an exception.
| aAccessMode | The file access mode flag(s). |
| Error | thrown if open fails. |
| String bps::AsyncIO::read | ( | ) |
| Number bps::AsyncIO::readByte | ( | ) |
Reads one byte from the port if possible; otherwise throws an exception.
| String bps::AsyncIO::toString | ( | ) | const |
| void bps::AsyncIO::write | ( | String | aData | ) |
Writes data to the port if possible; otherwise throws an exception.
| aData | The data to write. |
| void bps::AsyncIO::writeByte | ( | Number | aByte | ) |
Writes a byte to the port is possible; otherwise throws an exception.
| aByte | The numeric code of the byte to write. |
|
readwrite |
The transmission speed given as bits per second.
Set the bit rate before opening the device.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.B110 | 110 bits per second. |
| bps.AsyncIO.B300 | 300 bits per second. |
| bps.AsyncIO.B600 | 600 bits per second. |
| bps.AsyncIO.B1200 | 1200 bits per second. |
| bps.AsyncIO.B2400 | 2400 bits per second. |
| bps.AsyncIO.B4800 | 4800 bits per second. |
| bps.AsyncIO.B9600 | 9600 bits per second. |
| bps.AsyncIO.B19200 | 19200 bits per second. |
| bps.AsyncIO.B38400 | 38400 bits per second. |
| bps.AsyncIO.B57600 | 57600 bits per second. |
| bps.AsyncIO.B115200 | 115200 bits per second. |
|
readwrite |
The data bits per word.
Set the data bits before opening the device.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.D5 | 5 bits per word. |
| bps.AsyncIO.D6 | 6 bits per word. |
| bps.AsyncIO.D7 | 7 bits per word. |
| bps.AsyncIO.D8 | 8 bits per word. |
|
readwrite |
Default encoding used for static text read/write methods, and initial encoding for files opened subsequently in script context.
The initial default encoding at application start is UTF-8.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.Utf8 | UTF-8 |
| bps.AsyncIO.Latin1 | Latin 1 |
| bps.AsyncIO.Local8Bit | Local 8 Bit |
| bps.AsyncIO.IBM850 | IBM 850 |
|
readwrite |
Encoding for the non-static text read and write methods.
The encoding of files opened in script context is initialized to the value of defaultEncoding at opening time. The encoding of files opened in C++ context is bps.AsyncIO.Default.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.Default | Use defaultEncoding. |
| bps.AsyncIO.Utf8 | UTF-8 |
| bps.AsyncIO.Latin1 | Latin 1 |
| bps.AsyncIO.Local8Bit | Local 8 Bit |
| bps.AsyncIO.IBM850 | IBM 850 |
|
readwrite |
The flow control to regulate transmission.
Set the flow control before opening the device.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.NoFlowControl | No flow control at all. DTR and RTS always on. |
| bps.AsyncIO.Hard | Hardware flow control by DTR and RTS. |
| bps.AsyncIO.Soft | Software flow control by XON/XOFF. DTR and RTS always on. |
| bps.AsyncIO.HardAndSoft | Hardware flow control plus software flow control. |
|
readwrite |
The parity.
Set the parity before opening the device.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.NoParity | No parity. |
| bps.AsyncIO.Odd | Odd parity. |
| bps.AsyncIO.Even | Even parity. |
| bps.AsyncIO.Mark | Mark parity. |
| bps.AsyncIO.Space | Space parity. |
|
readwrite |
The serial port name.
Set the port name before opening the device.
On windows, the port name must be given as \\ .\COM10 for ports above COM9. It is recommended to use this name schema also for ports COM1 to COM9.
|
readwrite |
The stop bits per word.
Set the stop bits before opening the device.
| Constant | Encoding |
|---|---|
| bps.AsyncIO.S1 | One stop bit per word. |
| bps.AsyncIO.S1_5 | One and a half stop bits per word. |
| bps.AsyncIO.S2 | Two stop bits per word. |
|
readwrite |
The write timeout in milliseconds.
A value of 0 disables write timeout and waits forever. The initial default value is 0. Set the write timeout before opening the device.