source: pacpusframework/branches/2.0-beta1/include/Pacpus/PacpusTools/PacpusSerialPort.h@ 139

Last change on this file since 139 was 122, checked in by morasjul, 11 years ago

add function to PacpusSerialPort

File size: 1.6 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 : public QObject, public ComponentBase
23{
24 Q_OBJECT
25
26public:
27
28 typedef enum { ASCII, BINARY } DataMode;
29
30 PacpusSerialPort(QString name);
31 ~PacpusSerialPort();
32
33protected:
34 void startActivity(); /*!< to start the processing thread */
35 void stopActivity(); /*!< to stop the processing thread */
36 ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
37
38 void addInput();
39 void addOutput();
40 void processInputFrame(const QByteArray &);
41
42private Q_SLOTS :
43 void readData();
44
45private:
46
47 QThread thread_;
48
49 QSerialPort * serialPort;
50
51 QString portName;
52 QSerialPort::Direction direction;
53 QSerialPort::BaudRate baudRate;
54 QSerialPort::DataBits dataBits;
55 QSerialPort::Parity parity;
56 QSerialPort::StopBits stopBits;
57 QSerialPort::FlowControl flowControl;
58 QSerialPort::DataErrorPolicy errorPolicy;
59 DataMode dataMode;
60
61 QByteArray buffer;
62
63 QString sepChar;
64 QString startChar;
65 QString stopChar;
66
67 int minPacketSize;
68
69 bool log;
70
71
72};
73
74} // end namespace
75
76#endif
Note: See TracBrowser for help on using the repository browser.