source: pacpusframework/branches/2.0-beta1/include/Pacpus/PacpusTools/QSerialPort.h@ 89

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

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1/*********************************************************************
2// created: 2011/05/18
3// filename: QSerialPort.h
4//
5// author: Gerald Dherbomez
6//
7// version: $Id: $
8//
9// purpose: This class declares a unix (32bits) driver for serial port
10*********************************************************************/
11
12
13
14#ifndef _QSerialPort_H_
15#define _QSerialPort_H_
16
17#include <QtExtSerialPort/qextserialport.h>
18
19#include <QThread>
20#include <QSemaphore>
21#include <QList>
22#include <QMutex>
23
24#include <Pacpus/kernel/road_time.h>
25
26
27//#include "kernel/pacpus.h"
28//#include "dataFrame.h"
29
30
31#define PORT_NAME_MAXIMUM_LENGTH 20
32
33
34typedef struct {
35 road_time_t t;
36 road_timerange_t tr;
37 unsigned long length;
38 char * data;
39}FRAME;
40
41
42class QSerialPort : public QThread
43{
44 Q_OBJECT
45
46public:
47 QSerialPort(QString name);
48 ~QSerialPort();
49
50 /*!< return the number of items in the list */
51 int numberOfFrames();
52
53 /*!< return the first dataFrame in the list */
54 FRAME* firstFrame();
55
56 /*!< remove the first dataFrame in the list */
57 int removeFirstFrame();
58
59 /*!< open the port 'name'
60 return true if success
61 */
62 bool openPort(const char * name);
63
64 /*!< close the port
65 return true if success
66 */
67 int closePort();
68
69 /*!< configure the port
70 return true if success
71 */
72 int configurePort(long baudRate, int byteSize, char parity, int stopBits);
73
74 /*!< set the mode of usage of the port
75
76 */
77// void setMode(const DWORD overlappedModeAttribute = 0); // FILE_FLAG_OVERLAPPED
78
79
80 QList<FRAME*> dataFrameList;
81 bool THREAD_ALIVE;
82 char portName[PORT_NAME_MAXIMUM_LENGTH+1];
83
84signals:
85 void newDataAvailable(int);
86
87
88public Q_SLOTS :
89 void RecieveData();
90
91private:
92// void setPortName(const char * name);
93// bool setPort(long baudrate,char parity,int byteSize,int stopBits );
94
95 //void processIncomingEvent();
96 void processIncomingData();
97 int readBuffer(char *buffer, int maxLength);
98 int nbBytesToRead();
99
100 void run();
101
102 int handlePort;
103
104 QextSerialPort * serialPort;
105
106 /*
107 DWORD overlappedMode;
108 OVERLAPPED overlappedStructure;
109 COMMCONFIG commConfigStructure;
110 COMMTIMEOUTS commTimeoutsStructure;
111 UINT inputBufferSize;
112 UINT outputBufferSize;
113
114 DWORD baudRate_;
115 BYTE byteSize_;
116 BYTE parity_;
117 BYTE stopBits_;
118*/
119 /*
120 DWORD evtMask;
121 COMSTAT comStat;
122 DWORD comErr;
123 DWORD comOperationStatus;
124*/
125
126 char * receivedBuffer_;
127 int numberBytesToRead;
128 int numberBytesRead;
129 bool ringIndicatorDetected;
130
131 // local variables
132 road_time_t t_;
133
134 QMutex frameLock_;
135};
136
137
138
139#endif
Note: See TracBrowser for help on using the repository browser.