The bps.AsyncIO class provides functionality for reading and writing asynchronous serial ports.
More...
|
| 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. More...
|
|
String | read () |
|
Number | readByte () |
| Reads one byte from the port if possible; otherwise throws an exception. More...
|
|
String | toString () const |
|
void | write (String aData) |
| Writes data to the port if possible; otherwise throws an exception. More...
|
|
void | writeByte (Number aByte) |
| Writes a byte to the port is possible; otherwise throws an exception. More...
|
|
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.
◆ AccessMode
This enum is used with open() to describe the mode in which a port is opened.
Enumerator |
---|
ReadOnly | Opens the port in read-only mode.
|
WriteOnly | Opens the port in write-only mode.
|
ReadWrite | The port is opened for reading and writing.
|
◆ open()
Opens the port in the specified access mode if possible; otherwise throws an exception.
- Parameters
-
aAccessMode | The file access mode flag(s). |
- Exceptions
-
Error | thrown if open fails. |
◆ read()
- Returns
- All data currently in the receive buffer.
◆ readByte()
Number bps::AsyncIO::readByte |
( |
| ) |
|
Reads one byte from the port if possible; otherwise throws an exception.
- Returns
- The numeric code of the byte read.
◆ toString()
String bps::AsyncIO::toString |
( |
| ) |
const |
- Returns
- Returns "AsyncIO(port name)"
◆ write()
void bps::AsyncIO::write |
( |
String |
aData | ) |
|
Writes data to the port if possible; otherwise throws an exception.
- Parameters
-
◆ writeByte()
void bps::AsyncIO::writeByte |
( |
Number |
aByte | ) |
|
Writes a byte to the port is possible; otherwise throws an exception.
- Parameters
-
aByte | The numeric code of the byte to write. |
◆ bitRate
Number bps::AsyncIO::bitRate |
|
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. |
◆ dataBits
Number bps::AsyncIO::dataBits |
|
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. |
◆ defaultEncoding
Number bps::AsyncIO::defaultEncoding |
|
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 |
- Note
- Changing the default encoding will not change the encoding of files previously opened in script context. It will however effect existing files created in C++ context, when the encoding property was not yet changed from within a script.
◆ encoding
Number bps::AsyncIO::encoding |
|
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 |
◆ flowControl
Number bps::AsyncIO::flowControl |
|
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. |
◆ parity
Number bps::AsyncIO::parity |
|
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. |
◆ portName
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.
◆ stopBits
Number bps::AsyncIO::stopBits |
|
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. |
◆ writeTimeout
Number bps::AsyncIO::writeTimeout |
|
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.
The documentation for this class was generated from the following file: