author | John Imhofe |
Mon, 22 Feb 2010 14:47:35 +0000 | |
changeset 16 | f3f3987b99ac |
parent 8 | 538db54a451d |
child 43 | c1f20ce4abcf |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32\include\d32comm.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
//#define _DEBUG_DEVCOMM |
|
19 |
||
20 |
/** |
|
21 |
@file |
|
22 |
@publishedPartner |
|
23 |
@released |
|
24 |
*/ |
|
25 |
||
26 |
#ifndef __D32COMM_H__ |
|
27 |
#define __D32COMM_H__ |
|
28 |
#include <e32cmn.h> |
|
29 |
#include <e32ver.h> |
|
8
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#include <d32public.h> |
0 | 31 |
|
32 |
/** |
|
33 |
Enumeration of number of data bits for serial port configuration. |
|
34 |
Typically, these values are used to initialize the iDataBits of |
|
35 |
TCommConfigV01 before calling DComm::Configure() or any other serial |
|
36 |
comm API to configure the serial port's databits size. |
|
37 |
*/ |
|
38 |
enum TDataBits {EData5,EData6,EData7,EData8}; |
|
39 |
/** |
|
40 |
Enumeration of number of stop bits for serial port configuration. |
|
41 |
Typically, these values are used to initialize the iStopBits of |
|
42 |
TCommConfigV01 before calling DComm::Configure() or any other serial |
|
43 |
comm API to configure the serial port's stopbits. |
|
44 |
*/ |
|
45 |
enum TStopBits {EStop1,EStop2}; |
|
46 |
/** |
|
47 |
Enumeration of types of parity for serial port configuration. |
|
48 |
Typically, these values are used to initialize the iParity of |
|
49 |
TCommConfigV01 before calling DComm::Configure() or any other serial |
|
50 |
comm API to configure the serial port's parity setting. |
|
51 |
*/ |
|
52 |
enum TParity {EParityNone,EParityEven,EParityOdd,EParityMark,EParitySpace}; |
|
53 |
/** |
|
54 |
Enumeration of baud rates in bits per second for serial port configuration. |
|
55 |
* e.g EBps115200 is for 115200Bps data rate |
|
56 |
Typically, these values are used to initialize the iRate of TCommConfigV01 |
|
57 |
before calling DComm::Configure() or any other serial comm API to configure |
|
58 |
the serial port's baud rate. |
|
59 |
*/ |
|
60 |
enum TBps |
|
61 |
{ |
|
62 |
EBps50, |
|
63 |
EBps75, |
|
64 |
EBps110, |
|
65 |
EBps134, |
|
66 |
EBps150, |
|
67 |
EBps300, |
|
68 |
EBps600, |
|
69 |
EBps1200, |
|
70 |
EBps1800, |
|
71 |
EBps2000, |
|
72 |
EBps2400, |
|
73 |
EBps3600, |
|
74 |
EBps4800, |
|
75 |
EBps7200, |
|
76 |
EBps9600, |
|
77 |
EBps19200, |
|
78 |
EBps38400, |
|
79 |
EBps57600, |
|
80 |
EBps115200, |
|
81 |
EBps230400, |
|
82 |
EBps460800, |
|
83 |
EBps576000, |
|
84 |
EBps1152000, |
|
85 |
EBps4000000, |
|
86 |
EBps921600, |
|
87 |
EBpsAutobaud=0x40000000, |
|
88 |
EBpsSpecial=0x80000000, |
|
89 |
}; |
|
90 |
/** |
|
91 |
Enumeration of Fifo status (enable and disable) for serial port configuration. |
|
92 |
Typically, these values are used to initialize the iFifo of TCommConfigV01 |
|
93 |
before calling DComm::Configure() or any other serial comm API to configure |
|
94 |
the serial port's fifo. |
|
95 |
*/ |
|
96 |
enum TFifo |
|
97 |
{ |
|
98 |
EFifoEnable,EFifoDisable, |
|
99 |
}; |
|
100 |
/** |
|
101 |
Enumeration of SIR status (enable and disable) for serial comm configuration. |
|
102 |
Typically, these values are used to initialize the iSIREnable of TCommConfigV01 |
|
103 |
before calling DComm::Configure() or any other serial comm API to configure |
|
104 |
the serial port's SIR (infrared) settings. |
|
105 |
*/ |
|
106 |
enum TSir |
|
107 |
{ |
|
108 |
ESIREnable,ESIRDisable, |
|
109 |
}; |
|
110 |
||
111 |
const TInt KConfigMaxTerminators=4; |
|
112 |
// DTE Constants |
|
113 |
const TUint KConfigObeyXoff=0x01; |
|
114 |
const TUint KConfigSendXoff=0x02; |
|
115 |
const TUint KConfigObeyCTS=0x04; |
|
116 |
const TUint KConfigFailCTS=0x08; |
|
117 |
const TUint KConfigObeyDSR=0x10; |
|
118 |
const TUint KConfigFailDSR=0x20; |
|
119 |
const TUint KConfigObeyDCD=0x40; |
|
120 |
const TUint KConfigFailDCD=0x80; |
|
121 |
const TUint KConfigFreeRTS=0x100; |
|
122 |
const TUint KConfigFreeDTR=0x200; |
|
123 |
// DCE Constants |
|
124 |
const TUint KConfigObeyDTR=0x400; |
|
125 |
const TUint KConfigFailDTR=0x800; |
|
126 |
const TUint KConfigObeyRTS=0x1000; |
|
127 |
const TUint KConfigFailRTS=0x2000; |
|
128 |
const TUint KConfigFreeDSR=0x4000; |
|
129 |
const TUint KConfigFreeCTS=0x8000; |
|
130 |
const TUint KConfigFreeDCD=0x10000; |
|
131 |
const TUint KConfigFreeRI=0x20000; |
|
132 |
const TUint KConfigWriteBufferedComplete=0x80000000; |
|
133 |
// |
|
134 |
const TUint KConfigParityErrorFail=0; |
|
135 |
const TUint KConfigParityErrorIgnore=0x01; |
|
136 |
const TUint KConfigParityErrorReplaceChar=0x02; |
|
137 |
const TUint KConfigXonXoffDebug=0x80000000; |
|
138 |
// |
|
139 |
const TUint KSignalCTS=0x01; |
|
140 |
const TUint KSignalDSR=0x02; |
|
141 |
const TUint KSignalDCD=0x04; |
|
142 |
const TUint KSignalRNG=0x08; |
|
143 |
const TUint KSignalRTS=0x10; |
|
144 |
const TUint KSignalDTR=0x20; |
|
145 |
const TUint KSignalBreak=0x40; |
|
146 |
||
147 |
const TUint KSignalChanged=0x1000; |
|
148 |
const TUint KCTSChanged=KSignalCTS*KSignalChanged; |
|
149 |
const TUint KDSRChanged=KSignalDSR*KSignalChanged; |
|
150 |
const TUint KDCDChanged=KSignalDCD*KSignalChanged; |
|
151 |
const TUint KRNGChanged=KSignalRNG*KSignalChanged; |
|
152 |
const TUint KRTSChanged=KSignalRTS*KSignalChanged; |
|
153 |
const TUint KDTRChanged=KSignalDTR*KSignalChanged; |
|
154 |
const TUint KBreakChanged=KSignalBreak*KSignalChanged; |
|
155 |
||
156 |
const TUint KSignalDTEOutputs=KSignalRTS|KSignalDTR; |
|
157 |
const TUint KSignalDTEInputs=KSignalCTS|KSignalDSR|KSignalDCD|KSignalRNG; |
|
158 |
const TUint KSignalDCEInputs=KSignalDTEOutputs; |
|
159 |
const TUint KSignalDCEOutputs=KSignalDTEInputs; |
|
160 |
||
161 |
const TUint KConfigSIRPulseWidthMaximum=0x01; |
|
162 |
const TUint KConfigSIRPulseWidthMinimum=0x02; |
|
163 |
||
164 |
// more SIRSettings for selecting the IR range |
|
165 |
const TUint KConfigSIRShutDown=0x10; |
|
166 |
const TUint KConfigSIRMinimumRange=0x20; |
|
167 |
const TUint KConfigSIRMediumRange=0x40; |
|
168 |
const TUint KConfigSIRMaximumRange=0x80; |
|
169 |
||
170 |
/** |
|
171 |
Comms configuration structure. |
|
172 |
Class to hold the configuration settings for serial comm port |
|
173 |
||
174 |
This class provides the serial port configuration block interface of serial comms (c32). |
|
175 |
A serial comm client sets up a serial port before use, by providing a configuration block. |
|
176 |
TCommConfigV01 is initialized with settings for serial port and used to configure the |
|
177 |
serial port by calling DComm::Configure(TCommConfigV01 &aConfig) or any other serial comm |
|
178 |
API to configure the serial port. |
|
179 |
*/ |
|
180 |
class TCommConfigV01 |
|
181 |
{ |
|
182 |
public: |
|
183 |
/** |
|
184 |
Data rate in bits per second. |
|
185 |
@see TBps |
|
186 |
*/ |
|
187 |
TBps iRate; |
|
188 |
/** |
|
189 |
Character width in bits. |
|
190 |
@see TDataBits |
|
191 |
*/ |
|
192 |
TDataBits iDataBits; |
|
193 |
/** |
|
194 |
Number of stop bits. |
|
195 |
@see TStopBits |
|
196 |
*/ |
|
197 |
TStopBits iStopBits; |
|
198 |
/** |
|
199 |
Type of parity. |
|
200 |
@see TParity |
|
201 |
*/ |
|
202 |
TParity iParity; |
|
203 |
/** |
|
204 |
Type of Handshaking control. |
|
205 |
Possible values can be KConfigObeyXXX or KConfigSendXXX or KConfigFailXXX or KConfigFreeXXX |
|
206 |
*/ |
|
207 |
TUint iHandshake; |
|
208 |
/** |
|
209 |
Type of error to generate on a parity failure. |
|
210 |
Possible values can be KConfigParityErrorFail or KConfigParityErrorIgnore or KConfigParityErrorReplaceChar |
|
211 |
*/ |
|
212 |
TUint iParityError; |
|
213 |
/** |
|
214 |
FIFO status, enabled or disabled. |
|
215 |
@see TFifo |
|
216 |
*/ |
|
217 |
TUint iFifo; |
|
218 |
/** |
|
219 |
Special data rate, not listed under TBps. Use this, when iRate is set to EBpsSpecial |
|
220 |
*/ |
|
221 |
TInt iSpecialRate; |
|
222 |
/** |
|
223 |
Count of number of special characters used as terminators (<=KConfigMaxTerminators) |
|
224 |
*/ |
|
225 |
TInt iTerminatorCount; |
|
226 |
/** |
|
227 |
Array of special characters which can be used as terminators |
|
228 |
*/ |
|
229 |
TText8 iTerminator[KConfigMaxTerminators]; |
|
230 |
/** |
|
231 |
Character used to signal the transmitter to resume sending when using XON/XOFF handshaking |
|
232 |
i.e character used as XON - software flow control |
|
233 |
*/ |
|
234 |
TText8 iXonChar; |
|
235 |
/** |
|
236 |
Character used to signal the transmitter to suspend sending when using XON/XOFF handshaking |
|
237 |
i.e character used as XOFF - software flow control |
|
238 |
*/ |
|
239 |
TText8 iXoffChar; |
|
240 |
/** |
|
241 |
Character used to replace the characters received with a parity error. |
|
242 |
This is used when iParityError is set to KConfigParityErrorReplaceChar |
|
243 |
*/ |
|
244 |
TText8 iParityErrorChar; |
|
245 |
/** |
|
246 |
Switch the SIR encoding hardware on and off. |
|
247 |
@see TSir |
|
248 |
*/ |
|
249 |
TSir iSIREnable; |
|
250 |
/** |
|
251 |
SIR hardware control setting. Possible value can be one of KConfigSIRXXX |
|
252 |
*/ |
|
253 |
TUint iSIRSettings; |
|
254 |
}; |
|
255 |
/** |
|
256 |
Package buffer for a TCommConfigV01 object. |
|
257 |
||
258 |
TCommConfig packages the comms configuration structure TCommConfigV01 to a buffer. |
|
259 |
This is used with API of serial comms like RComm::Config(TDes8 &aConfig) and |
|
260 |
RComm::SetConfig(TDesC8 &aConfig) where config structure is passed as buffer. |
|
261 |
||
262 |
@see TCommConfigV01 |
|
263 |
*/ |
|
264 |
typedef TPckgBuf<TCommConfigV01> TCommConfig; |
|
265 |
||
266 |
// TCommConfigV02 is deprecated. |
|
267 |
// |
|
268 |
class TCommConfigV02: public TCommConfigV01 |
|
269 |
{ |
|
270 |
public: |
|
271 |
TInt iTxShutdownTimeout; |
|
272 |
}; |
|
273 |
||
274 |
// TCommConfig2 is deprecated |
|
275 |
// |
|
276 |
typedef TPckgBuf<TCommConfigV02> TCommConfig2; |
|
277 |
||
278 |
// |
|
279 |
const TUint KCapsBps50=0x00000001; |
|
280 |
const TUint KCapsBps75=0x00000002; |
|
281 |
const TUint KCapsBps110=0x00000004; |
|
282 |
const TUint KCapsBps134=0x00000008; |
|
283 |
const TUint KCapsBps150=0x00000010; |
|
284 |
const TUint KCapsBps300=0x00000020; |
|
285 |
const TUint KCapsBps600=0x00000040; |
|
286 |
const TUint KCapsBps1200=0x00000080; |
|
287 |
const TUint KCapsBps1800=0x00000100; |
|
288 |
const TUint KCapsBps2000=0x00000200; |
|
289 |
const TUint KCapsBps2400=0x00000400; |
|
290 |
const TUint KCapsBps3600=0x00000800; |
|
291 |
const TUint KCapsBps4800=0x00001000; |
|
292 |
const TUint KCapsBps7200=0x00002000; |
|
293 |
const TUint KCapsBps9600=0x00004000; |
|
294 |
const TUint KCapsBps19200=0x00008000; |
|
295 |
const TUint KCapsBps38400=0x00010000; |
|
296 |
const TUint KCapsBps57600=0x00020000; |
|
297 |
const TUint KCapsBps115200=0x00040000; |
|
298 |
const TUint KCapsBps230400=0x00080000; |
|
299 |
const TUint KCapsBps460800=0x00100000; |
|
300 |
const TUint KCapsBps576000 =0x00200000; |
|
301 |
const TUint KCapsBps1152000=0x00400000; |
|
302 |
const TUint KCapsBps4000000=0x00800000; |
|
303 |
const TUint KCapsBps921600=0x01000000; |
|
304 |
const TUint KCapsBpsAutobaud=0x40000000; |
|
305 |
const TUint KCapsBpsSpecial=0x80000000; |
|
306 |
// |
|
307 |
const TUint KCapsData5=0x01; |
|
308 |
const TUint KCapsData6=0x02; |
|
309 |
const TUint KCapsData7=0x04; |
|
310 |
const TUint KCapsData8=0x08; |
|
311 |
// |
|
312 |
const TUint KCapsStop1=0x01; |
|
313 |
const TUint KCapsStop2=0x02; |
|
314 |
// |
|
315 |
const TUint KCapsParityNone=0x01; |
|
316 |
const TUint KCapsParityEven=0x02; |
|
317 |
const TUint KCapsParityOdd=0x04; |
|
318 |
const TUint KCapsParityMark=0x08; |
|
319 |
const TUint KCapsParitySpace=0x10; |
|
320 |
// |
|
321 |
const TUint KCapsSignalCTSSupported=0x01; |
|
322 |
const TUint KCapsSignalDSRSupported=0x02; |
|
323 |
const TUint KCapsSignalDCDSupported=0x04; |
|
324 |
const TUint KCapsSignalRNGSupported=0x08; |
|
325 |
const TUint KCapsSignalRTSSupported=0x10; |
|
326 |
const TUint KCapsSignalDTRSupported=0x20; |
|
327 |
// |
|
328 |
const TUint KCapsObeyXoffSupported=0x01; |
|
329 |
const TUint KCapsSendXoffSupported=0x02; |
|
330 |
const TUint KCapsObeyCTSSupported=0x04; |
|
331 |
const TUint KCapsFailCTSSupported=0x08; |
|
332 |
const TUint KCapsObeyDSRSupported=0x10; |
|
333 |
const TUint KCapsFailDSRSupported=0x20; |
|
334 |
const TUint KCapsObeyDCDSupported=0x40; |
|
335 |
const TUint KCapsFailDCDSupported=0x80; |
|
336 |
const TUint KCapsFreeRTSSupported=0x100; |
|
337 |
const TUint KCapsFreeDTRSupported=0x200; |
|
338 |
// DCE Constants |
|
339 |
const TUint KCapsObeyRTSSupported=0x400; |
|
340 |
const TUint KCapsObeyDTRSupported=0x800; |
|
341 |
// |
|
342 |
const TUint KCapsHasFifo=0x01; |
|
343 |
// |
|
344 |
const TUint KCapsSIR115kbps=0x01; |
|
345 |
const TUint KCapsSIR2400bpsOnly=0x02; |
|
346 |
const TUint KCapsSIR4Mbs=0x04; |
|
347 |
// |
|
348 |
const TUint KNotifySignalsChangeSupported=0x01; |
|
349 |
const TUint KNotifyRateChangeSupported=0x02; |
|
350 |
const TUint KNotifyDataFormatChangeSupported=0x04; |
|
351 |
const TUint KNotifyHandshakeChangeSupported=0x08; |
|
352 |
const TUint KNotifyBreakSupported=0x10; |
|
353 |
const TUint KNotifyFlowControlChangeSupported=0x20; |
|
354 |
const TUint KNotifyDataAvailableSupported=0x40; |
|
355 |
const TUint KNotifyOutputEmptySupported=0x80; |
|
356 |
// |
|
357 |
const TUint KCapsRoleSwitchSupported=0x01; |
|
358 |
// |
|
359 |
const TUint KCapsFlowControlStatusSupported=0x01; |
|
360 |
// |
|
361 |
const TUint KRateChanged=0x01; |
|
362 |
const TUint KDataFormatChanged=0x02; |
|
363 |
const TUint KHandshakeChanged=0x04; |
|
364 |
// |
|
365 |
||
366 |
/** |
|
367 |
Comms capability structure. |
|
368 |
Class to query the capability settings for serial comm port device. |
|
369 |
Members of this class are filled with the capabilities of the comm port device. |
|
370 |
*/ |
|
371 |
||
372 |
class TCommCapsV01 |
|
373 |
{ |
|
374 |
public: |
|
375 |
/** |
|
376 |
Data rates supported, in bits per second. |
|
377 |
The value is a bitmask made by OR-ing KCapsBpsXXX values. |
|
378 |
Each set bit corresponds to a supported bit rate. |
|
379 |
*/ |
|
380 |
TUint iRate; |
|
381 |
/** |
|
382 |
Character widths supported, in bits. |
|
383 |
The value is a bitmask made by OR-ing a combination of KCapsData5, KCapsData6, KCapsData7 and KCapsData8 values. |
|
384 |
Each set bit corresponds to a supported character width. |
|
385 |
*/ |
|
386 |
TUint iDataBits; |
|
387 |
/** |
|
388 |
Number of stop bits supported. |
|
389 |
The value is one of KCapsStop1, KCapsStop2 or KCapsStop1|KCapsStop2. |
|
390 |
Each set bit corresponds to a supported number of stop bit. |
|
391 |
*/ |
|
392 |
TUint iStopBits; |
|
393 |
/** |
|
394 |
Parity types supported. |
|
395 |
The value is a bitmask made by OR-ing a combination of KCapsParityNone, KCapsParityEven, KCapsParityOdd, KCapsParityMark and KCapsParitySpace values. |
|
396 |
Each set bit corresponds to a supported parity type. |
|
397 |
*/ |
|
398 |
TUint iParity; |
|
399 |
/** |
|
400 |
Type of Handshaking protocols supported by the device. |
|
401 |
The value is a bitmask made by OR-ing a combination of KCapsObeyXXX, KCapsSendXXX, KCapsFailXXX and KCapsFreeXXX values. |
|
402 |
Each set bit corresponds to a supported handshaking protocol. |
|
403 |
*/ |
|
404 |
TUint iHandshake; |
|
405 |
/** |
|
406 |
Type of Signals supported by the device. |
|
407 |
The value is a bitmask made by OR-ing a combination of KCapsSignalXXX values. |
|
408 |
Each set bit corresponds to a supported signal. |
|
409 |
*/ |
|
410 |
TUint iSignals; |
|
411 |
/** |
|
412 |
Whether Fifo is enabled or disabled. |
|
413 |
Value is KCapsHasFifo if enabled, 0 otherwise |
|
414 |
*/ |
|
415 |
TUint iFifo; |
|
416 |
/** |
|
417 |
Capabilities of the SIR encoding hardware. |
|
418 |
The value is a bitmask made by OR-ing a combination of KCapsSIR115kbps, KCapsSIR2400bpsOnly and KCapsSIR4Mbps values. |
|
419 |
Each set bit corresponds to a supported SIR capability. |
|
420 |
*/ |
|
421 |
TUint iSIR; |
|
422 |
}; |
|
423 |
/** |
|
424 |
Package buffer for a TCommCapsV01 object. |
|
425 |
||
426 |
TCommCaps packages the comms capability structure TCommCapsV01 in a buffer. |
|
427 |
This is used by serial comms APIs to pass the capability structure as a buffer, |
|
428 |
for example in RComm::Caps(TDes8 &aCaps). |
|
429 |
||
430 |
@see TCommCapsV01 |
|
431 |
*/ |
|
432 |
typedef TPckgBuf<TCommCapsV01> TCommCaps; |
|
433 |
||
434 |
/** |
|
435 |
Comms capability structure. |
|
436 |
Class to query the capability settings for serial comm port. |
|
437 |
Members of this class are filled with the capabilities of the comm port. |
|
438 |
||
439 |
@see TCommCapsV01 |
|
440 |
*/ |
|
441 |
class TCommCapsV02 : public TCommCapsV01 |
|
442 |
{ |
|
443 |
public: |
|
444 |
/** |
|
445 |
Specifies the notifications that are supported for the serial comm port. |
|
446 |
The field is a bitmask made by OR-ing a combination of: |
|
447 |
-KNotifySignalsChangeSupported |
|
448 |
-KNotifyRateChangeSupported |
|
449 |
-KNotifyDataFormatChangeSupported |
|
450 |
-KNotifyHandshakeChangeSupported |
|
451 |
-KNotifyBreakSupported |
|
452 |
-KNotifyFlowControlChangeSupported |
|
453 |
-KNotifyDataAvailableSupported |
|
454 |
-KNotifyOutputEmptySupported |
|
455 |
Each set bit corresponds to a supported notification type. |
|
456 |
*/ |
|
457 |
TUint iNotificationCaps; |
|
458 |
/** |
|
459 |
Specifies whether Role Switch is supported or not. |
|
460 |
If supported the value is KCapsRoleSwitchSupported, otherwise Zero |
|
461 |
*/ |
|
462 |
TUint iRoleCaps; |
|
463 |
/** |
|
464 |
Specifies whether Flow Control Status is supported or not. |
|
465 |
If supported the value is KCapsFlowControlStatusSupported, otherwise Zero |
|
466 |
*/ |
|
467 |
TUint iFlowControlCaps; |
|
468 |
}; |
|
469 |
||
470 |
/** |
|
471 |
Package buffer for a TCommCapsV02 object. |
|
472 |
||
473 |
TCommCaps2 packages the comms capability structure TCommCapsV02 in a buffer. |
|
474 |
This is used by serial comms to pass the capability structure as a buffer, |
|
475 |
for example in RComm::Caps(TDes8 &aCaps) |
|
476 |
||
477 |
@see TCommCapsV02 |
|
478 |
*/ |
|
479 |
typedef TPckgBuf<TCommCapsV02> TCommCaps2; |
|
480 |
||
481 |
||
482 |
/** |
|
483 |
Comms capability structure. |
|
484 |
Class to hold the capability settings for serial comm port. |
|
485 |
||
486 |
This class is used to query the capabilities of the serial comm port. |
|
487 |
Members of this class are filled with the capabilities of the comm port. |
|
488 |
||
489 |
@see TCommCapsV02 |
|
490 |
*/ |
|
491 |
class TCommCapsV03 : public TCommCapsV02 |
|
492 |
{ |
|
493 |
public: |
|
494 |
/** |
|
495 |
Specifies whether break is supported or not. |
|
496 |
ETrue if Supported, EFalse otherwise. |
|
497 |
*/ |
|
498 |
TBool iBreakSupported; |
|
499 |
}; |
|
500 |
||
501 |
/** |
|
502 |
Package buffer for a TCommCapsV03 object. |
|
503 |
||
504 |
TCommCaps3 packages the comms capability structure TCommCapsV03 in a buffer. |
|
505 |
This is used by serial comms APIs to pass the capability structure as a buffer, |
|
506 |
for example in RComm::Caps(TDes8 &aCaps) |
|
507 |
||
508 |
@see TCommCapsV03 |
|
509 |
*/ |
|
510 |
typedef TPckgBuf<TCommCapsV03> TCommCaps3; |
|
511 |
||
512 |
/** |
|
513 |
Structure that holds the capabilities of the Comms factory object. Only Version is supported. |
|
514 |
This structure is packaged within a descriptor when passed to methods such as RDevice::GetCaps() |
|
515 |
*/ |
|
516 |
class TCapsDevCommV01 |
|
517 |
{ |
|
518 |
public: |
|
519 |
/** |
|
520 |
Version of the device |
|
521 |
@see TVersion |
|
522 |
*/ |
|
523 |
TVersion version; |
|
524 |
}; |
|
525 |
||
526 |
/** |
|
527 |
Comms Notification configuration structure |
|
528 |
Class to hold the notification configuration of the device. |
|
529 |
Notifications are only used with DCE (modem) comms ports. |
|
530 |
*/ |
|
531 |
class TCommNotificationV01 |
|
532 |
{ |
|
533 |
public: |
|
534 |
/** |
|
535 |
Specifies which of the configuration members have changed |
|
536 |
This value is a bitmask made by OR-ing a combination of KRateChanged,KDataFormatChanged and KHandshakeChanged values. |
|
537 |
Each set bit corresponds to a change in the configuration notification. |
|
538 |
@see TCommCapsV01 |
|
539 |
*/ |
|
540 |
TUint iChangedMembers; |
|
541 |
/** |
|
542 |
Data rate in bits per second. |
|
543 |
@see TBps |
|
544 |
*/ |
|
545 |
TBps iRate; |
|
546 |
/** |
|
547 |
Character width in bits. |
|
548 |
@see TDataBits |
|
549 |
*/ |
|
550 |
TDataBits iDataBits; |
|
551 |
/** |
|
552 |
Number of stop bits. |
|
553 |
@see TStopBits |
|
554 |
*/ |
|
555 |
TStopBits iStopBits; |
|
556 |
/** |
|
557 |
Type of parity. |
|
558 |
@see TParity |
|
559 |
*/ |
|
560 |
TParity iParity; |
|
561 |
/** |
|
562 |
Type of Handshaking control. |
|
563 |
Possible values can be any combination of KConfigObeyXXX, KConfigSendXXX, KConfigFailXXX and KConfigFreeXXX. |
|
564 |
*/ |
|
565 |
TUint iHandshake; |
|
566 |
}; |
|
567 |
/** |
|
568 |
Package buffer for a TCommNotificationV01 object. |
|
569 |
Packages TCommNotificationV01 within a buffer. |
|
570 |
@see TCommNotificationV01 |
|
571 |
*/ |
|
572 |
typedef TPckgBuf<TCommNotificationV01> TCommNotificationPckg; |
|
573 |
// |
|
574 |
const TUint KDataAvailableNotifyFlag=0x80000000; |
|
575 |
// |
|
576 |
#ifdef _DEBUG_DEVCOMM |
|
577 |
class TCommDebugInfo |
|
578 |
{ |
|
579 |
public: |
|
580 |
TBool iRxBusy; |
|
581 |
TBool iRxHeld; |
|
582 |
TInt iRxLength; |
|
583 |
TInt iRxOffset; |
|
584 |
TInt iRxIntCount; |
|
585 |
TInt iRxErrCount; |
|
586 |
TInt iRxBufCount; |
|
587 |
TBool iTxBusy; |
|
588 |
TBool iTxHeld; |
|
589 |
TInt iTxLength; |
|
590 |
TInt iTxOffset; |
|
591 |
TInt iTxIntCount; |
|
592 |
TInt iTxErrCount; |
|
593 |
TInt iTxBufCount; |
|
594 |
TBool iDrainingRxBuf; |
|
595 |
TBool iFillingTxBuf; |
|
596 |
TBool iRunningDfc; |
|
597 |
TInt iDfcCount; |
|
598 |
TInt iDfcReqSeq; |
|
599 |
TInt iDfcHandlerSeq; |
|
600 |
TInt iDoDrainSeq; |
|
601 |
TBool iTxDfcPend; |
|
602 |
TBool iRxDfcPend; |
|
603 |
TInt iTxChars, iRxChars; |
|
604 |
TInt iTxXon, iTxXoff, iRxXon, iRxXoff; |
|
605 |
}; |
|
606 |
typedef TPckgBuf<TCommDebugInfo> TCommDebugInfoPckg; |
|
607 |
#endif |
|
608 |
// |
|
609 |
||
610 |
/** |
|
611 |
The externally visible interface through which the clients can access serial devices. |
|
612 |
It also represents a user side handle to the serial device driver. |
|
613 |
*/ |
|
614 |
class RBusDevComm : public RBusLogicalChannel |
|
615 |
{ |
|
616 |
public: |
|
617 |
/** |
|
618 |
Serial device driver build version. |
|
619 |
*/ |
|
620 |
enum TVer |
|
621 |
{ |
|
622 |
/** Major Version */ |
|
623 |
EMajorVersionNumber=1, |
|
624 |
/** Minor Version */ |
|
625 |
EMinorVersionNumber=0, |
|
626 |
/** Build Version */ |
|
627 |
EBuildVersionNumber=KE32BuildVersionNumber |
|
628 |
}; |
|
629 |
||
630 |
/** |
|
631 |
Asynchronous request types |
|
632 |
*/ |
|
633 |
enum TRequest |
|
634 |
{ |
|
635 |
/** Read request */ |
|
636 |
ERequestRead=0x0, |
|
637 |
/** Cancel read request */ |
|
638 |
ERequestReadCancel=0x1, |
|
639 |
/** Write reqeust */ |
|
640 |
ERequestWrite=0x1, |
|
641 |
/** Cancel write request */ |
|
642 |
ERequestWriteCancel=0x2, |
|
643 |
/** Break request */ |
|
644 |
ERequestBreak=0x2, |
|
645 |
/** Cancel break request */ |
|
646 |
ERequestBreakCancel=0x4, |
|
647 |
/** Signal change notification request */ |
|
648 |
ERequestNotifySignalChange=0x3, |
|
649 |
/** Cancel signal change notification request */ |
|
650 |
ERequestNotifySignalChangeCancel=0x8, |
|
651 |
}; |
|
652 |
||
653 |
/** |
|
654 |
Synchronous request types |
|
655 |
*/ |
|
656 |
enum TControl |
|
657 |
{ |
|
658 |
/** Get the current configuration */ |
|
659 |
EControlConfig, |
|
660 |
/** Set the device configuration */ |
|
661 |
EControlSetConfig, |
|
662 |
/** Get the device capabilities */ |
|
663 |
EControlCaps, |
|
664 |
/** Read the state of Modem control signals supported */ |
|
665 |
EControlSignals, |
|
666 |
/** Set the state of output modem control signals */ |
|
667 |
EControlSetSignals, |
|
668 |
/** Query the driver receive buffer for data availability */ |
|
669 |
EControlQueryReceiveBuffer, |
|
670 |
/** Reset the driver buffers */ |
|
671 |
EControlResetBuffers, |
|
672 |
/** Get the driver receive buffer length */ |
|
673 |
EControlReceiveBufferLength, |
|
674 |
/** Set the driver receive buffer length */ |
|
675 |
EControlSetReceiveBufferLength, |
|
676 |
/** Get the minimum turnaround time between a receive and subsequent transmission operation */ |
|
677 |
EControlMinTurnaroundTime, |
|
678 |
/** Set the minimum turnaround time between a receive and subsequent transmission operation */ |
|
679 |
EControlSetMinTurnaroundTime, |
|
680 |
#ifdef _DEBUG_DEVCOMM |
|
681 |
/** Get debug information from the driver */ |
|
682 |
EControlDebugInfo |
|
683 |
#endif |
|
684 |
}; |
|
685 |
||
686 |
public: |
|
687 |
#ifndef __KERNEL_MODE__ |
|
688 |
||
689 |
/** |
|
690 |
This function opens a channel and creates a handle to the serial driver. |
|
691 |
@param aUnit The unit number of the serial device. |
|
692 |
@return KErrNone, if successful; |
|
693 |
otherwise one of the other system-wide error codes. |
|
694 |
KErrPermissionDenied if the port given in aName is wrong or if the request fails the CSY's own security check; |
|
695 |
KErrNotSupported if this port is not supported by the CSY or the hardware; |
|
696 |
KErrLocked if the port has already been opened; |
|
697 |
KErrAccessDenied if the device driver encounteres a problem opening the hardware port. |
|
698 |
*/ |
|
699 |
inline TInt Open(TInt aUnit); |
|
700 |
||
701 |
/** |
|
702 |
Get the version number required by the driver |
|
703 |
@return The version number required by the driver |
|
704 |
@see TVersion |
|
705 |
*/ |
|
706 |
inline TVersion VersionRequired() const; |
|
707 |
||
708 |
/** |
|
709 |
Read from the channel |
|
710 |
@param aStatus The asynchronous request status |
|
711 |
@param aDes Buffer to be filled in by the driver |
|
712 |
*/ |
|
713 |
inline void Read(TRequestStatus &aStatus,TDes8 &aDes); |
|
714 |
||
715 |
/** |
|
716 |
Read from the channel |
|
717 |
@param aStatus The asynchronous request status |
|
718 |
@param aDes Buffer to be filled in by the driver |
|
719 |
@param aLength The length of the data to be read |
|
720 |
*/ |
|
721 |
inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength); |
|
722 |
||
723 |
/** |
|
724 |
Read one or more characters from the channel. |
|
725 |
If there is data in the serial driver's buffer when ReadOneOrMore() is called it will |
|
726 |
read as much data as possible (up to the maximum length of the supplied buffer) |
|
727 |
and then return. |
|
728 |
If there is no data in the buffer the request will complete as soon as one or more bytes arrive at the serial hardware. |
|
729 |
@param aStatus The asynchronous request status |
|
730 |
@param aDes Buffer to be filled in by the driver |
|
731 |
*/ |
|
732 |
inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes); |
|
733 |
||
734 |
/** |
|
735 |
Cancel a pending read request |
|
736 |
*/ |
|
737 |
inline void ReadCancel(); |
|
738 |
||
739 |
/** |
|
740 |
Write to the channel |
|
741 |
@param aStatus The asynchronous request status |
|
742 |
@param aDes Buffer containing the data to be sent |
|
743 |
*/ |
|
744 |
inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes); |
|
745 |
||
746 |
/** |
|
747 |
Write to the channel |
|
748 |
@param aStatus The asynchronous request status |
|
749 |
@param aDes Buffer containing the data to be sent |
|
750 |
@param aLength The length of the data to be sent |
|
751 |
*/ |
|
752 |
inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength); |
|
753 |
||
754 |
/** |
|
755 |
Cancel a pending write request |
|
756 |
*/ |
|
757 |
inline void WriteCancel(); |
|
758 |
||
759 |
/** |
|
760 |
Causes a break condition to be transmitted to the receiving device |
|
761 |
@param aStatus The asynchronous request status |
|
762 |
@param aTime The time interval in microseconds after which the break condition will be released |
|
763 |
*/ |
|
764 |
inline void Break(TRequestStatus &aStatus,TInt aTime); |
|
765 |
||
766 |
/** |
|
767 |
Cancel a pending break request |
|
768 |
*/ |
|
769 |
inline void BreakCancel(); |
|
770 |
||
771 |
/** |
|
772 |
Get the current configuration of the serial device |
|
773 |
@param aConfig A packaged object to be filled with the configuration information by the driver |
|
774 |
@see TCommConfigV02 |
|
775 |
*/ |
|
776 |
inline void Config(TDes8 &aConfig); |
|
777 |
||
778 |
/** |
|
779 |
Set the cofiguration of the serial device |
|
780 |
@param aConfig A packaged object containing the configuration information |
|
781 |
@see TCommConfigV02 |
|
782 |
*/ |
|
783 |
inline TInt SetConfig(const TDesC8 &aConfig); |
|
784 |
||
785 |
/** |
|
786 |
Get the capabilities of the serial device. |
|
787 |
@param aCaps A packaged object to be filled with the capabilities of the device. |
|
788 |
@see TCommCapsV03 |
|
789 |
*/ |
|
790 |
inline void Caps(TDes8 &aCaps); |
|
791 |
||
792 |
/** |
|
793 |
Get the status of the control lines |
|
794 |
@return A bitmask of KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG, |
|
795 |
KSignalRTS, KSignalDTR, KSignalBreak |
|
796 |
*/ |
|
797 |
inline TUint Signals(); |
|
798 |
||
799 |
/** |
|
800 |
Set and clear the control lines |
|
801 |
@param aSetMask Bitmask of signals to set |
|
802 |
@param aClearMask Bitmask of signals to clear |
|
803 |
@see Signals for a list of signals |
|
804 |
*/ |
|
805 |
inline void SetSignals(TUint aSetMask,TUint aClearMask); |
|
806 |
||
807 |
/** |
|
808 |
Get the number of unread characters in the receive buffer of the driver |
|
809 |
@return The number of unread characters |
|
810 |
*/ |
|
811 |
inline TInt QueryReceiveBuffer(); |
|
812 |
||
813 |
/** |
|
814 |
Reset the receive and transmit buffers. |
|
815 |
*/ |
|
816 |
inline void ResetBuffers(); |
|
817 |
||
818 |
/** |
|
819 |
Get the length of the receive buffer |
|
820 |
@return The length of the receive buffer |
|
821 |
*/ |
|
822 |
inline TInt ReceiveBufferLength(); |
|
823 |
||
824 |
/** |
|
825 |
Set the length of the receive buffer |
|
826 |
@param aLength The length of the receive buffer to be set |
|
827 |
*/ |
|
828 |
inline TInt SetReceiveBufferLength(TInt aLength); |
|
829 |
||
830 |
/** |
|
831 |
Request notification when one of the signals change. |
|
832 |
The signals that could change are KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG, |
|
833 |
KSignalRTS, KSignalDTR, KSignalBreak. |
|
834 |
@param aStatus The asynchronous request status |
|
835 |
@param aSignals Pointer to the bitmask containing the changed signals |
|
836 |
@param aSignalMask Bitmask of signals to be monitored |
|
837 |
*/ |
|
838 |
inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F); |
|
839 |
||
840 |
/** |
|
841 |
Cancel a pending signal change notification request |
|
842 |
*/ |
|
843 |
inline void NotifySignalChangeCancel(); |
|
844 |
||
845 |
/** |
|
846 |
Request notification when there is data available to be read from the driver receive buffer |
|
847 |
@param aStatus The asynchronous request status |
|
848 |
*/ |
|
849 |
inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus); |
|
850 |
||
851 |
/** |
|
852 |
Cancel a pending data notification request |
|
853 |
*/ |
|
854 |
inline void NotifyReceiveDataAvailableCancel(); |
|
855 |
||
856 |
/** |
|
857 |
Get the minimum turnaround time before a transmission can begin after a receive operation |
|
858 |
@return The turnaround time in microseconds |
|
859 |
*/ |
|
860 |
inline TUint MinTurnaroundTime(); |
|
861 |
||
862 |
/** |
|
863 |
Set the minimum turnaround time between a receive and the next transmission operation |
|
864 |
@param aMicroSeconds The turnaround time in microseconds |
|
865 |
*/ |
|
866 |
inline TInt SetMinTurnaroundTime(TUint aMicroSeconds); |
|
867 |
||
868 |
#ifdef _DEBUG_DEVCOMM |
|
869 |
/** |
|
870 |
Get the debug information |
|
871 |
@param aInfo a packaged object to be filled by the driver with debug information |
|
872 |
@see TCommDebugInfo |
|
873 |
*/ |
|
874 |
inline void DebugInfo(TDes8 &aInfo); |
|
875 |
#endif |
|
876 |
#endif |
|
877 |
}; |
|
878 |
||
879 |
class RBusDevCommDCE : public RBusLogicalChannel |
|
880 |
{ |
|
881 |
public: |
|
882 |
enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber}; |
|
883 |
enum TRequest |
|
884 |
{ |
|
885 |
ERequestRead=0x0,ERequestReadCancel=0x1, |
|
886 |
ERequestWrite=0x1,ERequestWriteCancel=0x2, |
|
887 |
ERequestBreak=0x2,ERequestBreakCancel=0x4, |
|
888 |
ERequestNotifySignalChange=0x3,ERequestNotifySignalChangeCancel=0x8, |
|
889 |
ERequestNotifyFlowControlChange=0x4,ERequestNotifyFlowControlChangeCancel=0x10, |
|
890 |
ERequestNotifyConfigChange=0x5,ERequestNotifyConfigChangeCancel=0x20 |
|
891 |
}; |
|
892 |
enum TControl |
|
893 |
{ |
|
894 |
EControlConfig,EControlSetConfig,EControlCaps, |
|
895 |
EControlSignals,EControlSetSignals, |
|
896 |
EControlQueryReceiveBuffer,EControlResetBuffers, |
|
897 |
EControlReceiveBufferLength,EControlSetReceiveBufferLength, |
|
898 |
EControlFlowControlStatus, |
|
899 |
#ifdef _DEBUG_DEVCOMM |
|
900 |
EControlDebugInfo |
|
901 |
#endif |
|
902 |
}; |
|
903 |
public: |
|
904 |
#ifndef __KERNEL_MODE__ |
|
905 |
inline TInt Open(TInt aUnit); |
|
906 |
inline TVersion VersionRequired() const; |
|
907 |
inline void Read(TRequestStatus &aStatus,TDes8 &aDes); |
|
908 |
inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength); |
|
909 |
inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes); |
|
910 |
inline void ReadCancel(); |
|
911 |
inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes); |
|
912 |
inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength); |
|
913 |
inline void WriteCancel(); |
|
914 |
inline void Break(TRequestStatus &aStatus,TInt aTime); |
|
915 |
inline void BreakCancel(); |
|
916 |
inline void Config(TDes8 &aConfig); |
|
917 |
inline TInt SetConfig(const TDesC8 &aConfig); |
|
918 |
inline void Caps(TDes8 &aCaps); |
|
919 |
inline TUint Signals(); |
|
920 |
inline void SetSignals(TUint aSetMask,TUint aClearMask); |
|
921 |
inline TInt QueryReceiveBuffer(); |
|
922 |
inline void ResetBuffers(); |
|
923 |
inline TInt ReceiveBufferLength(); |
|
924 |
inline TInt SetReceiveBufferLength(TInt aLength); |
|
925 |
inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F); |
|
926 |
inline void NotifySignalChangeCancel(); |
|
927 |
inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus); |
|
928 |
inline void NotifyReceiveDataAvailableCancel(); |
|
929 |
inline void NotifyFlowControlChange(TRequestStatus& aStatus); |
|
930 |
inline void NotifyFlowControlChangeCancel(); |
|
931 |
inline void GetFlowControlStatus(TFlowControl& aFlowControl); |
|
932 |
inline void NotifyConfigChange(TRequestStatus& aStatus, TDes8& aNewConfig); |
|
933 |
inline void NotifyConfigChangeCancel(); |
|
934 |
#ifdef _DEBUG_DEVCOMM |
|
935 |
inline void DebugInfo(TDes8 &aInfo); |
|
936 |
#endif |
|
937 |
#endif |
|
938 |
}; |
|
939 |
||
940 |
#include <d32comm.inl> |
|
941 |
#endif |