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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\d32comm.h
18 //#define _DEBUG_DEVCOMM
32 Enumeration of number of data bits for serial port configuration.
33 Typically, these values are used to initialize the iDataBits of
34 TCommConfigV01 before calling DComm::Configure() or any other serial
35 comm API to configure the serial port's databits size.
37 enum TDataBits {EData5,EData6,EData7,EData8};
39 Enumeration of number of stop bits for serial port configuration.
40 Typically, these values are used to initialize the iStopBits of
41 TCommConfigV01 before calling DComm::Configure() or any other serial
42 comm API to configure the serial port's stopbits.
44 enum TStopBits {EStop1,EStop2};
46 Enumeration of types of parity for serial port configuration.
47 Typically, these values are used to initialize the iParity of
48 TCommConfigV01 before calling DComm::Configure() or any other serial
49 comm API to configure the serial port's parity setting.
51 enum TParity {EParityNone,EParityEven,EParityOdd,EParityMark,EParitySpace};
53 Enumeration of baud rates in bits per second for serial port configuration.
54 * e.g EBps115200 is for 115200Bps data rate
55 Typically, these values are used to initialize the iRate of TCommConfigV01
56 before calling DComm::Configure() or any other serial comm API to configure
57 the serial port's baud rate.
86 EBpsAutobaud=0x40000000,
87 EBpsSpecial=0x80000000,
90 Enumeration of Fifo status (enable and disable) for serial port configuration.
91 Typically, these values are used to initialize the iFifo of TCommConfigV01
92 before calling DComm::Configure() or any other serial comm API to configure
93 the serial port's fifo.
97 EFifoEnable,EFifoDisable,
100 Enumeration of SIR status (enable and disable) for serial comm configuration.
101 Typically, these values are used to initialize the iSIREnable of TCommConfigV01
102 before calling DComm::Configure() or any other serial comm API to configure
103 the serial port's SIR (infrared) settings.
107 ESIREnable,ESIRDisable,
112 EFlowControlOn,EFlowControlOff
116 const TInt KConfigMaxTerminators=4;
118 const TUint KConfigObeyXoff=0x01;
119 const TUint KConfigSendXoff=0x02;
120 const TUint KConfigObeyCTS=0x04;
121 const TUint KConfigFailCTS=0x08;
122 const TUint KConfigObeyDSR=0x10;
123 const TUint KConfigFailDSR=0x20;
124 const TUint KConfigObeyDCD=0x40;
125 const TUint KConfigFailDCD=0x80;
126 const TUint KConfigFreeRTS=0x100;
127 const TUint KConfigFreeDTR=0x200;
129 const TUint KConfigObeyDTR=0x400;
130 const TUint KConfigFailDTR=0x800;
131 const TUint KConfigObeyRTS=0x1000;
132 const TUint KConfigFailRTS=0x2000;
133 const TUint KConfigFreeDSR=0x4000;
134 const TUint KConfigFreeCTS=0x8000;
135 const TUint KConfigFreeDCD=0x10000;
136 const TUint KConfigFreeRI=0x20000;
137 const TUint KConfigWriteBufferedComplete=0x80000000;
139 const TUint KConfigParityErrorFail=0;
140 const TUint KConfigParityErrorIgnore=0x01;
141 const TUint KConfigParityErrorReplaceChar=0x02;
142 const TUint KConfigXonXoffDebug=0x80000000;
144 const TUint KSignalCTS=0x01;
145 const TUint KSignalDSR=0x02;
146 const TUint KSignalDCD=0x04;
147 const TUint KSignalRNG=0x08;
148 const TUint KSignalRTS=0x10;
149 const TUint KSignalDTR=0x20;
150 const TUint KSignalBreak=0x40;
152 const TUint KSignalChanged=0x1000;
153 const TUint KCTSChanged=KSignalCTS*KSignalChanged;
154 const TUint KDSRChanged=KSignalDSR*KSignalChanged;
155 const TUint KDCDChanged=KSignalDCD*KSignalChanged;
156 const TUint KRNGChanged=KSignalRNG*KSignalChanged;
157 const TUint KRTSChanged=KSignalRTS*KSignalChanged;
158 const TUint KDTRChanged=KSignalDTR*KSignalChanged;
159 const TUint KBreakChanged=KSignalBreak*KSignalChanged;
161 const TUint KSignalDTEOutputs=KSignalRTS|KSignalDTR;
162 const TUint KSignalDTEInputs=KSignalCTS|KSignalDSR|KSignalDCD|KSignalRNG;
163 const TUint KSignalDCEInputs=KSignalDTEOutputs;
164 const TUint KSignalDCEOutputs=KSignalDTEInputs;
166 const TUint KConfigSIRPulseWidthMaximum=0x01;
167 const TUint KConfigSIRPulseWidthMinimum=0x02;
169 // more SIRSettings for selecting the IR range
170 const TUint KConfigSIRShutDown=0x10;
171 const TUint KConfigSIRMinimumRange=0x20;
172 const TUint KConfigSIRMediumRange=0x40;
173 const TUint KConfigSIRMaximumRange=0x80;
176 Comms configuration structure.
177 Class to hold the configuration settings for serial comm port
179 This class provides the serial port configuration block interface of serial comms (c32).
180 A serial comm client sets up a serial port before use, by providing a configuration block.
181 TCommConfigV01 is initialized with settings for serial port and used to configure the
182 serial port by calling DComm::Configure(TCommConfigV01 &aConfig) or any other serial comm
183 API to configure the serial port.
189 Data rate in bits per second.
194 Character width in bits.
209 Type of Handshaking control.
210 Possible values can be KConfigObeyXXX or KConfigSendXXX or KConfigFailXXX or KConfigFreeXXX
214 Type of error to generate on a parity failure.
215 Possible values can be KConfigParityErrorFail or KConfigParityErrorIgnore or KConfigParityErrorReplaceChar
219 FIFO status, enabled or disabled.
224 Special data rate, not listed under TBps. Use this, when iRate is set to EBpsSpecial
228 Count of number of special characters used as terminators (<=KConfigMaxTerminators)
230 TInt iTerminatorCount;
232 Array of special characters which can be used as terminators
234 TText8 iTerminator[KConfigMaxTerminators];
236 Character used to signal the transmitter to resume sending when using XON/XOFF handshaking
237 i.e character used as XON - software flow control
241 Character used to signal the transmitter to suspend sending when using XON/XOFF handshaking
242 i.e character used as XOFF - software flow control
246 Character used to replace the characters received with a parity error.
247 This is used when iParityError is set to KConfigParityErrorReplaceChar
249 TText8 iParityErrorChar;
251 Switch the SIR encoding hardware on and off.
256 SIR hardware control setting. Possible value can be one of KConfigSIRXXX
261 Package buffer for a TCommConfigV01 object.
263 TCommConfig packages the comms configuration structure TCommConfigV01 to a buffer.
264 This is used with API of serial comms like RComm::Config(TDes8 &aConfig) and
265 RComm::SetConfig(TDesC8 &aConfig) where config structure is passed as buffer.
269 typedef TPckgBuf<TCommConfigV01> TCommConfig;
271 // TCommConfigV02 is deprecated.
273 class TCommConfigV02: public TCommConfigV01
276 TInt iTxShutdownTimeout;
279 // TCommConfig2 is deprecated
281 typedef TPckgBuf<TCommConfigV02> TCommConfig2;
284 const TUint KCapsBps50=0x00000001;
285 const TUint KCapsBps75=0x00000002;
286 const TUint KCapsBps110=0x00000004;
287 const TUint KCapsBps134=0x00000008;
288 const TUint KCapsBps150=0x00000010;
289 const TUint KCapsBps300=0x00000020;
290 const TUint KCapsBps600=0x00000040;
291 const TUint KCapsBps1200=0x00000080;
292 const TUint KCapsBps1800=0x00000100;
293 const TUint KCapsBps2000=0x00000200;
294 const TUint KCapsBps2400=0x00000400;
295 const TUint KCapsBps3600=0x00000800;
296 const TUint KCapsBps4800=0x00001000;
297 const TUint KCapsBps7200=0x00002000;
298 const TUint KCapsBps9600=0x00004000;
299 const TUint KCapsBps19200=0x00008000;
300 const TUint KCapsBps38400=0x00010000;
301 const TUint KCapsBps57600=0x00020000;
302 const TUint KCapsBps115200=0x00040000;
303 const TUint KCapsBps230400=0x00080000;
304 const TUint KCapsBps460800=0x00100000;
305 const TUint KCapsBps576000 =0x00200000;
306 const TUint KCapsBps1152000=0x00400000;
307 const TUint KCapsBps4000000=0x00800000;
308 const TUint KCapsBps921600=0x01000000;
309 const TUint KCapsBpsAutobaud=0x40000000;
310 const TUint KCapsBpsSpecial=0x80000000;
312 const TUint KCapsData5=0x01;
313 const TUint KCapsData6=0x02;
314 const TUint KCapsData7=0x04;
315 const TUint KCapsData8=0x08;
317 const TUint KCapsStop1=0x01;
318 const TUint KCapsStop2=0x02;
320 const TUint KCapsParityNone=0x01;
321 const TUint KCapsParityEven=0x02;
322 const TUint KCapsParityOdd=0x04;
323 const TUint KCapsParityMark=0x08;
324 const TUint KCapsParitySpace=0x10;
326 const TUint KCapsSignalCTSSupported=0x01;
327 const TUint KCapsSignalDSRSupported=0x02;
328 const TUint KCapsSignalDCDSupported=0x04;
329 const TUint KCapsSignalRNGSupported=0x08;
330 const TUint KCapsSignalRTSSupported=0x10;
331 const TUint KCapsSignalDTRSupported=0x20;
333 const TUint KCapsObeyXoffSupported=0x01;
334 const TUint KCapsSendXoffSupported=0x02;
335 const TUint KCapsObeyCTSSupported=0x04;
336 const TUint KCapsFailCTSSupported=0x08;
337 const TUint KCapsObeyDSRSupported=0x10;
338 const TUint KCapsFailDSRSupported=0x20;
339 const TUint KCapsObeyDCDSupported=0x40;
340 const TUint KCapsFailDCDSupported=0x80;
341 const TUint KCapsFreeRTSSupported=0x100;
342 const TUint KCapsFreeDTRSupported=0x200;
344 const TUint KCapsObeyRTSSupported=0x400;
345 const TUint KCapsObeyDTRSupported=0x800;
347 const TUint KCapsHasFifo=0x01;
349 const TUint KCapsSIR115kbps=0x01;
350 const TUint KCapsSIR2400bpsOnly=0x02;
351 const TUint KCapsSIR4Mbs=0x04;
353 const TUint KNotifySignalsChangeSupported=0x01;
354 const TUint KNotifyRateChangeSupported=0x02;
355 const TUint KNotifyDataFormatChangeSupported=0x04;
356 const TUint KNotifyHandshakeChangeSupported=0x08;
357 const TUint KNotifyBreakSupported=0x10;
358 const TUint KNotifyFlowControlChangeSupported=0x20;
359 const TUint KNotifyDataAvailableSupported=0x40;
360 const TUint KNotifyOutputEmptySupported=0x80;
362 const TUint KCapsRoleSwitchSupported=0x01;
364 const TUint KCapsFlowControlStatusSupported=0x01;
366 const TUint KRateChanged=0x01;
367 const TUint KDataFormatChanged=0x02;
368 const TUint KHandshakeChanged=0x04;
382 typedef TPckgBuf<TCommCapsV01> TCommCaps;
384 class TCommCapsV02 : public TCommCapsV01
387 TUint iNotificationCaps;
389 TUint iFlowControlCaps;
391 typedef TPckgBuf<TCommCapsV02> TCommCaps2;
393 class TCommCapsV03 : public TCommCapsV02
396 TBool iBreakSupported;
398 typedef TPckgBuf<TCommCapsV03> TCommCaps3;
401 class TCapsDevCommV01
407 class TCommNotificationV01
410 TUint iChangedMembers;
417 typedef TPckgBuf<TCommNotificationV01> TCommNotificationPckg;
419 const TUint KDataAvailableNotifyFlag=0x80000000;
421 #ifdef _DEBUG_DEVCOMM
439 TBool iDrainingRxBuf;
448 TInt iTxChars, iRxChars;
449 TInt iTxXon, iTxXoff, iRxXon, iRxXoff;
451 typedef TPckgBuf<TCommDebugInfo> TCommDebugInfoPckg;
454 class RBusDevComm : public RBusLogicalChannel
457 enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
460 ERequestRead=0x0,ERequestReadCancel=0x1,
461 ERequestWrite=0x1,ERequestWriteCancel=0x2,
462 ERequestBreak=0x2,ERequestBreakCancel=0x4,
463 ERequestNotifySignalChange=0x3,ERequestNotifySignalChangeCancel=0x8,
467 EControlConfig,EControlSetConfig,EControlCaps,
468 EControlSignals,EControlSetSignals,
469 EControlQueryReceiveBuffer,EControlResetBuffers,
470 EControlReceiveBufferLength,EControlSetReceiveBufferLength,
471 EControlMinTurnaroundTime,EControlSetMinTurnaroundTime,
472 #ifdef _DEBUG_DEVCOMM
477 #ifndef __KERNEL_MODE__
478 inline TInt Open(TInt aUnit);
479 inline TVersion VersionRequired() const;
480 inline void Read(TRequestStatus &aStatus,TDes8 &aDes);
481 inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength);
482 inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes);
483 inline void ReadCancel();
484 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes);
485 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength);
486 inline void WriteCancel();
487 inline void Break(TRequestStatus &aStatus,TInt aTime);
488 inline void BreakCancel();
489 inline void Config(TDes8 &aConfig);
490 inline TInt SetConfig(const TDesC8 &aConfig);
491 inline void Caps(TDes8 &aCaps);
492 inline TUint Signals();
493 inline void SetSignals(TUint aSetMask,TUint aClearMask);
494 inline TInt QueryReceiveBuffer();
495 inline void ResetBuffers();
496 inline TInt ReceiveBufferLength();
497 inline TInt SetReceiveBufferLength(TInt aLength);
498 inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F);
499 inline void NotifySignalChangeCancel();
500 inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus);
501 inline void NotifyReceiveDataAvailableCancel();
502 inline TUint MinTurnaroundTime();
503 inline TInt SetMinTurnaroundTime(TUint aMicroSeconds);
504 #ifdef _DEBUG_DEVCOMM
505 inline void DebugInfo(TDes8 &aInfo);
510 class RBusDevCommDCE : public RBusLogicalChannel
513 enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
516 ERequestRead=0x0,ERequestReadCancel=0x1,
517 ERequestWrite=0x1,ERequestWriteCancel=0x2,
518 ERequestBreak=0x2,ERequestBreakCancel=0x4,
519 ERequestNotifySignalChange=0x3,ERequestNotifySignalChangeCancel=0x8,
520 ERequestNotifyFlowControlChange=0x4,ERequestNotifyFlowControlChangeCancel=0x10,
521 ERequestNotifyConfigChange=0x5,ERequestNotifyConfigChangeCancel=0x20
525 EControlConfig,EControlSetConfig,EControlCaps,
526 EControlSignals,EControlSetSignals,
527 EControlQueryReceiveBuffer,EControlResetBuffers,
528 EControlReceiveBufferLength,EControlSetReceiveBufferLength,
529 EControlFlowControlStatus,
530 #ifdef _DEBUG_DEVCOMM
535 #ifndef __KERNEL_MODE__
536 inline TInt Open(TInt aUnit);
537 inline TVersion VersionRequired() const;
538 inline void Read(TRequestStatus &aStatus,TDes8 &aDes);
539 inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength);
540 inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes);
541 inline void ReadCancel();
542 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes);
543 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength);
544 inline void WriteCancel();
545 inline void Break(TRequestStatus &aStatus,TInt aTime);
546 inline void BreakCancel();
547 inline void Config(TDes8 &aConfig);
548 inline TInt SetConfig(const TDesC8 &aConfig);
549 inline void Caps(TDes8 &aCaps);
550 inline TUint Signals();
551 inline void SetSignals(TUint aSetMask,TUint aClearMask);
552 inline TInt QueryReceiveBuffer();
553 inline void ResetBuffers();
554 inline TInt ReceiveBufferLength();
555 inline TInt SetReceiveBufferLength(TInt aLength);
556 inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F);
557 inline void NotifySignalChangeCancel();
558 inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus);
559 inline void NotifyReceiveDataAvailableCancel();
560 inline void NotifyFlowControlChange(TRequestStatus& aStatus);
561 inline void NotifyFlowControlChangeCancel();
562 inline void GetFlowControlStatus(TFlowControl& aFlowControl);
563 inline void NotifyConfigChange(TRequestStatus& aStatus, TDes8& aNewConfig);
564 inline void NotifyConfigChangeCancel();
565 #ifdef _DEBUG_DEVCOMM
566 inline void DebugInfo(TDes8 &aInfo);
571 #include <d32comm.inl>