|
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 "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 // This file contains the class definition used by the Modem emulation portion of the Etel |
|
15 // regression test harness code to interface ports to the communications server. Classes |
|
16 // MComm, CCommReader, and CCommWriter are defined here. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 #ifndef _MCOMM_H_ |
|
25 #define _MCOMM_H_ |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <e32base.h> |
|
29 #include <c32comm.h> |
|
30 |
|
31 class CCommWriter; |
|
32 class CCommReader; |
|
33 |
|
34 /** |
|
35 * This class abstracts the port portion of the regression test harness. It uses the |
|
36 * communications server and serial port definitions. Though this class starts with |
|
37 * an M prefix, it is NOT a mixin class, as it contains member data and has substansial |
|
38 * method functions. |
|
39 */ |
|
40 class MComm |
|
41 { |
|
42 protected: |
|
43 MComm(); |
|
44 virtual ~MComm(); |
|
45 void CommConstructL(TInt aReadPriority, TInt aWritePriority); |
|
46 TInt CommOpen(const TDesC& aName, TCommAccess aAccess); |
|
47 TInt CommOpen(const TDesC& aDll, const TDesC& aName, TCommAccess aAccess); |
|
48 void CommClose(); |
|
49 void CommCancel(); |
|
50 void CommWrite(const TDesC8& aDes); |
|
51 void CommWriteReady(); |
|
52 void CommWriteCancel(); |
|
53 void CommRead(TDes8& aDes); |
|
54 void CommReadOneOrMore(TDes8& aDes); |
|
55 void CommReadReady(); |
|
56 void CommReadCancel(); |
|
57 // Invoked by the RunL of the CCommReader active object for Read completion |
|
58 virtual void CommReadComplete(TInt aStatus)=0; |
|
59 // Invoked by the RunL of the CCommWriter active object for Write completion |
|
60 virtual void CommWriteComplete(TInt aStatus)=0; |
|
61 protected: |
|
62 friend class CCommWriter; |
|
63 friend class CCommReader; |
|
64 RCommServ iCommServer; //< Handle for the Communications Server |
|
65 RComm iCommPort; //< Handle for a Serial Port |
|
66 CCommReader* iCommReader; //< Pointer to the Comm Reader associated with this xxxx |
|
67 CCommWriter* iCommWriter; //< Pointer to the Comm Writer associated with this xxxx |
|
68 TBuf8<1> iBuf; //< A single byte buffer used during intialization read |
|
69 }; |
|
70 |
|
71 /** |
|
72 * A CActive object that is used for reading data from the ports in the regression test harness. |
|
73 */ |
|
74 class CCommReader : public CActive |
|
75 { |
|
76 public: |
|
77 CCommReader(MComm* aComm, TInt aPriority); |
|
78 virtual ~CCommReader(); |
|
79 inline void Activate() { SetActive(); } |
|
80 inline TRequestStatus& StatusRef() { return iStatus; } |
|
81 protected: |
|
82 virtual void RunL(); |
|
83 virtual void DoCancel(); |
|
84 private: |
|
85 MComm *iComm; //< Pointer to the MComm class associated with this reader. |
|
86 }; |
|
87 |
|
88 /** |
|
89 * A CActive object that is used for writing data from the ports in the regression test harness. |
|
90 */ |
|
91 class CCommWriter : public CActive |
|
92 { |
|
93 public: |
|
94 CCommWriter(MComm* aComm, TInt aPriority); |
|
95 virtual ~CCommWriter(); |
|
96 inline void Activate() { SetActive(); } |
|
97 inline TRequestStatus& StatusRef() { return iStatus; } |
|
98 protected: |
|
99 virtual void RunL(); |
|
100 virtual void DoCancel(); |
|
101 private: |
|
102 MComm *iComm; //< Pointer to the MComm class associated with this writer. |
|
103 }; |
|
104 |
|
105 #endif |