0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/********************************************************************************
|
|
21 |
*
|
|
22 |
* Stat Serial Transport
|
|
23 |
*
|
|
24 |
*******************************************************************************/
|
|
25 |
#ifndef __STATSERIAL_H__
|
|
26 |
#define __STATSERIAL_H__
|
|
27 |
|
|
28 |
/********************************************************************************
|
|
29 |
*
|
|
30 |
* System Includes
|
|
31 |
*
|
|
32 |
*******************************************************************************/
|
|
33 |
|
|
34 |
#ifndef LIGHT_MODE
|
|
35 |
#include <c32comm.h>
|
|
36 |
#else // ifndef LIGHT_MODE
|
|
37 |
#include <serialdriverext.h>
|
|
38 |
#endif // ifndef LIGHT_MODE
|
|
39 |
|
|
40 |
#include <f32file.h>
|
|
41 |
|
|
42 |
/********************************************************************************
|
|
43 |
*
|
|
44 |
* Local Includes
|
|
45 |
*
|
|
46 |
*******************************************************************************/
|
|
47 |
#include "filedump.h"
|
|
48 |
#include "stat_interfaces.h"
|
|
49 |
|
|
50 |
/********************************************************************************
|
|
51 |
*
|
|
52 |
* Definitions
|
|
53 |
*
|
|
54 |
*******************************************************************************/
|
|
55 |
#define KModuleSize 8
|
|
56 |
|
|
57 |
/********************************************************************************
|
|
58 |
*
|
|
59 |
* Class
|
|
60 |
*
|
|
61 |
*******************************************************************************/
|
|
62 |
class CStatApiSerial : public CActive, public MStatNetwork
|
|
63 |
{
|
|
64 |
public:
|
|
65 |
// construction
|
|
66 |
static CStatApiSerial* NewL( TPtrC16 aModule );
|
|
67 |
CStatApiSerial();
|
|
68 |
~CStatApiSerial();
|
|
69 |
|
|
70 |
// from MStatNetwork
|
|
71 |
TInt GetPacketSize();
|
|
72 |
TInt InitialiseL( MNotifyStatTransport *iTransport );
|
|
73 |
TInt ConnectL( TDesC *aRemoteHost );
|
|
74 |
TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
|
|
75 |
TInt RequestReceive( TUint aByteCount );
|
|
76 |
TInt Disconnect( void );
|
|
77 |
TInt Release( void );
|
|
78 |
TText8 *Error( void );
|
|
79 |
TUint NtoHl( TUint aValue ) const;
|
|
80 |
TUint HtoNl( TUint aValue ) const;
|
|
81 |
|
|
82 |
// from CActive
|
|
83 |
void RunL( void );
|
|
84 |
void DoCancel( void );
|
|
85 |
|
|
86 |
public:
|
|
87 |
// Enumeration of different serial sub-types.
|
|
88 |
// There is an option of using serial sub-classes but the number of
|
|
89 |
// classes (three plus a base serial) is too great for the
|
|
90 |
// very small number of special case changes we need.
|
|
91 |
// Leave the serial implementation as one class and continue
|
|
92 |
// to handle special cases. This ensure all the code we
|
|
93 |
// need continues to be in one place.
|
|
94 |
enum TSerialSubtype {
|
|
95 |
EInvalid = 0,
|
|
96 |
ESerialCable,
|
|
97 |
EInfraRed,
|
|
98 |
ENumberOfSubTypes
|
|
99 |
};
|
|
100 |
|
|
101 |
private:
|
|
102 |
void ConstructL( TPtrC16 aModule );
|
|
103 |
|
|
104 |
void SetStatus( TCommStatus aNewStatus );
|
|
105 |
void ExtractOptions( TDesC *aRemoteHost, TDes& aPortNumber, TInt& aBaudCap, TBps& aBaudRate );
|
|
106 |
|
|
107 |
// Finalise the initialisation started by a call to InitialiseL.
|
|
108 |
// Called directly by InitialiseL in a synchronous
|
|
109 |
// initialisation; called from RunL in an asynchronous
|
|
110 |
// initialisation (such as USB).
|
|
111 |
TInt OnInitialiseL(TInt resultCode);
|
|
112 |
|
|
113 |
// Uses our iModule transport description text string to
|
|
114 |
// determine the sub-type. This will leave if we
|
|
115 |
// are pass an unrecognised string in the constructor.
|
|
116 |
// The leave value will be KErrNotSupported.
|
|
117 |
void DetermineSubTypeL(void);
|
|
118 |
|
|
119 |
// Returns the sub-type that identifies the nature of
|
|
120 |
// our transport special case.
|
|
121 |
TSerialSubtype SubType(void) const;
|
|
122 |
|
|
123 |
private:
|
|
124 |
TCommStatus iSerialStatus;
|
|
125 |
TReadWriteStatus iRWStatus;
|
|
126 |
TBuf16<KModuleSize> iModule;
|
|
127 |
MNotifyStatTransport *iTransport;
|
|
128 |
TBuf8<1> iDummyBuffer;
|
|
129 |
TInt iRetries;
|
|
130 |
// Store the packetsize.
|
|
131 |
// This depends upon our specific serial subtype.
|
|
132 |
TInt iMaxPacketSize;
|
|
133 |
|
|
134 |
#ifndef LIGHT_MODE
|
|
135 |
RCommServ iCommServer;
|
|
136 |
RComm iCommPort;
|
|
137 |
#else // ifndef LIGHT_MODE
|
|
138 |
SerialServer iCommServer;
|
|
139 |
SerialPort iCommPort;
|
|
140 |
|
|
141 |
RLibrary serialDriverLib; // use for loading the serial driver lib
|
|
142 |
|
|
143 |
#endif // ifndef LIGHT_MODE
|
|
144 |
|
|
145 |
TCommConfig iPortSettings, iOldPortSettings;
|
|
146 |
|
|
147 |
HBufC8 *iRecvBuffer;
|
|
148 |
TPtr8 *iRecvBufferPtr;
|
|
149 |
TInt iRecvLength, iCommOldSettingsValid;
|
|
150 |
|
|
151 |
// This is the sub-type that identifies the nature of
|
|
152 |
// our transport special case.
|
|
153 |
TSerialSubtype iSubType;
|
|
154 |
};
|
|
155 |
|
|
156 |
inline TUint CStatApiSerial::NtoHl( TUint aValue ) const
|
|
157 |
{
|
|
158 |
return ( aValue );
|
|
159 |
}
|
|
160 |
|
|
161 |
inline TUint CStatApiSerial::HtoNl( TUint aValue ) const
|
|
162 |
{
|
|
163 |
return ( aValue );
|
|
164 |
}
|
|
165 |
|
|
166 |
inline CStatApiSerial::TSerialSubtype CStatApiSerial::SubType(void) const
|
|
167 |
{
|
|
168 |
return (iSubType);
|
|
169 |
}
|
|
170 |
|
|
171 |
#endif
|