source: pacpussensors/trunk/driver/PosixSerialPort.h@ 118

Last change on this file since 118 was 99, checked in by nguyenhu, 9 years ago

compilation under linux with 0.2.X framework

File size: 2.6 KB
RevLine 
[59]1/*********************************************************************
2// created: 2011/05/18
3// filename: PosixSerialPort.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 _PosixSerialPort_H_
15#define _PosixSerialPort_H_
16
17
18
19#include <QThread>
20#include <QSemaphore>
21#include <QList>
22#include <QMutex>
23
24
25#include "kernel/pacpus.h"
26#include "dataFrame.h"
27
28
29#define PORT_NAME_MAXIMUM_LENGTH 20
30
31
32typedef struct {
33 road_time_t t;
34 road_timerange_t tr;
35 unsigned long length;
[99]36 QByteArray data; //char *
[59]37}FRAME;
38
39
40class PosixSerialPort : public QThread
41{
42 Q_OBJECT
43
44public:
45 PosixSerialPort(QString name);
46 ~PosixSerialPort();
47
48 /*!< return the number of items in the list */
49 int numberOfFrames();
50
51 /*!< return the first dataFrame in the list */
52 FRAME* firstFrame();
53
[99]54 /*!< return the next dataFrame in the list and removes it */
55 FRAME* getNextFrame();
56
[59]57 /*!< remove the first dataFrame in the list */
58 int removeFirstFrame();
59
60 /*!< open the port 'name'
61 return true if success
62 */
63 bool openPort(const char * name);
64
65 /*!< close the port
66 return true if success
67 */
68 int closePort();
69
70 /*!< configure the port
71 return true if success
72 */
73 int configurePort(long baudRate, int byteSize, char parity, int stopBits);
74
75 /*!< set the mode of usage of the port
76
77 */
78// void setMode(const DWORD overlappedModeAttribute = 0); // FILE_FLAG_OVERLAPPED
79
80
81 QList<FRAME*> dataFrameList;
82 bool THREAD_ALIVE;
83 char portName[PORT_NAME_MAXIMUM_LENGTH+1];
84
85signals:
86 void newDataAvailable(int);
87
88protected:
89 QString componentName;
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 /*
105 DWORD overlappedMode;
106 OVERLAPPED overlappedStructure;
107 COMMCONFIG commConfigStructure;
108 COMMTIMEOUTS commTimeoutsStructure;
109 UINT inputBufferSize;
110 UINT outputBufferSize;
111
112 DWORD baudRate_;
113 BYTE byteSize_;
114 BYTE parity_;
115 BYTE stopBits_;
116*/
117 /*
118 DWORD evtMask;
119 COMSTAT comStat;
120 DWORD comErr;
121 DWORD comOperationStatus;
122*/
123
124 char * receivedBuffer_;
125 int numberBytesToRead;
126 int numberBytesRead;
127 bool ringIndicatorDetected;
128
129 // local variables
130 road_time_t t_;
131
132 QMutex frameLock_;
133};
134
135
136
137#endif
Note: See TracBrowser for help on using the repository browser.