24
|
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 |
// Serial IO Functions
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalAll
|
|
21 |
*/
|
|
22 |
|
|
23 |
|
|
24 |
#ifndef __ATIO_H__
|
|
25 |
#define __ATIO_H__
|
|
26 |
|
|
27 |
#include "SCOMM.H"
|
|
28 |
#include "ATBASE.H"
|
|
29 |
/**
|
|
30 |
@internalComponent
|
|
31 |
*/
|
|
32 |
const TInt KKeyReaderPriority = 0;
|
|
33 |
const TInt KChatterPriority = 0;
|
|
34 |
const TInt KChatTimeout = 3000000;
|
|
35 |
const TInt KCommRxBufSize = 200;
|
|
36 |
const TInt KCommTimeout = 10000000;
|
|
37 |
const TInt KCommReadPriority = 10;
|
|
38 |
const TInt KCommWritePriority = 20;
|
|
39 |
const TInt KCommTimerPriority = 5;
|
|
40 |
/**
|
|
41 |
@internalComponent
|
|
42 |
*/
|
|
43 |
const TInt KReadTimeOutSec=60;
|
|
44 |
const TInt KWriteTimeOutSec=10;
|
|
45 |
const TInt KInitialisationTimeOut=20;
|
|
46 |
const TInt KDefaultTimeOutMillisec=5000;
|
|
47 |
|
|
48 |
class CATIO;
|
|
49 |
class CATBase;
|
|
50 |
class CCompletionEntry : public CBase
|
|
51 |
/**
|
|
52 |
@internalComponent
|
|
53 |
*/
|
|
54 |
{
|
|
55 |
public:
|
|
56 |
static CCompletionEntry* NewL(CCommChatString* aCs, CATBase* aAtCommand);
|
|
57 |
CCompletionEntry(CCommChatString* aCs, CATBase* aAtCommand);
|
|
58 |
~CCompletionEntry();
|
|
59 |
private:
|
|
60 |
CCommChatString* iCs;
|
|
61 |
CATBase* iAtCommand;
|
|
62 |
TDblQueLink iLink;
|
|
63 |
friend class CATIO;
|
|
64 |
};
|
|
65 |
|
|
66 |
class CATErrorHandler;
|
|
67 |
class CATBase;
|
|
68 |
class CATIO : public CBase, public MComm, public MCommChatNotify
|
|
69 |
/**
|
|
70 |
@internalComponent
|
|
71 |
*/
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
static CATIO* NewL(TFileName& csy, TName& port,TPortAccess& aPortAccess);
|
|
75 |
CATIO(TPortAccess& aPortAccess);
|
|
76 |
void ConstructL(TFileName& csy, TName& port);
|
|
77 |
~CATIO();
|
|
78 |
TInt ConfigurePort(TCommConfig aConfiguration);
|
|
79 |
void Start(CATBase* aCompletionClass);
|
|
80 |
void StartWrite(CATBase* aCompletionClass);
|
|
81 |
CCommChatString* AddExpectString(CATBase* aATBase, const TDesC8& aString, TBool aPartLine=EFalse);
|
|
82 |
CCommChatString* DoAddExpectStringL(CATBase* aATBase, const TDesC8& aString, TBool aPartLine=EFalse);
|
|
83 |
void RemoveExpectStrings(CATBase* aATBase);
|
|
84 |
void RemoveExpectString(CCommChatString* aExpectString);
|
|
85 |
void SignalCommandsWithError(TInt aStatus);
|
|
86 |
void Read();
|
|
87 |
void Write(CATBase* aWriteCommand, const TDesC8& aString);
|
|
88 |
TBool ReadPending();
|
|
89 |
TInt BufferFindF(const TDesC8& aDes) const;
|
|
90 |
TPtrC8 Buffer() const;
|
|
91 |
TPtrC8 CurrentLine() const;
|
|
92 |
void ClearBuffer();
|
|
93 |
void ClearCurrentLine();
|
|
94 |
void Disconnect();
|
|
95 |
void Cancel();
|
|
96 |
void ReadCancel();
|
|
97 |
void WriteAndTimerCancel(CATBase* aATBase);
|
|
98 |
CCommChatString* FoundChatString();
|
|
99 |
|
|
100 |
void SetTimeOut(CATBase* aCompletionClass, TUint aTimePeriodSec=KDefaultTimeOutMillisec);
|
|
101 |
void DropDtr();
|
|
102 |
void RaiseDTR();
|
|
103 |
void DropRTS();
|
|
104 |
void RaiseRTS();
|
|
105 |
void ResetReadAndWriteBuffers();
|
|
106 |
TInt GetSizeOfRxBuffer();
|
|
107 |
void ProcessReadCharsL();
|
|
108 |
void SetErrorHandler(CATErrorHandler* aErrorHandler) {iErrorHandler = aErrorHandler;}
|
|
109 |
void SetPreserveBufferFlag(TBool aFlg);
|
|
110 |
TUint Signals();
|
|
111 |
// from MComm
|
|
112 |
virtual void CommReadComplete(TInt aStatus);
|
|
113 |
virtual void CommWriteComplete(TInt aStatus);
|
|
114 |
// from MCommChatNotify
|
|
115 |
virtual void ChatStringMatchL(CCommChatString* aCs);
|
|
116 |
virtual void ChatTimeout();
|
|
117 |
TFileName iCsy;
|
|
118 |
private:
|
|
119 |
TInt GetPortShutdownTimeout();
|
|
120 |
TInt SetPortShutdownTimeout(TInt aTimeout);
|
|
121 |
CATBase* iTimeOutCommand;
|
|
122 |
CATBase* iWriteCommand;
|
|
123 |
CATErrorHandler* iErrorHandler;
|
|
124 |
CCommChatter* iChat;
|
|
125 |
TInt iRxBufOffset;
|
|
126 |
TBuf8<KCommRxBufSize> iRxBuf;
|
|
127 |
TBool iReadPending;
|
|
128 |
TBool iWritePending;
|
|
129 |
TBool iWaitTimerPending;
|
|
130 |
TBool iInitPending;
|
|
131 |
TBool iStringFound;
|
|
132 |
CArrayFixFlat<CCommChatString*>* iChatStringFound;
|
|
133 |
CCommChatString* iCurrentFoundChatString;
|
|
134 |
TDblQue<CCompletionEntry> iExpectList;
|
|
135 |
TPortAccess& iPortAccess;
|
|
136 |
TInt iSecondChanceForCommsError;
|
|
137 |
TBool iPreserveBuffer;
|
|
138 |
};
|
|
139 |
|
|
140 |
#endif
|