|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef __SIO_H |
|
22 #define __SIO_H |
|
23 |
|
24 #include "Te_LoopBackSCHAT.H" |
|
25 #include "Te_LoopBackSCOMM.H" |
|
26 #include "Te_LoopBackATSTD.H" // for enum TPortAccess |
|
27 |
|
28 const TInt KKeyReaderPriority = 0; |
|
29 const TInt KChatterPriority = 0; |
|
30 const TInt KChatTimeout = 3000000; |
|
31 const TInt KCommRxBufSize = 800; |
|
32 const TInt KCommTimeout = 10000000; |
|
33 const TInt KCommReadPriority = 10; |
|
34 const TInt KCommWritePriority = 20; |
|
35 const TInt KCommTimerPriority = 5; |
|
36 |
|
37 const TInt KReadTimeOutSec=60; |
|
38 const TInt KWriteTimeOutSec=10; |
|
39 const TInt KInitialisationTimeOut=20; |
|
40 const TInt KDefaultTimeOutMillisec=5000; |
|
41 |
|
42 class CATIO; |
|
43 class CATBase; |
|
44 |
|
45 /** |
|
46 * This class inherits from CBase and is used by the test harness to manage the expect |
|
47 * strings. Every expect (or chat) string is associated with a completion entry. There |
|
48 * is a list of expected strings managed by the test harness code. When a string comes |
|
49 * in from the TSY, this class is used (as the data container) for matching the expected |
|
50 * strings and the input from the TSY. |
|
51 */ |
|
52 class CCompletionEntry : public CBase |
|
53 { |
|
54 public: |
|
55 static CCompletionEntry* NewL(CCommChatString* aCs, CATBase* aAtCommand); |
|
56 CCompletionEntry(CCommChatString* aCs, CATBase* aAtCommand); |
|
57 ~CCompletionEntry(); |
|
58 private: |
|
59 CCommChatString* iCs; //< Pointer to the chat string (expected string) for this |
|
60 //< completion entry. |
|
61 CATBase* iAtCommand; //< Pointer to the CATBase object associated with this |
|
62 //< completion entry. Used for various tasks such as |
|
63 //< event signalling, removing of expected strings, etc. |
|
64 TDblQueLink iLink; //< Element of Doubly linked list |
|
65 friend class CATIO; |
|
66 }; |
|
67 |
|
68 class CATErrorHandler; |
|
69 class CATBase; |
|
70 /** |
|
71 * This class inherits from CBase, MComm, and MCommChatNotify. |
|
72 * It represents the basic IO mechanism for the regression test harness. |
|
73 * This class handles the receive buffer from the GSM TSY and the expect |
|
74 * strings (reading and writing). |
|
75 */ |
|
76 class CATIO : public CBase, public MComm, public MCommChatNotify |
|
77 { |
|
78 public: |
|
79 static CATIO* NewL(const TDesC& aCsy, const TDesC& aPort); |
|
80 CATIO(); |
|
81 void ConstructL(const TDesC& aCsy, const TDesC& aPort); |
|
82 ~CATIO(); |
|
83 TInt ConfigurePort(TCommConfig aConfiguration); |
|
84 TInt Start(CATBase* aCompletionClass); |
|
85 CCommChatString* AddExpectString(CATBase* aATBase, const TDesC8& aString); |
|
86 void RemoveExpectStrings(CATBase* aATBase); |
|
87 void RemoveExpectString(CCommChatString* aExpectString); |
|
88 void SignalCommandsWithError(TInt aStatus); |
|
89 TInt Read(); |
|
90 TInt Write(CATBase* aWriteCommand, const TDesC8& aString); |
|
91 TBool RWPending(); |
|
92 TBool ReadPending(); |
|
93 void GetExcessData(TDes8& aBuffer); |
|
94 void MarkRxBuffer(TInputBufferMark& aBufferMarker); |
|
95 TPtrC8 GetRxBufferLC(TInputBufferMark& aBufferMarker); |
|
96 void Disconnect(); |
|
97 void Cancel(); |
|
98 void WriteAndTimerCancel(CATBase* aATBase); |
|
99 void WriteAndTimerCancelAll(); |
|
100 CCommChatString* FoundChatString(); |
|
101 |
|
102 void SetTimeOut(CATBase* aCompletionClass, TUint aTimePeriodSec=KDefaultTimeOutMillisec); |
|
103 void DropDtr(); |
|
104 void RaiseDTR(); |
|
105 void DropRTS(); |
|
106 void RaiseRTS(); |
|
107 void ResetReadAndWriteBuffers(); |
|
108 TInt GetSizeOfRxBuffer(); |
|
109 void ProcessReadCharsL(); |
|
110 void SetErrorHandler(CATErrorHandler* aErrorHandler) {iErrorHandler = aErrorHandler;} |
|
111 TUint Signals(); |
|
112 void SignalMark(TUint aSignal); |
|
113 void SignalSpace(TUint aSignal); |
|
114 |
|
115 // from MComm |
|
116 virtual void CommReadComplete(TInt aStatus); |
|
117 virtual void CommWriteComplete(TInt aStatus); |
|
118 // from MCommChatNotify |
|
119 virtual void ChatStringMatchL(CCommChatString* aCs); |
|
120 virtual void ChatTimeout(); |
|
121 private: |
|
122 CATBase* iControllingClass; //< Pointer to the controlling CATBase entity for read |
|
123 //< completions. |
|
124 CATBase* iTimeOutCommand; //< Pointer to the controlling CATBase entity for timeout |
|
125 //< completions. |
|
126 CATBase* iWriteCommand; //< Pointer to the controlling CATBase entity for write |
|
127 //< completions. |
|
128 CATErrorHandler* iErrorHandler; //< Ptr to error handler, not apparently used by test harness. |
|
129 CCommChatter* iChat; //< Pointer to the CComChatter object which is associated |
|
130 //< with this IO class and iRxBuf. |
|
131 TInt iRxBufOffset; //< Offset in iRxBuf where received data is to be placed. |
|
132 TBuf8<KCommRxBufSize> iRxBuf; //< The buffer which contains commands/data received from |
|
133 //< the GSM TSY. |
|
134 TBool iReadPending; //< True if a read is pending; false otherwise |
|
135 TBool iWritePending; //< True if a write is pending; false otherwise |
|
136 TBool iWaitTimerPending; //< Boolean used for noting an outstanding timer on a chat string. |
|
137 TBool iInitPending; //< Not currently used in Regression Test Harness |
|
138 TBool iStringFound; //< True if a matching string is found, set to false when |
|
139 //< a read is pended. |
|
140 CArrayFixFlat<CCommChatString*>* iChatStringFound; //< Array of ptrs to chat strings that have been |
|
141 //< matched. |
|
142 CCommChatString* iCurrentFoundChatString; //< Pointer to the chat string that has currently |
|
143 //< been matched. |
|
144 TDblQue<CCompletionEntry> iExpectList; //< Queue of expected strings (in CCompletionEntry) |
|
145 TInt iSecondChanceForCommsError; //< Counter of number of comms errors. One comm error |
|
146 //< can be retried during this test. |
|
147 }; |
|
148 |
|
149 #endif |