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