BPS asynchronous IO communications class, based on QIODevice. More...
#include <bpsasyncio.h>
Public Types | |
| enum | BitRate { B110, B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200 } |
| Bits per second. More... | |
| enum | DataBits { D5, D6, D7, D8 } |
| Number of data bits per word. More... | |
| enum | FlowControl { NoFlowControl, Hard, Soft, HardAndSoft } |
| Flow control. More... | |
| enum | Parity { NoParity, Odd, Even, Mark, Space } |
| Parity settings. More... | |
| enum | StopBits { S1, S1_5, S2 } |
| Number of stop bits per word. More... | |
Signals | |
| void | error (const QString &aError) |
| Signal emitted whenever an error is registered. | |
Public Member Functions | |
| BitRate | bitRate () const |
| BpsAsyncIO (QObject *aParent=0) | |
| DataBits | dataBits () const |
| QString | error () const |
| The last error message saved. | |
| FlowControl | flowControl () const |
| Parity | parity () const |
| QString | portName () const |
| void | setBitRate (BitRate aBitRate) |
| Set the bit rate. | |
| void | setDataBits (DataBits aDataBits) |
| Set the number of data bits per word. | |
| void | setFlowControl (FlowControl aFlowControl) |
| Set the flow control mode to use. | |
| void | setParity (Parity aParity) |
| Set the parity to use. | |
| void | setPortName (const QString &aPortName) |
| Set the port name. | |
| void | setStopBits (StopBits aStopBits) |
| Set the number of stop bits to use. | |
| void | setup (const QMap< QString, QString > &aConfig) |
| Initialize by values given in the config map. | |
| void | setWriteTimeout (quint32 aMillisecs) |
| Set the write timeout in milliseconds. | |
| StopBits | stopBits () const |
| void | unsetError () |
| Clears the error message returned by error(). | |
| quint32 | writeTimeout () const |
Static Public Member Functions | |
| static QStringList | portNames () |
| Get a list of all asynchronous IO devices available on the current computer. | |
BPS asynchronous IO communications class, based on QIODevice.
Asynchronous devices are often called COM device on windows, or tty character devices on unix stemmed operating systems. Background operations are implemented with QTimer, so the signal readReady will only be auto fired when the opening thread has an event queue.
| enum BpsAsyncIO::BitRate |
| enum BpsAsyncIO::DataBits |
| enum BpsAsyncIO::Parity |
| enum BpsAsyncIO::StopBits |
| BpsAsyncIO::BpsAsyncIO | ( | QObject * | aParent = 0 | ) |
| aParent | Pointer to an optional parent object. |
| BitRate BpsAsyncIO::bitRate | ( | ) | const |
| DataBits BpsAsyncIO::dataBits | ( | ) | const |
| QString BpsAsyncIO::error | ( | ) | const |
The last error message saved.
For example, if open() returns false, or a read/write operation returns -1, this function can be called to get the according message.
| void BpsAsyncIO::error | ( | const QString & | aError | ) | [signal] |
Signal emitted whenever an error is registered.
| [in] | aError | The error message generated. |
| FlowControl BpsAsyncIO::flowControl | ( | ) | const |
| Parity BpsAsyncIO::parity | ( | ) | const |
| QString BpsAsyncIO::portName | ( | ) | const |
| static QStringList BpsAsyncIO::portNames | ( | ) | [static] |
Get a list of all asynchronous IO devices available on the current computer.
| BpsException | Thrown on errors. |
| void BpsAsyncIO::setBitRate | ( | BitRate | aBitRate | ) |
Set the bit rate.
The initial default value is B115200. Setting the bit rate must be done before opening the device.
| [in] | aBitRate | The bit rate to set. |
| void BpsAsyncIO::setDataBits | ( | DataBits | aDataBits | ) |
Set the number of data bits per word.
The initial default value is D8. Setting the data bits must be done before opening the device.
| [in] | aDataBits | The number of data bits per word. |
| void BpsAsyncIO::setFlowControl | ( | FlowControl | aFlowControl | ) |
Set the flow control mode to use.
| [in] | aFlowControl | The flow control mode. The initial default value is NoFlowControl. Setting the flow control must be done before opening the device. |
| void BpsAsyncIO::setParity | ( | Parity | aParity | ) |
Set the parity to use.
The initial default value is NoParity. Setting the parity must be done before opening the device.
| [in] | aParity | The new parity to set. |
| void BpsAsyncIO::setPortName | ( | const QString & | aPortName | ) |
Set the port name.
On windows this is something like COM1, COM2 etc. On other systems it might be something like /dev/tty01. Setting the port name must be done before opening the device.
| [in] | aPortName | The port name to use. |
| void BpsAsyncIO::setStopBits | ( | StopBits | aStopBits | ) |
Set the number of stop bits to use.
The initial default value is S1. Setting the stop bits must be done before opening the device.
| [in] | aStopBits | The number of stop bits. |
| void BpsAsyncIO::setup | ( | const QMap< QString, QString > & | aConfig | ) |
Initialize by values given in the config map.
Keys of the map are searched case insensitive.
| Key | Value |
| Port | The serial port name, for example COM1 on windows, or /dev/tty01 on unixoid operating systems like OSX or Linux. |
| Bitrate | Line speed in bits/sec, one of 110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600 or 115200 (default). |
| Databits | Number of data bits in a word: 5, 6, 7 or 8 (default). |
| Parity | One of none (default), odd, even, mark or space. |
| Stopbits | Number of stop bits, either 1 (default), 1.5 or 2. |
| Flowcontrol | none: No flow control (default).hard: Hardware flow control by CTS/RTS.soft: Software flow control by XON/XOFF.both: Both, hardware as well as software flow control. |
| [in] | aConfig | The map of configuration values. |
| void BpsAsyncIO::setWriteTimeout | ( | quint32 | aMillisecs | ) |
Set the write timeout in milliseconds.
A value of 0 disables write timeout and waits forever.
| [in] | aMillisecs | The flow control mode. The initial default value is 0. Setting the write timeout must be done before opening the device. |
| StopBits BpsAsyncIO::stopBits | ( | ) | const |
| quint32 BpsAsyncIO::writeTimeout | ( | ) | const |