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 |
* Serial Transport
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef __SERIAL_H__
|
|
22 |
#define __SERIAL_H__
|
|
23 |
|
|
24 |
/********************************************************************************
|
|
25 |
*
|
|
26 |
* System Includes
|
|
27 |
*
|
|
28 |
*******************************************************************************/
|
|
29 |
#include <c32comm.h>
|
|
30 |
#include <f32file.h>
|
|
31 |
|
|
32 |
#include "MUCCTransport.h"
|
|
33 |
|
|
34 |
/********************************************************************************
|
|
35 |
*
|
|
36 |
* Definitions
|
|
37 |
*
|
|
38 |
*******************************************************************************/
|
|
39 |
#define KMaxPacketSize 64
|
|
40 |
#define KModuleSize 8
|
|
41 |
#define KReadTimeout 30000000
|
|
42 |
|
|
43 |
const char OPT_DELIMITER = '|';
|
|
44 |
|
|
45 |
#ifndef _TCOMMSTATUS
|
|
46 |
#define _TCOMMSTATUS
|
|
47 |
enum TCommStatus {
|
|
48 |
EIdle,
|
|
49 |
EInitialising,
|
|
50 |
EInitialised,
|
|
51 |
EConnecting,
|
|
52 |
EConnected,
|
|
53 |
EDisconnecting,
|
|
54 |
EDisconnected,
|
|
55 |
EReleasing,
|
|
56 |
ESendPending,
|
|
57 |
EReceivePending,
|
|
58 |
ELast
|
|
59 |
};
|
|
60 |
#endif
|
|
61 |
|
|
62 |
/********************************************************************************
|
|
63 |
*
|
|
64 |
* Class
|
|
65 |
*
|
|
66 |
*******************************************************************************/
|
|
67 |
class CSerialTransport : public MUCCTransport
|
|
68 |
{
|
|
69 |
public:
|
|
70 |
CSerialTransport();
|
|
71 |
static CSerialTransport* NewL( TPtrC16 aModule );
|
|
72 |
virtual ~CSerialTransport();
|
|
73 |
|
|
74 |
TInt InitialiseL();
|
|
75 |
TInt ConnectL( TDesC *aRemoteHost );
|
|
76 |
TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
|
|
77 |
TInt RequestReceive( TPtr8 *aRecvBufferPtr, TUint aByteCount );
|
|
78 |
TInt Disconnect( void );
|
|
79 |
TInt Release( void );
|
|
80 |
TText8 *Error( void );
|
|
81 |
|
|
82 |
private:
|
|
83 |
void ConstructL( TPtrC16 aModule );
|
|
84 |
void SetStatus( TCommStatus aNewStatus );
|
|
85 |
void ExtractOptions( TDesC *aRemoteHost, TInt& aPortNumber, TInt& aBaudCap, TBps& aBaudRate );
|
|
86 |
|
|
87 |
private:
|
|
88 |
enum TReadWriteStatus { ENoRW, EWritePending, EReadPending };
|
|
89 |
|
|
90 |
private:
|
|
91 |
TCommStatus iSerialStatus;
|
|
92 |
TBuf16<KModuleSize> iModule;
|
|
93 |
TInt iRetries;
|
|
94 |
|
|
95 |
RCommServ iCommServer;
|
|
96 |
RComm iCommPort;
|
|
97 |
TCommConfig iPortSettings, iOldPortSettings;
|
|
98 |
|
|
99 |
TInt iCommPortOpen, iCommOldSettingsValid;
|
|
100 |
TRequestStatus iStatus;
|
|
101 |
};
|
|
102 |
|
|
103 |
#endif
|