File: TTYStream.3cc

package info (click to toggle)
libcommoncpp2 1.0.13-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,740 kB
  • ctags: 2,860
  • sloc: cpp: 18,857; sh: 8,451; ansic: 1,546; makefile: 299; xml: 5
file content (234 lines) | stat: -rw-r--r-- 6,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
.TH "TTYStream" 3 "19 Jul 2003" "CommonC++" \" -*- nroff -*-
.ad l
.nh
.SH NAME
TTYStream \- TTY streams are used to represent serial connections that are fully 'streamable' objects using C++ stream classes and friends. streamable tty serial I/O class. 
.SH SYNOPSIS
.br
.PP
\fC#include <serial.h>\fP
.PP
Inherits \fBSerial\fP.
.PP
Inherited by \fBTTYSession\fP, and \fBttystream\fP.
.PP
.SS "Public Methods"

.in +1c
.ti -1c
.RI "\fBTTYStream\fP (const char *filename, \fBtimeout_t\fP to=0)"
.br
.RI "\fICreate and open a tty serial port.\fP"
.ti -1c
.RI "virtual \fB~TTYStream\fP ()"
.br
.RI "\fIEnd the tty stream and cleanup.\fP"
.ti -1c
.RI "void \fBsetTimeout\fP (\fBtimeout_t\fP to)"
.br
.RI "\fISet the timeout control.\fP"
.ti -1c
.RI "void \fBinteractive\fP (bool flag)"
.br
.RI "\fISet tty mode to buffered or 'interactive'.\fP"
.ti -1c
.RI "int \fBsync\fP (void)"
.br
.RI "\fIFlushes the stream input and out buffers, writes pending output.\fP"
.ti -1c
.RI "bool \fBisPending\fP (\fBPending\fP pend, \fBtimeout_t\fP \fBtimeout\fP=TIMEOUT_INF)"
.br
.RI "\fIGet the status of pending operations.\fP"
.in -1c
.SS "Protected Methods"

.in +1c
.ti -1c
.RI "\fBTTYStream\fP ()"
.br
.RI "\fIThis constructor is used to derive 'ttystream', a more C++ style version of the TTYStream class.\fP"
.ti -1c
.RI "void \fBallocate\fP (void)"
.br
.RI "\fIUsed to allocate the buffer space needed for iostream operations.\fP"
.ti -1c
.RI "void \fBendStream\fP (void)"
.br
.RI "\fIUsed to terminate the buffer space and clean up the tty connection.\fP"
.ti -1c
.RI "int \fBunderflow\fP (void)"
.br
.RI "\fIThis streambuf method is used to load the input buffer through the established tty serial port.\fP"
.ti -1c
.RI "int \fBuflow\fP (void)"
.br
.RI "\fIThis streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode.\fP"
.ti -1c
.RI "int \fBoverflow\fP (int ch)"
.br
.RI "\fIThis streambuf method is used to write the output buffer through the established tty port.\fP"
.in -1c
.SS "Protected Attributes"

.in +1c
.ti -1c
.RI "char * \fBgbuf\fP"
.br
.ti -1c
.RI "char * \fBpbuf\fP"
.br
.ti -1c
.RI "\fBtimeout_t\fP \fBtimeout\fP"
.br
.in -1c
.SS "Friends"

.in +1c
.ti -1c
.RI "TTYStream & \fBcrlf\fP (TTYStream &)"
.br
.ti -1c
.RI "TTYStream & \fBlfcr\fP (TTYStream &)"
.br
.in -1c
.SH "DETAILED DESCRIPTION"
.PP 
TTY streams are used to represent serial connections that are fully 'streamable' objects using C++ stream classes and friends. streamable tty serial I/O class.
.PP
The first application relevant serial I/O class is the TTYStream class. TTYStream offers a linearly buffered 'streaming' I/O session with the serial device. Furthermore, traditional C++ 'stream' operators (<< and >>) may be used with the serial device. A more 'true' to ANSI C++ library format 'ttystream' is also available, and this supports an 'open' method in which one can pass initial serial device parameters immediately following the device name in a single string, as in '/dev/tty3a:9600,7,e,1', as an example.
.PP
The \fBTTYSession\fP aggragates a TTYStream and a Common C++ \fBThread\fP which is assumed to be the execution context that will be used to perform actual I/O operations. This class is very anagolous to \fBTCPSession\fP.
.PP
\fBAuthor: \fP
.in +1c
David Sugar <dyfet@ostel.com> 
.PP
.SH "CONSTRUCTOR & DESTRUCTOR DOCUMENTATION"
.PP 
.SS "TTYStream::TTYStream ()\fC [protected]\fP"
.PP
This constructor is used to derive 'ttystream', a more C++ style version of the TTYStream class.
.PP
.SS "TTYStream::TTYStream (const char * filename, \fBtimeout_t\fP to = 0)"
.PP
Create and open a tty serial port.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIfilename\fP\fP
char name of device to open. 
.TP
\fB\fIto\fP\fP
default timeout. 
.SS "virtual TTYStream::~TTYStream ()\fC [virtual]\fP"
.PP
End the tty stream and cleanup.
.PP
.SH "MEMBER FUNCTION DOCUMENTATION"
.PP 
.SS "void TTYStream::allocate (void)\fC [protected]\fP"
.PP
Used to allocate the buffer space needed for iostream operations.
.PP
This is based on MAX_INPUT. 
.SS "void TTYStream::endStream (void)\fC [protected]\fP"
.PP
Used to terminate the buffer space and clean up the tty connection.
.PP
This function is called by the destructor. 
.SS "void TTYStream::interactive (bool flag)"
.PP
Set tty mode to buffered or 'interactive'.
.PP
When interactive, all streamed I/O is directly sent to the serial port immediately.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIflag\fP\fP
bool set to true to make interactive. 
.SS "bool TTYStream::isPending (\fBPending\fP pend, \fBtimeout_t\fP timeout = TIMEOUT_INF)\fC [virtual]\fP"
.PP
Get the status of pending operations.
.PP
This can be used to examine if input or output is waiting, or if an error has occured on the serial device. If read buffer contains data then input is ready and if write buffer contains data it is first flushed then checked.
.PP
\fBReturns: \fP
.in +1c
true if ready, false if timeout. 
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIpend\fP\fP
ready check to perform. 
.TP
\fB\fItimeout\fP\fP
in milliseconds. 
.PP
Reimplemented from \fBSerial\fP.
.SS "int TTYStream::overflow (int ch)\fC [protected]\fP"
.PP
This streambuf method is used to write the output buffer through the established tty port.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIch\fP\fP
char to push through. 
.PP
\fBReturns: \fP
.in +1c
char pushed through. 
.SS "void TTYStream::setTimeout (\fBtimeout_t\fP to)\fC [inline]\fP"
.PP
Set the timeout control.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIto\fP\fP
timeout to use. 
.SS "int TTYStream::sync (void)"
.PP
Flushes the stream input and out buffers, writes pending output.
.PP
\fBReturns: \fP
.in +1c
0 on success. 
.SS "int TTYStream::uflow (void)\fC [protected]\fP"
.PP
This streambuf method is used for doing unbuffered reads through the establish tty serial port when in interactive mode.
.PP
Also this method will handle proper use of buffers if not in interative mode.
.PP
\fBReturns: \fP
.in +1c
char from tty serial port, EOF also possible. 
.SS "int TTYStream::underflow (void)\fC [protected]\fP"
.PP
This streambuf method is used to load the input buffer through the established tty serial port.
.PP
\fBReturns: \fP
.in +1c
char from get buffer, EOF also possible. 
.SH "FRIENDS AND RELATED FUNCTION DOCUMENTATION"
.PP 
.SS "TTYStream& crlf (TTYStream &)\fC [friend]\fP"
.PP
.SS "TTYStream& lfcr (TTYStream &)\fC [friend]\fP"
.PP
.SH "MEMBER DATA DOCUMENTATION"
.PP 
.SS "char* TTYStream::gbuf\fC [protected]\fP"
.PP
.SS "char * TTYStream::pbuf\fC [protected]\fP"
.PP
.SS "\fBtimeout_t\fP TTYStream::timeout\fC [protected]\fP"
.PP


.SH "AUTHOR"
.PP 
Generated automatically by Doxygen for CommonC++ from the source code.