1 #ifndef _QEXTSERIALBASE_H_
2 #define _QEXTSERIALBASE_H_
9 #ifdef QT_THREAD_SUPPORT
15 #define _TTY_NOWARN_PORT_
27 #ifdef QT_LARGE_FILE_SUPPORT
30 typedef Q_ULONG Offset;
32 #endif //QT_LARGE_FILE_SUPPORT
36 #ifdef QT_THREAD_SUPPORT
37 #define LOCK_MUTEX() mutex->lock()
38 #define UNLOCK_MUTEX() mutex->unlock()
41 #define UNLOCK_MUTEX()
45 #ifdef _TTY_NOWARN_PORT_
46 #define TTY_PORTABILITY_WARNING(s)
48 #define TTY_PORTABILITY_WARNING(s) qWarning(s)
51 #define TTY_WARNING(s)
53 #define TTY_WARNING(s) qWarning(s)
58 #define MIN(a,b) (((a)<(b))?(a):(b))
61 #define PORT_NAME_SIZE_LIMIT 80
75 #define E_INVALID_FD 1
77 #define E_CAUGHT_NON_BLOCKED_SIGNAL 3
78 #define E_PORT_TIMEOUT 4
79 #define E_INVALID_DEVICE 5
80 #define E_BREAK_CONDITION 6
81 #define E_FRAMING_ERROR 7
83 #define E_BUFFER_OVERRUN 9
84 #define E_RECEIVE_OVERFLOW 10
85 #define E_RECEIVE_PARITY_ERROR 11
86 #define E_TRANSMIT_OVERFLOW 12
87 #define E_READ_FAILED 13
88 #define E_WRITE_FAILED 14
91 typedef enum _NamingConvention {
100 typedef enum _FlowType {
107 typedef enum _ParityType {
116 typedef enum _DataBitsType {
124 typedef enum _StopBitsType {
131 typedef enum _BaudRateType {
159 FlowType FlowControl;
161 DataBitsType DataBits;
162 StopBitsType StopBits;
163 BaudRateType BaudRate;
164 unsigned long Timeout_Sec;
165 unsigned long Timeout_Millisec;
173 virtual void construct(
void);
174 virtual const char* name()
const;
175 virtual void setName(
const char* name);
176 virtual bool open(
int mode=0)=0;
177 virtual bool open(
const char* name);
178 virtual void close()=0;
179 virtual void flush()=0;
180 virtual Offset size()
const=0;
181 virtual Q_LONG readLine(
char *data, Q_ULONG maxlen);
182 virtual int getch()=0;
183 virtual int putch(
int)=0;
184 virtual int ungetch(
int);
185 virtual bool atEnd()
const;
186 virtual void setFlowControl(FlowType)=0;
187 virtual FlowType flowControl()
const;
188 virtual void setParity(ParityType)=0;
189 virtual ParityType parity()
const;
190 virtual void setDataBits(DataBitsType)=0;
191 virtual DataBitsType dataBits()
const;
192 virtual void setStopBits(StopBitsType)=0;
193 virtual StopBitsType stopBits()
const;
194 virtual void setBaudRate(BaudRateType)=0;
195 virtual BaudRateType baudRate()
const;
196 virtual bool isOpen()
const;
197 virtual unsigned long lastError()
const;
198 virtual void setDtr(
bool set=
true)=0;
199 virtual void setRts(
bool set=
true)=0;
200 virtual unsigned long lineStatus(
void)=0;
201 virtual int bytesWaiting()=0;
202 virtual void translateError(
unsigned long)=0;
203 virtual void setTimeout(
unsigned long,
unsigned long)=0;
204 virtual bool isOpen(
void);
207 virtual Q_LONG readBlock(
char *data, uint maxlen)=0;
208 virtual Q_LONG writeBlock(
const char *data, uint len)=0;
210 virtual Q_LONG readBlock(
char *data,
unsigned long maxlen)=0;
211 virtual Q_LONG writeBlock(
const char *data,
unsigned long len)=0;
216 unsigned long lastErr;
217 char portName[PORT_NAME_SIZE_LIMIT+1];
220 #ifdef QT_THREAD_SUPPORT
221 static unsigned long refCount;
222 static QMutex* mutex;
QT serial port base class for Posix_QextSerialPort and Win_QextSerialPort classes.
Definition: qextserialbase.h:168
Definition: qextserialbase.h:158