Documents > BPS V2 C++ API

BPS asynchronous IO communications class, based on QIODevice. More...

#include <bpsasyncio.h>

List of all members.

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.

Detailed Description

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.


Member Enumeration Documentation

Bits per second.

Enumerator:
B110 

110 bits/sec.

B300 

300 bits/sec.

B600 

600 bits/sec.

B1200 

1200 bits/sec.

B2400 

2400 bits/sec.

B4800 

4800 bits/sec.

B9600 

9600 bits/sec.

B19200 

19200 bits/sec.

B38400 

38400 bits/sec.

B57600 

57600 bits/sec.

B115200 

115200 bits/sec.

Number of data bits per word.

Enumerator:
D5 

5 bits per word.

D6 

6 bits per word.

D7 

7 bits per word.

D8 

8 nits per word.

Flow control.

Enumerator:
NoFlowControl 

No flow control at all. DTR and RTS always on.

Hard 

Hardware flow control by DTR and RTS.

Soft 

Software flow control by XON/XOFF. DTR and RTS always on.

HardAndSoft 

Hardware flow control plus software flow control.

Parity settings.

Enumerator:
NoParity 

No parity at all.

Odd 

Odd parity.

Even 

Even parity.

Mark 

Always mark.

Space 

Always space.

Number of stop bits per word.

Enumerator:
S1 

One stop bit per word.

S1_5 

One and a half stop bits per word.

S2 

Two stop bits per word.


Constructor & Destructor Documentation

BpsAsyncIO::BpsAsyncIO ( QObject *  aParent = 0)
Parameters:
aParentPointer to an optional parent object.

Member Function Documentation

BitRate BpsAsyncIO::bitRate ( ) const
Returns:
The port name.
DataBits BpsAsyncIO::dataBits ( ) const
Returns:
The number of data bits per word.
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.

Returns:
The latest error message.
void BpsAsyncIO::error ( const QString &  aError) [signal]

Signal emitted whenever an error is registered.

Parameters:
[in]aErrorThe error message generated.
FlowControl BpsAsyncIO::flowControl ( ) const
Returns:
The flow control.
Parity BpsAsyncIO::parity ( ) const
Returns:
The parity setting.
QString BpsAsyncIO::portName ( ) const
Returns:
The current port name.
static QStringList BpsAsyncIO::portNames ( ) [static]

Get a list of all asynchronous IO devices available on the current computer.

Returns:
List of all COM/tty device names found.
Exceptions:
BpsExceptionThrown 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.

Parameters:
[in]aBitRateThe 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.

Parameters:
[in]aDataBitsThe number of data bits per word.
void BpsAsyncIO::setFlowControl ( FlowControl  aFlowControl)

Set the flow control mode to use.

Parameters:
[in]aFlowControlThe 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.

Parameters:
[in]aParityThe 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.

Parameters:
[in]aPortNameThe 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.

Parameters:
[in]aStopBitsThe 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.

KeyValue
PortThe serial port name, for example COM1 on windows, or /dev/tty01 on unixoid operating systems like OSX or Linux.
BitrateLine speed in bits/sec, one of 110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600 or 115200 (default).
DatabitsNumber of data bits in a word: 5, 6, 7 or 8 (default).
ParityOne of none (default), odd, even, mark or space.
StopbitsNumber of stop bits, either 1 (default), 1.5 or 2.
Flowcontrolnone: 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.
Parameters:
[in]aConfigThe 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.

Parameters:
[in]aMillisecsThe flow control mode. The initial default value is 0. Setting the write timeout must be done before opening the device.
StopBits BpsAsyncIO::stopBits ( ) const
Returns:
The number of stop bits per word.
quint32 BpsAsyncIO::writeTimeout ( ) const
Returns:
Write timeout in milliseconds.

The documentation for this class was generated from the following file: