source: pacpusframework/trunk/include/Pacpus/PacpusTools/PacpusSerialPort.h@ 233

Last change on this file since 233 was 152, checked in by Marek Kurdej, 11 years ago

Major update.
Renamed: addInput -> addInputs, addOutput -> addOutputs and made pure virtual (=0).
Transformed macro definitions into template methods: ADD_INPUT -> ComponentBase::addInput, ADD_OUTPUT -> ComponentBase::addOutput, GET_INPUT -> ComponentBase::getTypedInput, GET_OUTPUT -> ComponentBase::getTypedOutput.
Fixed: added public/protected set/get methods in ComponentBase, made member fields private.

File size: 1.7 KB
Line 
1/*********************************************************************
2// created: 2013/07/10
3// filename: PacpusSerialPort.h
4//
5// author: Julien Moras
6//
7// version: $Id: $
8//
9// purpose: This class defines a Qt 5.1 driver for serial port
10*********************************************************************/
11#ifndef _PacpusSerialPort_H_
12#define _PacpusSerialPort_H_
13
14#include <QtSerialPort/QSerialPort>
15#include <QtSerialPort/QSerialPortInfo>
16#include <QThread>
17
18#include <Pacpus/kernel/ComponentBase.h>
19
20namespace pacpus {
21
22class PacpusSerialPort
23 : public QObject
24 , public ComponentBase
25{
26 Q_OBJECT
27
28public:
29 typedef enum {
30 ASCII,
31 BINARY
32 } DataMode;
33
34 PacpusSerialPort(QString name);
35 ~PacpusSerialPort();
36
37protected:
38 void startActivity(); /*!< to start the processing thread */
39 void stopActivity(); /*!< to stop the processing thread */
40 ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
41
42 virtual void addInputs();
43 virtual void addOutputs();
44 void processInputFrame(const QByteArray &);
45
46private Q_SLOTS:
47 void readData();
48
49private:
50 QThread thread_;
51
52 QSerialPort * serialPort;
53
54 QString portName;
55 QSerialPort::Direction direction;
56 QSerialPort::BaudRate baudRate;
57 QSerialPort::DataBits dataBits;
58 QSerialPort::Parity parity;
59 QSerialPort::StopBits stopBits;
60 QSerialPort::FlowControl flowControl;
61 QSerialPort::DataErrorPolicy errorPolicy;
62 DataMode dataMode;
63
64 QByteArray buffer;
65
66 QString sepChar;
67 QString startChar;
68 QString stopChar;
69
70 int minPacketSize;
71
72 bool log;
73};
74
75} // end namespace
76
77#endif
Note: See TracBrowser for help on using the repository browser.