Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 1997-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.
16 #ifndef SYMBIAN_C32_SERCOMMS_V2
17 // PLEASE NOTE: This file is part of Version 2 of C32 - that is, the multi-threaded version.
18 // The single-threaded C32 version of this file is in c32\Version1\SCOMM
19 // All defect fixes should be applied to both versions where appropriate.
20 // PLEASE NOTE: This comment is applicable to SercommsV2 but is surrounded by an "#ifndef"
21 // to enable the automatic removal of this comment once non-C32 V2 code is removed.
30 C32 header file to be included by the clients.
31 Defines the main interface to C32, RCommServ and RComm
41 IMPORT_C TInt StartC32();
42 IMPORT_C TInt StartC32WithCMISuppressions(const TDesC& aCMISuppressionList);
45 C32 major version number.
48 const TUint KEC32MajorVersionNumber = 1;
50 C32 minor version number.
53 const TUint KEC32MinorVersionNumber = 0;
55 C32 build version number.
58 const TUint KEC32BuildVersionNumber = 605;
63 const TDesC& KCommServerName(void);
65 /** Specifies the mode in which a port is opened.
67 We specify the mode when it is opened, and the mode cannot thereafter be
68 changed. If we open the port in Shared mode, other clients of the comms
69 server can use the same port while we have it open. If we open the port
70 in Exclusive mode, then it is locked for our own use and any attempt to
71 access it from another process will fail. Furthermore, our own attempt
72 to open a port in exclusive mode will fail if another process has already
73 opened the port in shared mode.
75 Infra-red ports using IRCOMM.CSY can be opened in either shared or exclusive
76 mode. However they SHOULD only be opened in Exclusive mode, since opening
77 them any other way warm-boots the computer.
84 /** Once open, the port cannot be used by any other RComm clients. An attempt to
85 open a port in exclusive mode will fail if another process has already opened
86 the port in shared mode. */
88 /** The port can be shared by other RComm clients who open in the same mode. */
90 /** Allows another client to pre-empt the session with an open request in one of
91 the other two modes. The port will be lost if other clients are trying to open it.*/
95 Use full buffering. Used by RComm::SetMode().
100 const TUint KCommBufferFull = 0x0000;
102 Use partial buffering. Used by RComm::SetMode().
107 const TUint KCommBufferPartial = 0x0001;
111 trace flags for debugging purposes
116 ETraceC32Startup = 0x00000001,
117 ETraceC32Panic = 0x00000002,
118 ETraceC32Request = 0x00000004,
119 ETraceC32IPC = 0x00000008,
120 ETraceC32All = 0xFFFFFFFF,
124 Used by the package TCommServerConfig to configure the comm port.
126 Holds the buffer configuration settings for the comms server.
128 The comms server copies data between the descriptors provided by the client
129 and the buffers used by the serial port drivers, for each read and write request.
130 There are two methods by which this can be accomplished. Full buffering means
131 that the comms server will always attempt to allocate enough memory to satisfy
132 any reads or writes in a single copy, while partial buffering means that the
133 comms server will allocate a static buffer and use partial copies to transfer
134 data to the serial driver. When a port is opened, the default is full buffering.
139 struct TCommServerConfigV01
141 /** Buffering option: either KCommBufferFull or KCommBufferPartial */
142 TUint iBufFlags; ///< contains buffer flags e.g for partial read/write
143 /** Size of server buffer if partial buffering is being used */
144 TUint iBufSize; ///< size of the Tx/Rx buffer
147 /** Package buffer for a server configuration object. TCommServerConfig is used
148 as an argument to RComm::Mode() and RComm::SetMode().
153 typedef TPckgBuf<TCommServerConfigV01> TCommServerConfig;
155 /** Maximum length of port full name, TPortDescription (48 characters).
160 const TInt KMaxPortDescription = 0x30;
161 /** Maximum length of the Port Prefix format name, as used by TPortName (16 characters).
166 const TInt KMaxPortName = 0x10;
168 /** Reset the receive buffer
173 const TUint KCommResetRx = 0x00000001; ///< to by used as flag by RComm::ResetBuffers
174 /** Reset the transmit buffer
179 const TUint KCommResetTx = 0x00000002; ///< to by used as flag by RComm::ResetBuffers
180 /** Port name. Used by TSerialInfo::iName.
185 typedef TBuf<KMaxPortName> TPortName;
186 /** Full port name/description. Used by TSerialInfo::iDescription.
191 typedef TBuf<KMaxPortDescription> TPortDescription;
195 /** Describes a serial protocol's general capabilities.
197 Used by RCommServ::GetPortInfo to retrieve information
198 about the comm ports and the CSY.
202 1. The lowest port need not necessarily be numbered zero.
204 2. At least one port is always guaranteed.
206 3. The full name of the serial port (used when opening it) consists of the name
207 returned by TSerialInfo (the Port Prefix), followed by a double colon separator, followed by
208 the unit number (port number) as an ASCII number (for instance COMM::0).
215 /** Description of the CSY meant only for human reading. It
216 can be up to KMaxPortDescription (48) characters long. */
217 TPortDescription iDescription; ///< description of the port (CSY)
218 /** The short name of the port (Port Prefix). This is used in calls to RComm::Open(). It can be up to
219 KMaxPortName (i.e. 16) characters long. */
220 TPortName iName; ///< name of the port
221 TUint iLowUnit; ///< The lowest port number supported by the serial module
222 TUint iHighUnit; ///< the highest port number supported by the serial module
226 Specifies the DTE/DCE role in which a port is opened.
234 /** Port takes on role of DTE. (DTE=computer).
238 /** Port takes on role of DCE. (DCE=modem).
246 class RCommServ : public RSessionBase
247 /** Represents a session with the serial comms server.
248 Functions are provided for connection
249 to the server and for loading and unloading different comms modules, and services
250 for finding out the name and numbers of the available ports.
252 Sessions with the serial comms server are not shareable.
254 Comms modules are also known as "CSY"s due to their ".CSY" extension,
255 derived from the term "Comms SYstem".
257 This class is not intended for user derivation.
263 IMPORT_C RCommServ();
264 IMPORT_C TInt Connect();
265 IMPORT_C TVersion Version() const;
267 IMPORT_C TInt LoadCommModule(const TDesC& aFileName);
268 IMPORT_C TInt UnloadCommModule(const TDesC& aName);
269 IMPORT_C TInt NumPorts(TInt& aNum);
270 IMPORT_C TInt GetPortInfo(const TDesC& aName, TSerialInfo& aInfo);
271 IMPORT_C TInt GetPortInfo(TInt aIndex, TDes& aModuleName, TSerialInfo& aInfo);
273 IMPORT_C TInt __DbgMarkHeap();
274 IMPORT_C TInt __DbgCheckHeap(TInt aCount);
275 IMPORT_C TInt __DbgMarkEnd(TInt aCount);
276 IMPORT_C TInt __DbgFailNext(TInt aCount);
277 IMPORT_C TInt __DbgSetTraceMask(TC32Trace aMask);
279 IMPORT_C static TInt CreateThreadInCommProc(const TDesC& aLibraryName, const TDesC& aThreadName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize);
281 static TBool IsServerThreadL();
285 struct TCommDebugInfo; // defined in d32comm.h
288 class RComm : public RSubSessionBase
289 /** A sub-session to the C32 Serial Server used for addressing a serial port.
291 All the necessary functions are provided by this class for communicating via
292 a port, including functions for opening, closing, reading, writing,
293 port configuration and capability checking. An RComm session represents
294 a single serial port and once opened cannot be altered to represent another port.
296 Ports are referenced by a character string whose format is referred to as Port Prefix format.
297 This format is also known as the CSY internal name, and the ports "short" name in older releases.
305 IMPORT_C TInt Open(RCommServ& aServer, const TDesC& aName, TCommAccess aMode);
306 IMPORT_C TInt Open(RCommServ& aServer, const TDesC& aName, TCommAccess aMode, TCommRole aRole);
307 IMPORT_C void OpenWhenAvailable(TRequestStatus& aStatus, RCommServ& aServer, const TDesC& aName);
308 IMPORT_C void OpenWhenAvailable(TRequestStatus& aStatus, RCommServ& aServer, const TDesC& aName, TCommRole aRole);
309 IMPORT_C void OpenWhenAvailableCancel();
310 IMPORT_C void Read(TRequestStatus& aStatus, TDes8& aDes);
311 IMPORT_C void Read(TRequestStatus& aStatus, TDes8& aDes, TInt aLength);
312 IMPORT_C void Read(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aTimeOut, TDes8& aDes);
313 IMPORT_C void Read(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aTimeOut, TDes8& aDes, TInt aLength);
314 IMPORT_C void ReadOneOrMore(TRequestStatus& aStatus, TDes8& aDes);
315 IMPORT_C TInt ReadCancel();
316 IMPORT_C TInt QueryReceiveBuffer() const;
317 IMPORT_C TInt ResetBuffers(TUint aFlags=(KCommResetRx|KCommResetTx));
318 IMPORT_C void Write(TRequestStatus& aStatus, const TDesC8& aDes);
319 IMPORT_C void Write(TRequestStatus& aStatus, const TDesC8& aDes, TInt aLength);
320 IMPORT_C void Write(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aTimeOut, const TDesC8& aDes);
321 IMPORT_C void Write(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aTimeOut, const TDesC8& aDes, TInt aLength);
322 IMPORT_C TInt WriteCancel();
323 IMPORT_C void Break(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aTime);
324 IMPORT_C TInt BreakCancel();
325 IMPORT_C TInt Cancel();
326 IMPORT_C TInt Config(TDes8& aConfig) const;
327 IMPORT_C TInt SetConfig(const TDesC8& aConfig);
328 IMPORT_C TInt Caps(TDes8& aCaps) const;
329 IMPORT_C TInt SetMode(const TCommServerConfig& aConfig);
330 IMPORT_C TInt Mode(TCommServerConfig& aConfig) const;
331 IMPORT_C TUint Signals(TUint aSignalMask = 0x3F) const;
332 IMPORT_C TInt SetSignalsToMark(TUint aSignalMask);
333 IMPORT_C TInt SetSignalsToSpace(TUint aSignalMask);
334 IMPORT_C TInt ReceiveBufferLength() const;
335 IMPORT_C TInt SetReceiveBufferLength(TInt aLength);
336 IMPORT_C void Close();
337 inline void SetSignals(TUint aSetMask, TUint aClearMask);
338 IMPORT_C void NotifySignalChange(TRequestStatus& aStatus, TUint& aSignals, TUint aSignalMask=0x3F);
339 IMPORT_C TInt NotifySignalChangeCancel() const;
340 IMPORT_C void NotifyConfigChange(TRequestStatus& aStatus, TDes8& aNewConfig) const;
341 IMPORT_C TInt NotifyConfigChangeCancel() const;
342 IMPORT_C void NotifyFlowControlChange(TRequestStatus& aStatus, TFlowControl& aFlowControl);
343 IMPORT_C TInt NotifyFlowControlChangeCancel() const;
344 IMPORT_C void NotifyBreak(TRequestStatus& aStatus) const;
345 IMPORT_C TInt NotifyBreakCancel() const;
346 IMPORT_C void NotifyDataAvailable(TRequestStatus& aStatus) const;
347 IMPORT_C TInt NotifyDataAvailableCancel() const;
348 IMPORT_C void NotifyOutputEmpty(TRequestStatus& aStatus) const;
349 IMPORT_C TInt NotifyOutputEmptyCancel() const;
350 IMPORT_C TInt GetFlowControlStatus(TFlowControl& aFlowControl) const;
351 IMPORT_C TInt GetRole(TCommRole& aRole) const;
353 IMPORT_C TInt SetAccessMode(TCommAccess aNewMode);
354 IMPORT_C TInt DebugState(TCommDebugInfo&);
356 #ifdef _DEBUG_DEVCOMM
357 IMPORT_C TInt RComm::DebugInfo(TDes8& aDes);
360 TPtr8 iSignalsNotification; ///< pointer to the signals to be changed during notification
361 TPtr8 iFlowNotification; ///< pointer to the flow control to be changed during notification
364 #include <c32comm.inl>