BPS C++ API  2.24.4
bpsasyncio.h
Go to the documentation of this file.
1 
4 #ifndef BPSASYNCIO_H
5 #define BPSASYNCIO_H
6 
7 #include "bpscore_global.h"
8 #include <QIODevice>
9 #include <QMap>
10 
17 {
18  Q_OBJECT
20 
21 public:
22 
26  enum BitRate {
27  B110,
28  B300,
29  B600,
37  B115200
38  };
39 
43  enum DataBits {
44  D5,
45  D6,
46  D7,
47  D8
48  };
49 
53  enum Parity {
55  Odd,
56  Even,
57  Mark,
58  Space
59  };
60 
64  enum StopBits {
65  S1,
66  S1_5,
67  S2
68  };
69 
73  enum FlowControl {
75  Hard,
76  Soft,
77  HardAndSoft
78  };
79 
83  BpsAsyncIO(QObject* aParent = nullptr);
84 
85  virtual ~BpsAsyncIO();
86 
101  void setup(const QMap<QString,QString>& aConfig);
102 
106  QString portName() const;
107 
115  void setPortName(const QString& aPortName);
116 
120  BitRate bitRate() const;
121 
128  void setBitRate(BitRate aBitRate);
129 
134 
141  void setDataBits(DataBits aDataBits);
142 
146  Parity parity() const;
147 
154  void setParity(Parity aParity);
155 
160 
167  void setStopBits(StopBits aStopBits);
168 
173 
180  void setFlowControl(FlowControl aFlowControl);
181 
185  quint32 writeTimeout() const;
186 
194  void setWriteTimeout(quint32 aMillisecs);
195 
202  QString error() const;
203 
207  void unsetError();
208 
209 
216 
218  virtual bool isSequential() const;
219  virtual bool open(OpenMode aMode);
220  virtual void close();
222 
223 signals:
224 
229  void error(const QString& aError);
230 
231 protected:
233  virtual qint64 readData(char* aData, qint64 aMaxSize);
234  virtual qint64 writeData(const char *aData, qint64 aMaxSize);
236 };
237 
238 #endif // BPSASYNCIO_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
BPS asynchronous IO communications class, based on QIODevice.
Definition: bpsasyncio.h:17
void setDataBits(DataBits aDataBits)
Set the number of data bits per word.
FlowControl
Flow control.
Definition: bpsasyncio.h:73
@ NoFlowControl
No flow control at all. DTR and RTS always on.
Definition: bpsasyncio.h:74
@ Soft
Software flow control by XON/XOFF. DTR and RTS always on.
Definition: bpsasyncio.h:76
@ Hard
Hardware flow control by DTR and RTS.
Definition: bpsasyncio.h:75
void unsetError()
Clears the error message returned by error().
BpsAsyncIO(QObject *aParent=nullptr)
BitRate bitRate() const
FlowControl flowControl() const
quint32 writeTimeout() const
void error(const QString &aError)
Signal emitted whenever an error is registered.
DataBits
Number of data bits per word.
Definition: bpsasyncio.h:43
@ D7
7 bits per word.
Definition: bpsasyncio.h:46
@ D6
6 bits per word.
Definition: bpsasyncio.h:45
@ D5
5 bits per word.
Definition: bpsasyncio.h:44
void setFlowControl(FlowControl aFlowControl)
Set the flow control mode to use.
DataBits dataBits() const
void setBitRate(BitRate aBitRate)
Set the bit rate.
Parity parity() const
void setStopBits(StopBits aStopBits)
Set the number of stop bits to use.
StopBits
Number of stop bits per word.
Definition: bpsasyncio.h:64
@ S1_5
One and a half stop bits per word.
Definition: bpsasyncio.h:66
@ S1
One stop bit per word.
Definition: bpsasyncio.h:65
void setParity(Parity aParity)
Set the parity to use.
Parity
Parity settings.
Definition: bpsasyncio.h:53
@ Even
Even parity.
Definition: bpsasyncio.h:56
@ Odd
Odd parity.
Definition: bpsasyncio.h:55
@ NoParity
No parity at all.
Definition: bpsasyncio.h:54
@ Mark
Always mark.
Definition: bpsasyncio.h:57
void setup(const QMap< QString, QString > &aConfig)
Initialize by values given in the config map.
QString portName() const
StopBits stopBits() const
void setPortName(const QString &aPortName)
Set the port name.
void setWriteTimeout(quint32 aMillisecs)
Set the write timeout in milliseconds.
QString error() const
The last error message saved.
static QStringList portNames()
Get a list of all asynchronous IO devices available on the current computer.
BitRate
Bits per second.
Definition: bpsasyncio.h:26
@ B4800
4800 bits/sec.
Definition: bpsasyncio.h:32
@ B110
110 bits/sec.
Definition: bpsasyncio.h:27
@ B2400
2400 bits/sec.
Definition: bpsasyncio.h:31
@ B19200
19200 bits/sec.
Definition: bpsasyncio.h:34
@ B300
300 bits/sec.
Definition: bpsasyncio.h:28
@ B1200
1200 bits/sec.
Definition: bpsasyncio.h:30
@ B9600
9600 bits/sec.
Definition: bpsasyncio.h:33
@ B38400
38400 bits/sec.
Definition: bpsasyncio.h:35
@ B600
600 bits/sec.
Definition: bpsasyncio.h:29
@ B57600
57600 bits/sec.
Definition: bpsasyncio.h:36
virtual void close()
virtual bool isSequential() const const
virtual bool open(QIODevice::OpenMode mode)
virtual qint64 readData(char *data, qint64 maxSize)=0
virtual qint64 writeData(const char *data, qint64 maxSize)=0