kernel/eka/include/d32comm.h
changeset 0 a41df078684a
child 36 538db54a451d
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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>
       
    30 
       
    31 /**
       
    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.
       
    36  */
       
    37 enum TDataBits {EData5,EData6,EData7,EData8};
       
    38 /**
       
    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.
       
    43  */
       
    44 enum TStopBits {EStop1,EStop2};
       
    45 /**
       
    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.
       
    50  */
       
    51 enum TParity {EParityNone,EParityEven,EParityOdd,EParityMark,EParitySpace};
       
    52 /**
       
    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.
       
    58  */
       
    59 enum TBps
       
    60 	{
       
    61 	EBps50,
       
    62 	EBps75,
       
    63 	EBps110,
       
    64 	EBps134,
       
    65 	EBps150,
       
    66 	EBps300,
       
    67 	EBps600,
       
    68 	EBps1200,
       
    69 	EBps1800,
       
    70 	EBps2000,
       
    71 	EBps2400,
       
    72 	EBps3600,
       
    73 	EBps4800,
       
    74 	EBps7200,
       
    75 	EBps9600,
       
    76 	EBps19200,
       
    77 	EBps38400,
       
    78 	EBps57600,
       
    79 	EBps115200,
       
    80 	EBps230400,
       
    81 	EBps460800,
       
    82 	EBps576000,
       
    83 	EBps1152000,
       
    84 	EBps4000000,
       
    85 	EBps921600,
       
    86 	EBpsAutobaud=0x40000000,
       
    87 	EBpsSpecial=0x80000000,
       
    88 	};
       
    89 /**
       
    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.
       
    94  */
       
    95 enum TFifo
       
    96 	{
       
    97 	EFifoEnable,EFifoDisable,
       
    98 	};
       
    99 /**
       
   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.
       
   104  */
       
   105 enum TSir 
       
   106 	{
       
   107 	ESIREnable,ESIRDisable,
       
   108 	};
       
   109 
       
   110 enum TFlowControl
       
   111 	{
       
   112 	EFlowControlOn,EFlowControlOff
       
   113 	};
       
   114 //
       
   115 
       
   116 const TInt KConfigMaxTerminators=4;
       
   117 // DTE Constants
       
   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;
       
   128 // DCE Constants
       
   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;
       
   138 //
       
   139 const TUint KConfigParityErrorFail=0;
       
   140 const TUint KConfigParityErrorIgnore=0x01;
       
   141 const TUint KConfigParityErrorReplaceChar=0x02;
       
   142 const TUint KConfigXonXoffDebug=0x80000000;
       
   143 //
       
   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;
       
   151 
       
   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;
       
   160 
       
   161 const TUint KSignalDTEOutputs=KSignalRTS|KSignalDTR;
       
   162 const TUint KSignalDTEInputs=KSignalCTS|KSignalDSR|KSignalDCD|KSignalRNG;
       
   163 const TUint KSignalDCEInputs=KSignalDTEOutputs;
       
   164 const TUint KSignalDCEOutputs=KSignalDTEInputs;
       
   165 
       
   166 const TUint KConfigSIRPulseWidthMaximum=0x01;
       
   167 const TUint KConfigSIRPulseWidthMinimum=0x02;
       
   168 
       
   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;
       
   174 
       
   175 /**
       
   176  Comms configuration structure.
       
   177  Class to hold the configuration settings for serial comm port
       
   178  
       
   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.
       
   184  */
       
   185 class TCommConfigV01
       
   186     {
       
   187 public:
       
   188 	/** 
       
   189 	 Data rate in bits per second.
       
   190 	 @see TBps 	
       
   191 	 */
       
   192 	TBps iRate;
       
   193 	/** 
       
   194 	 Character width in bits.
       
   195 	 @see TDataBits
       
   196 	 */	
       
   197 	TDataBits iDataBits;
       
   198 	/**
       
   199 	 Number of stop bits.
       
   200 	 @see TStopBits
       
   201 	 */
       
   202 	TStopBits iStopBits;
       
   203 	/**
       
   204 	 Type of parity.
       
   205 	 @see TParity 
       
   206 	 */
       
   207 	TParity iParity;
       
   208 	/**
       
   209 	 Type of Handshaking control.
       
   210 	 Possible values can be KConfigObeyXXX or KConfigSendXXX or KConfigFailXXX or KConfigFreeXXX
       
   211 	 */
       
   212 	TUint iHandshake;
       
   213 	/**
       
   214 	 Type of error to generate on a parity failure.
       
   215 	 Possible values can be KConfigParityErrorFail or KConfigParityErrorIgnore or KConfigParityErrorReplaceChar
       
   216 	 */
       
   217 	TUint iParityError;
       
   218 	/**
       
   219 	 FIFO status, enabled or disabled.
       
   220 	 @see TFifo 
       
   221 	 */
       
   222 	TUint iFifo;
       
   223 	/**
       
   224 	 Special data rate, not listed under TBps. Use this, when iRate is set to EBpsSpecial 
       
   225 	 */
       
   226 	TInt iSpecialRate;
       
   227 	/**
       
   228 	 Count of number of special characters used as terminators (<=KConfigMaxTerminators) 
       
   229 	 */				
       
   230 	TInt iTerminatorCount;
       
   231 	/**
       
   232 	 Array of special characters which can be used as terminators 
       
   233 	 */
       
   234 	TText8 iTerminator[KConfigMaxTerminators];
       
   235 	/**
       
   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
       
   238 	 */
       
   239 	TText8 iXonChar;
       
   240 	/**
       
   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
       
   243 	 */
       
   244 	TText8 iXoffChar;
       
   245 	/**
       
   246 	 Character used to replace the characters received with a parity error.
       
   247 	 This is used when iParityError is set to KConfigParityErrorReplaceChar 
       
   248 	 */	
       
   249 	TText8 iParityErrorChar;
       
   250 	/**
       
   251 	 Switch the SIR encoding hardware on and off.
       
   252 	 @see TSir
       
   253 	 */
       
   254 	TSir iSIREnable;
       
   255 	/**
       
   256 	 SIR hardware control setting. Possible value can be one of KConfigSIRXXX
       
   257 	 */
       
   258 	TUint iSIRSettings;
       
   259 	};
       
   260 /** 
       
   261  Package buffer for a TCommConfigV01 object.
       
   262  
       
   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.
       
   266  
       
   267  @see TCommConfigV01
       
   268  */		
       
   269 typedef TPckgBuf<TCommConfigV01> TCommConfig;
       
   270 
       
   271 // TCommConfigV02 is deprecated.
       
   272 //
       
   273 class TCommConfigV02: public TCommConfigV01
       
   274 	{
       
   275 public:		
       
   276 	TInt iTxShutdownTimeout;
       
   277 	};
       
   278 
       
   279 // TCommConfig2 is deprecated
       
   280 // 
       
   281 typedef TPckgBuf<TCommConfigV02> TCommConfig2;
       
   282 
       
   283 //
       
   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;
       
   311 //
       
   312 const TUint KCapsData5=0x01;
       
   313 const TUint KCapsData6=0x02;
       
   314 const TUint KCapsData7=0x04;
       
   315 const TUint KCapsData8=0x08;
       
   316 //
       
   317 const TUint KCapsStop1=0x01;
       
   318 const TUint KCapsStop2=0x02;
       
   319 //
       
   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;
       
   325 //
       
   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;
       
   332 //
       
   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;
       
   343 // DCE Constants
       
   344 const TUint KCapsObeyRTSSupported=0x400;
       
   345 const TUint KCapsObeyDTRSupported=0x800;
       
   346 //
       
   347 const TUint KCapsHasFifo=0x01;
       
   348 //
       
   349 const TUint KCapsSIR115kbps=0x01;
       
   350 const TUint KCapsSIR2400bpsOnly=0x02;
       
   351 const TUint KCapsSIR4Mbs=0x04;
       
   352 //
       
   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;
       
   361 //
       
   362 const TUint KCapsRoleSwitchSupported=0x01;
       
   363 //
       
   364 const TUint KCapsFlowControlStatusSupported=0x01;
       
   365 //
       
   366 const TUint KRateChanged=0x01;
       
   367 const TUint KDataFormatChanged=0x02;
       
   368 const TUint KHandshakeChanged=0x04;
       
   369 //
       
   370 
       
   371 /**
       
   372  Comms capability structure.
       
   373  Class to query the capability settings for serial comm port device.
       
   374  Members of this class are filled with the capabilities of the comm port device.
       
   375  */
       
   376 
       
   377 class TCommCapsV01
       
   378 	{
       
   379 public:
       
   380 	/** 
       
   381 	 Data rates supported, in bits per second.
       
   382 	 The value is a bitmask made by OR-ing KCapsBpsXXX values.
       
   383 	 Each set bit corresponds to a supported bit rate.
       
   384 	 */
       
   385 	TUint iRate;
       
   386 	/**
       
   387 	 Character widths supported, in bits.
       
   388 	 The value is a bitmask made by OR-ing a combination of KCapsData5, KCapsData6, KCapsData7 and KCapsData8 values.
       
   389 	 Each set bit corresponds to a supported character width. 
       
   390 	 */	
       
   391 	TUint iDataBits;
       
   392 	/**
       
   393 	 Number of stop bits supported.
       
   394 	 The value is one of KCapsStop1, KCapsStop2 or KCapsStop1|KCapsStop2.
       
   395 	 Each set bit corresponds to a supported number of stop bit.
       
   396 	 */
       
   397 	TUint iStopBits;
       
   398 	/**
       
   399 	 Parity types supported.
       
   400 	 The value is a bitmask made by OR-ing a combination of KCapsParityNone, KCapsParityEven, KCapsParityOdd, KCapsParityMark and KCapsParitySpace values.
       
   401 	 Each set bit corresponds to a supported parity type. 
       
   402 	 */
       
   403 	TUint iParity;
       
   404 	/**
       
   405 	 Type of Handshaking protocols supported by the device.
       
   406 	 The value is a bitmask made by OR-ing a combination of KCapsObeyXXX, KCapsSendXXX, KCapsFailXXX and KCapsFreeXXX values.
       
   407 	 Each set bit corresponds to a supported handshaking protocol.
       
   408 	 */
       
   409 	TUint iHandshake;
       
   410 	/**
       
   411 	 Type of Signals supported by the device.
       
   412 	 The value is a bitmask made by OR-ing a combination of KCapsSignalXXX values.
       
   413 	 Each set bit corresponds to a supported signal.
       
   414 	 */
       
   415 	TUint iSignals;
       
   416 	/**
       
   417 	 Whether Fifo is enabled or disabled.
       
   418 	 Value is KCapsHasFifo if enabled, 0 otherwise
       
   419 	 */
       
   420 	TUint iFifo;
       
   421 	/**
       
   422 	 Capabilities of the SIR encoding hardware.
       
   423 	 The value is a bitmask made by OR-ing a combination of KCapsSIR115kbps, KCapsSIR2400bpsOnly and KCapsSIR4Mbps values.
       
   424 	 Each set bit corresponds to a supported SIR capability.
       
   425 	 */
       
   426 	TUint iSIR;
       
   427 	};
       
   428 /** 
       
   429  Package buffer for a TCommCapsV01 object.
       
   430  
       
   431  TCommCaps packages the comms capability structure TCommCapsV01 in a buffer. 
       
   432  This is used by serial comms APIs to pass the capability structure as a buffer,
       
   433  for example in RComm::Caps(TDes8 &aCaps).
       
   434   
       
   435  @see TCommCapsV01
       
   436  */		
       
   437 typedef TPckgBuf<TCommCapsV01> TCommCaps;
       
   438 
       
   439 /**
       
   440  Comms capability structure.
       
   441  Class to query the capability settings for serial comm port.
       
   442  Members of this class are filled with the capabilities of the comm port.
       
   443  
       
   444  @see TCommCapsV01
       
   445  */
       
   446 class TCommCapsV02 : public TCommCapsV01
       
   447 	{
       
   448 public:
       
   449 	/**
       
   450 	 Specifies the notifications that are supported for the serial comm port.
       
   451 	 The field is a bitmask made by OR-ing a combination of:
       
   452 	 	-KNotifySignalsChangeSupported
       
   453 		-KNotifyRateChangeSupported
       
   454 		-KNotifyDataFormatChangeSupported
       
   455 		-KNotifyHandshakeChangeSupported
       
   456 		-KNotifyBreakSupported
       
   457 		-KNotifyFlowControlChangeSupported
       
   458 		-KNotifyDataAvailableSupported
       
   459 		-KNotifyOutputEmptySupported
       
   460 	 Each set bit corresponds to a supported notification type.
       
   461 	 */
       
   462 	TUint iNotificationCaps;
       
   463 	/**
       
   464 	 Specifies whether Role Switch is supported or not.
       
   465 	 If supported the value is KCapsRoleSwitchSupported, otherwise Zero
       
   466 	 */
       
   467 	TUint iRoleCaps;
       
   468 	/**
       
   469 	 Specifies whether Flow Control Status is supported or not.
       
   470 	 If supported the value is KCapsFlowControlStatusSupported, otherwise Zero
       
   471 	 */
       
   472 	TUint iFlowControlCaps;
       
   473 	};
       
   474 	
       
   475 /** 
       
   476  Package buffer for a TCommCapsV02 object.
       
   477  
       
   478  TCommCaps2 packages the comms capability structure TCommCapsV02 in a buffer. 
       
   479  This is used by serial comms to pass the capability structure as a buffer,
       
   480  for example in RComm::Caps(TDes8 &aCaps) 
       
   481  
       
   482  @see TCommCapsV02
       
   483  */		
       
   484 typedef TPckgBuf<TCommCapsV02> TCommCaps2;
       
   485 
       
   486 
       
   487 /**
       
   488  Comms capability structure.
       
   489  Class to hold the capability settings for serial comm port.
       
   490  
       
   491  This class is used to query the capabilities of the serial comm port.
       
   492  Members of this class are filled with the capabilities of the comm port.
       
   493  
       
   494  @see TCommCapsV02
       
   495  */
       
   496 class TCommCapsV03 : public TCommCapsV02
       
   497 	{
       
   498 public:
       
   499 	/**
       
   500 	 Specifies whether break is supported or not.
       
   501 	 ETrue if Supported, EFalse otherwise.
       
   502 	 */
       
   503 	TBool iBreakSupported;
       
   504 	};
       
   505 	
       
   506 /** 
       
   507  Package buffer for a TCommCapsV03 object.
       
   508  
       
   509  TCommCaps3 packages the comms capability structure TCommCapsV03 in a buffer. 
       
   510  This is used by serial comms APIs to pass the capability structure as a buffer,
       
   511  for example in RComm::Caps(TDes8 &aCaps) 
       
   512  
       
   513  @see TCommCapsV03
       
   514  */	
       
   515 typedef TPckgBuf<TCommCapsV03> TCommCaps3;
       
   516 
       
   517 /**
       
   518  Structure that holds the capabilities of the Comms factory object. Only Version is supported.
       
   519  This structure is packaged within a descriptor when passed to methods such as RDevice::GetCaps()
       
   520  */
       
   521 class TCapsDevCommV01
       
   522 	{
       
   523 public:
       
   524 	/**
       
   525 	Version of the device
       
   526 	@see TVersion
       
   527 	*/
       
   528 	TVersion version;
       
   529 	};
       
   530 
       
   531 /**
       
   532  Comms Notification configuration structure
       
   533  Class to hold the notification configuration of the device.
       
   534  Notifications are only used with DCE (modem) comms ports.
       
   535  */
       
   536 class TCommNotificationV01
       
   537 	{
       
   538 public:
       
   539 	/**
       
   540 	 Specifies which of the configuration members have changed
       
   541 	 This value is a bitmask made by OR-ing a combination of KRateChanged,KDataFormatChanged and KHandshakeChanged values.
       
   542 	 Each set bit corresponds to a change in the configuration notification.
       
   543 	 @see TCommCapsV01
       
   544 	 */
       
   545 	TUint iChangedMembers;
       
   546 	/** 
       
   547 	 Data rate in bits per second.
       
   548 	 @see TBps 	
       
   549 	 */
       
   550 	TBps iRate;
       
   551 	/** 
       
   552 	 Character width in bits.
       
   553 	 @see TDataBits
       
   554 	 */	
       
   555 	TDataBits iDataBits;
       
   556 	/**
       
   557 	 Number of stop bits.
       
   558 	 @see TStopBits
       
   559 	 */
       
   560 	TStopBits iStopBits;
       
   561 	/**
       
   562 	 Type of parity.
       
   563 	 @see TParity 
       
   564 	 */
       
   565 	TParity iParity;
       
   566 	/**
       
   567 	 Type of Handshaking control.
       
   568 	 Possible values can be any combination of KConfigObeyXXX, KConfigSendXXX, KConfigFailXXX and KConfigFreeXXX.
       
   569 	 */
       
   570 	TUint iHandshake;
       
   571 	};
       
   572 /** 
       
   573  Package buffer for a TCommNotificationV01 object.
       
   574  Packages TCommNotificationV01 within a buffer. 
       
   575  @see TCommNotificationV01
       
   576  */	
       
   577 typedef TPckgBuf<TCommNotificationV01> TCommNotificationPckg;
       
   578 //
       
   579 const TUint KDataAvailableNotifyFlag=0x80000000;
       
   580 //
       
   581 #ifdef _DEBUG_DEVCOMM
       
   582 class TCommDebugInfo
       
   583 	{
       
   584 public:
       
   585 	TBool iRxBusy;
       
   586 	TBool iRxHeld;
       
   587 	TInt iRxLength;
       
   588 	TInt iRxOffset;
       
   589 	TInt iRxIntCount;
       
   590 	TInt iRxErrCount;
       
   591 	TInt iRxBufCount;
       
   592 	TBool iTxBusy;
       
   593 	TBool iTxHeld;
       
   594 	TInt iTxLength;
       
   595 	TInt iTxOffset;
       
   596 	TInt iTxIntCount;
       
   597 	TInt iTxErrCount;
       
   598 	TInt iTxBufCount;
       
   599 	TBool iDrainingRxBuf;
       
   600 	TBool iFillingTxBuf;
       
   601 	TBool iRunningDfc;
       
   602 	TInt iDfcCount;
       
   603 	TInt iDfcReqSeq;
       
   604 	TInt iDfcHandlerSeq;
       
   605 	TInt iDoDrainSeq;
       
   606 	TBool iTxDfcPend;
       
   607 	TBool iRxDfcPend;
       
   608 	TInt iTxChars, iRxChars;
       
   609 	TInt iTxXon, iTxXoff, iRxXon, iRxXoff;
       
   610 	};
       
   611 typedef TPckgBuf<TCommDebugInfo> TCommDebugInfoPckg;
       
   612 #endif
       
   613 //
       
   614 
       
   615 /**
       
   616  The externally visible interface through which the clients can access serial devices.
       
   617  It also represents a user side handle to the serial device driver. 
       
   618  */
       
   619 class RBusDevComm : public RBusLogicalChannel
       
   620 	{
       
   621 public:
       
   622 	/**
       
   623 	 Serial device driver build version.
       
   624 	 */
       
   625 	enum TVer
       
   626 		{
       
   627 		/** Major Version */
       
   628 		EMajorVersionNumber=1,
       
   629 		/** Minor Version */
       
   630 		EMinorVersionNumber=0,
       
   631 		/** Build Version */
       
   632 		EBuildVersionNumber=KE32BuildVersionNumber
       
   633 		};
       
   634 	
       
   635 	/**
       
   636 	 Asynchronous request types
       
   637 	 */
       
   638 	enum TRequest
       
   639 		{
       
   640 		/** Read request */
       
   641 		ERequestRead=0x0,
       
   642 		/** Cancel read request */
       
   643 		ERequestReadCancel=0x1,
       
   644 		/** Write reqeust */
       
   645 		ERequestWrite=0x1,
       
   646 		/** Cancel write request */
       
   647 		ERequestWriteCancel=0x2,
       
   648 		/** Break request */
       
   649 		ERequestBreak=0x2,
       
   650 		/** Cancel break request */
       
   651 		ERequestBreakCancel=0x4,
       
   652 		/** Signal change notification request */
       
   653 		ERequestNotifySignalChange=0x3,
       
   654 		/** Cancel signal change notification request */
       
   655 		ERequestNotifySignalChangeCancel=0x8,
       
   656 		};
       
   657 		
       
   658 	/**
       
   659 	 Synchronous request types
       
   660 	 */
       
   661 	enum TControl
       
   662 		{
       
   663 		/** Get the current configuration */
       
   664 		EControlConfig,
       
   665 		/** Set the device configuration */
       
   666 		EControlSetConfig,
       
   667 		/** Get the device capabilities */
       
   668 		EControlCaps,
       
   669 		/** Read the state of Modem control signals supported */
       
   670 		EControlSignals,
       
   671 		/** Set the state of output modem control signals */
       
   672 		EControlSetSignals,
       
   673 		/** Query the driver receive buffer for data availability */
       
   674 		EControlQueryReceiveBuffer,
       
   675 		/** Reset the driver buffers */
       
   676 		EControlResetBuffers,
       
   677 		/** Get the driver receive buffer length */
       
   678 		EControlReceiveBufferLength,
       
   679 		/** Set the driver receive buffer length */
       
   680 		EControlSetReceiveBufferLength,
       
   681 		/** Get the minimum turnaround time between a receive and subsequent transmission operation */
       
   682 		EControlMinTurnaroundTime,
       
   683 		/** Set the minimum turnaround time between a receive and subsequent transmission operation */
       
   684 		EControlSetMinTurnaroundTime,
       
   685 #ifdef _DEBUG_DEVCOMM
       
   686         /** Get debug information from the driver */
       
   687 		EControlDebugInfo
       
   688 #endif
       
   689 		};
       
   690 				
       
   691 public:
       
   692 #ifndef __KERNEL_MODE__
       
   693 
       
   694 	/**
       
   695 	 This function opens a channel and creates a handle to the serial driver.
       
   696 	 @param aUnit The unit number of the serial device.
       
   697 	 @return KErrNone, if successful;
       
   698 	         otherwise one of the other system-wide error codes.
       
   699 	         KErrPermissionDenied if the port given in aName is wrong or if the request fails the CSY's own security check; 
       
   700 	         KErrNotSupported if this port is not supported by the CSY or the hardware; 
       
   701 	         KErrLocked if the port has already been opened; 
       
   702 	         KErrAccessDenied if the device driver encounteres a problem opening the hardware port.
       
   703 	 */
       
   704 	inline TInt Open(TInt aUnit);
       
   705 	
       
   706 	/**
       
   707 	 Get the version number required by the driver 
       
   708 	 @return The version number required by the driver
       
   709 	 @see TVersion
       
   710 	 */
       
   711 	inline TVersion VersionRequired() const;
       
   712 	
       
   713 	/**
       
   714 	 Read from the channel
       
   715 	 @param aStatus The asynchronous request status 
       
   716 	 @param aDes Buffer to be filled in by the driver
       
   717 	 */
       
   718 	inline void Read(TRequestStatus &aStatus,TDes8 &aDes);
       
   719 	
       
   720 	/**
       
   721 	 Read from the channel
       
   722 	 @param aStatus The asynchronous request status 
       
   723 	 @param aDes Buffer to be filled in by the driver
       
   724 	 @param aLength The length of the data to be read
       
   725 	 */
       
   726 	inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength);
       
   727 	
       
   728 	/**
       
   729 	 Read one or more characters from the channel.
       
   730 	 If there is data in the serial driver's buffer when ReadOneOrMore() is called it will 
       
   731 	 read as much data as possible (up to the maximum length of the supplied buffer) 
       
   732 	 and then return.
       
   733 	 If there is no data in the buffer the request will complete as soon as one or more bytes arrive at the serial hardware.
       
   734 	 @param aStatus The asynchronous request status 
       
   735 	 @param aDes Buffer to be filled in by the driver
       
   736 	 */
       
   737 	inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes);
       
   738 	
       
   739 	/**
       
   740 	 Cancel a pending read request
       
   741 	 */
       
   742 	inline void ReadCancel();
       
   743 	
       
   744 	/**
       
   745 	 Write to the channel
       
   746 	 @param aStatus The asynchronous request status 
       
   747 	 @param aDes Buffer containing the data to be sent
       
   748 	 */
       
   749 	inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes);
       
   750 
       
   751 	/**
       
   752 	 Write to the channel
       
   753 	 @param aStatus The asynchronous request status 
       
   754 	 @param aDes Buffer containing the data to be sent
       
   755 	 @param aLength The length of the data to be sent
       
   756 	 */        
       
   757 	inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength);
       
   758 	
       
   759 	/**
       
   760 	 Cancel a pending write request
       
   761 	 */
       
   762 	inline void WriteCancel();
       
   763 	
       
   764 	/**
       
   765 	 Causes a break condition to be transmitted to the receiving device
       
   766 	 @param aStatus The asynchronous request status
       
   767 	 @param aTime The time interval in microseconds after which the break condition will be released	
       
   768 	 */
       
   769 	inline void Break(TRequestStatus &aStatus,TInt aTime);
       
   770 	
       
   771 	/**
       
   772 	 Cancel a pending break request
       
   773 	 */
       
   774 	inline void BreakCancel();
       
   775 	
       
   776 	/**
       
   777 	 Get the current configuration of the serial device
       
   778 	 @param aConfig A packaged object to be filled with the configuration information by the driver
       
   779 	 @see TCommConfigV02
       
   780 	 */
       
   781 	inline void Config(TDes8 &aConfig);
       
   782 	
       
   783 	/**
       
   784 	 Set the cofiguration of the serial device
       
   785 	 @param aConfig A packaged object containing the configuration information
       
   786 	 @see TCommConfigV02
       
   787 	 */
       
   788 	inline TInt SetConfig(const TDesC8 &aConfig);
       
   789 	
       
   790 	/**
       
   791 	 Get the capabilities of the serial device.
       
   792 	 @param aCaps A packaged object to be filled with the capabilities of the device.
       
   793 	 @see TCommCapsV03
       
   794 	*/
       
   795 	inline void Caps(TDes8 &aCaps);
       
   796 	
       
   797 	/**
       
   798 	 Get the status of the control lines
       
   799 	 @return  A bitmask of KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG,
       
   800               KSignalRTS, KSignalDTR, KSignalBreak
       
   801 	 */
       
   802 	inline TUint Signals();
       
   803 	
       
   804 	/**
       
   805 	 Set and clear the control lines
       
   806 	 @param aSetMask    Bitmask of signals to set
       
   807 	 @param aClearMask  Bitmask of signals to clear
       
   808 	 @see Signals for a list of signals
       
   809 	 */
       
   810 	inline void SetSignals(TUint aSetMask,TUint aClearMask);
       
   811 	
       
   812 	/**
       
   813 	 Get the number of unread characters in the receive buffer of the driver
       
   814 	 @return The number of unread characters
       
   815 	 */
       
   816 	inline TInt QueryReceiveBuffer();
       
   817 	
       
   818 	/**
       
   819 	 Reset the receive and transmit buffers.
       
   820 	 */
       
   821 	inline void ResetBuffers();
       
   822 	
       
   823 	/**
       
   824 	 Get the length of the receive buffer
       
   825 	 @return The length of the receive buffer
       
   826 	 */	
       
   827 	inline TInt ReceiveBufferLength();
       
   828 	
       
   829 	/**
       
   830 	 Set the length of the receive buffer
       
   831 	 @param aLength The length of the receive buffer to be set
       
   832 	 */
       
   833 	inline TInt SetReceiveBufferLength(TInt aLength);
       
   834 		
       
   835 	/**
       
   836 	 Request notification when one of the signals change.
       
   837 	 The signals that could change are KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG,
       
   838 	 KSignalRTS, KSignalDTR, KSignalBreak.
       
   839 	 @param aStatus  The asynchronous request status
       
   840 	 @param aSignals Pointer to the bitmask containing the changed signals
       
   841 	 @param aSignalMask Bitmask of signals to be monitored
       
   842 	 */
       
   843 	inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F);
       
   844 	
       
   845 	/**
       
   846 	 Cancel a pending signal change notification request
       
   847 	 */
       
   848 	inline void NotifySignalChangeCancel();
       
   849 	
       
   850 	/**
       
   851 	 Request notification when there is data available to be read from the driver receive buffer
       
   852 	 @param aStatus The asynchronous request status
       
   853 	 */
       
   854 	inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus);
       
   855 	
       
   856 	/**
       
   857 	 Cancel a pending data notification request
       
   858 	 */
       
   859 	inline void NotifyReceiveDataAvailableCancel();
       
   860 	
       
   861 	/**
       
   862 	 Get the minimum turnaround time before a transmission can begin after a receive operation
       
   863 	 @return The turnaround time in microseconds 
       
   864 	 */
       
   865 	inline TUint MinTurnaroundTime();
       
   866 	
       
   867 	/**
       
   868 	 Set the minimum turnaround time between a receive and the next transmission operation
       
   869 	 @param aMicroSeconds The turnaround time in microseconds	               	
       
   870 	 */
       
   871 	inline TInt SetMinTurnaroundTime(TUint aMicroSeconds);
       
   872 	
       
   873 #ifdef _DEBUG_DEVCOMM
       
   874 	/**
       
   875 	 Get the debug information
       
   876 	 @param aInfo a packaged object to be filled by the driver with debug information
       
   877 	 @see TCommDebugInfo
       
   878 	 */
       
   879 	inline void DebugInfo(TDes8 &aInfo);
       
   880 #endif
       
   881 #endif
       
   882 	};
       
   883 
       
   884 class RBusDevCommDCE : public RBusLogicalChannel
       
   885 	{
       
   886 public:
       
   887 	enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
       
   888 	enum TRequest
       
   889 		{
       
   890 		ERequestRead=0x0,ERequestReadCancel=0x1,
       
   891 		ERequestWrite=0x1,ERequestWriteCancel=0x2,
       
   892 		ERequestBreak=0x2,ERequestBreakCancel=0x4,
       
   893 		ERequestNotifySignalChange=0x3,ERequestNotifySignalChangeCancel=0x8,
       
   894 		ERequestNotifyFlowControlChange=0x4,ERequestNotifyFlowControlChangeCancel=0x10,
       
   895 		ERequestNotifyConfigChange=0x5,ERequestNotifyConfigChangeCancel=0x20
       
   896 		};
       
   897 	enum TControl
       
   898 		{
       
   899 		EControlConfig,EControlSetConfig,EControlCaps,
       
   900 		EControlSignals,EControlSetSignals,
       
   901 		EControlQueryReceiveBuffer,EControlResetBuffers,
       
   902 		EControlReceiveBufferLength,EControlSetReceiveBufferLength,
       
   903 		EControlFlowControlStatus,
       
   904 #ifdef _DEBUG_DEVCOMM
       
   905 		EControlDebugInfo
       
   906 #endif
       
   907 		};
       
   908 public:
       
   909 #ifndef __KERNEL_MODE__
       
   910 	inline TInt Open(TInt aUnit);
       
   911 	inline TVersion VersionRequired() const;
       
   912 	inline void Read(TRequestStatus &aStatus,TDes8 &aDes);
       
   913 	inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength);
       
   914 	inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes);
       
   915 	inline void ReadCancel();
       
   916 	inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes);
       
   917 	inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength);
       
   918 	inline void WriteCancel();
       
   919 	inline void Break(TRequestStatus &aStatus,TInt aTime);
       
   920 	inline void BreakCancel();
       
   921 	inline void Config(TDes8 &aConfig);
       
   922 	inline TInt SetConfig(const TDesC8 &aConfig);
       
   923 	inline void Caps(TDes8 &aCaps);
       
   924 	inline TUint Signals();
       
   925 	inline void SetSignals(TUint aSetMask,TUint aClearMask);
       
   926 	inline TInt QueryReceiveBuffer();
       
   927 	inline void ResetBuffers();
       
   928 	inline TInt ReceiveBufferLength();
       
   929 	inline TInt SetReceiveBufferLength(TInt aLength);
       
   930 	inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F);
       
   931 	inline void NotifySignalChangeCancel();
       
   932 	inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus);
       
   933 	inline void NotifyReceiveDataAvailableCancel();
       
   934 	inline void NotifyFlowControlChange(TRequestStatus& aStatus);
       
   935 	inline void NotifyFlowControlChangeCancel();
       
   936 	inline void GetFlowControlStatus(TFlowControl& aFlowControl);
       
   937 	inline void NotifyConfigChange(TRequestStatus& aStatus, TDes8& aNewConfig);
       
   938 	inline void NotifyConfigChangeCancel();
       
   939 #ifdef _DEBUG_DEVCOMM
       
   940 	inline void DebugInfo(TDes8 &aInfo);
       
   941 #endif
       
   942 #endif
       
   943 	};
       
   944 
       
   945 #include <d32comm.inl>
       
   946 #endif