Async
0.18.0
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
include
AsyncSerial.h
Go to the documentation of this file.
1
35
#ifndef SERIAL_INCLUDED
36
#define SERIAL_INCLUDED
37
38
39
/****************************************************************************
40
*
41
* System Includes
42
*
43
****************************************************************************/
44
45
#include <sigc++/sigc++.h>
46
#include <termios.h>
47
#include <unistd.h>
48
49
#include <string>
50
51
52
/****************************************************************************
53
*
54
* Project Includes
55
*
56
****************************************************************************/
57
58
59
60
/****************************************************************************
61
*
62
* Local Includes
63
*
64
****************************************************************************/
65
66
67
68
/****************************************************************************
69
*
70
* Forward declarations
71
*
72
****************************************************************************/
73
74
75
76
/****************************************************************************
77
*
78
* Namespace
79
*
80
****************************************************************************/
81
82
namespace
Async
83
{
84
85
86
/****************************************************************************
87
*
88
* Forward declarations of classes inside of the declared namespace
89
*
90
****************************************************************************/
91
92
class
FdWatch;
93
class
SerialDevice;
94
95
96
/****************************************************************************
97
*
98
* Defines & typedefs
99
*
100
****************************************************************************/
101
102
103
104
/****************************************************************************
105
*
106
* Exported Global Variables
107
*
108
****************************************************************************/
109
110
111
112
/****************************************************************************
113
*
114
* Class definitions
115
*
116
****************************************************************************/
117
129
class
Serial
:
public
SigC::Object
130
{
131
public
:
135
typedef
enum
136
{
137
PARITY_NONE
,
138
PARITY_EVEN
,
139
PARITY_ODD
140
}
Parity
;
141
145
typedef
enum
146
{
147
FLOW_NONE
,
148
FLOW_HW
,
149
FLOW_XONOFF
150
}
Flow
;
151
155
typedef
enum
156
{
157
PIN_NONE
,
158
PIN_RTS
,
159
PIN_DTR
,
160
PIN_CTS
,
161
PIN_DSR
,
162
PIN_DCD
,
163
PIN_RI
164
}
Pin
;
165
169
static
const
int
READ_BUFSIZE
= 1024;
170
171
181
explicit
Serial
(
const
std::string& serial_port);
182
186
~Serial
(
void
);
187
204
bool
setParams
(
int
speed,
Parity
parity,
int
bits,
int
stop_bits,
205
Flow
flow);
206
220
bool
open
(
void
);
221
233
bool
close
(
void
);
234
243
int
write
(
const
char
*buf,
size_t
count)
244
{
245
return ::write(fd, buf, count);
246
}
247
264
bool
setCanonical
(
bool
canonical);
265
276
bool
stopInput
(
bool
stop);
277
289
bool
setPin
(
Pin
pin,
bool
set
);
290
302
bool
getPin
(
Pin
pin,
bool
&is_set);
303
314
SigC::Signal2<void, char*, int>
charactersReceived
;
315
316
317
protected
:
318
319
private
:
320
const
std::string serial_port;
321
bool
canonical;
322
323
int
fd;
324
struct
termios port_settings;
325
SerialDevice *dev;
326
327
328
};
/* class Serial */
329
330
331
}
/* namespace */
332
333
#endif
/* SERIAL_INCLUDED */
334
335
336
337
/*
338
* This file has not been truncated
339
*/
340
Generated by
1.8.3