|
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 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __SERIAL_DRIVER_H |
|
26 #define __SERIAL_DRIVER_H |
|
27 |
|
28 #define MAX_PORTS 10 // randomly high value... |
|
29 |
|
30 #include <e32std.h> |
|
31 #include <e32cmn.h> |
|
32 |
|
33 class RSerialPort; // actually defined within the implementation |
|
34 |
|
35 |
|
36 class CSerialServer |
|
37 { |
|
38 |
|
39 friend class CSerialPort; // declare CSerialPort our friemd |
|
40 |
|
41 public: |
|
42 CSerialServer(); |
|
43 virtual ~CSerialServer(); |
|
44 |
|
45 TBool Open(void); |
|
46 TBool Close(void); |
|
47 |
|
48 private: |
|
49 |
|
50 // These next methods are for friends and not intended |
|
51 // as part of the truely public interface. |
|
52 RSerialPort * GetPort(TUint aPortNum); |
|
53 RSerialPort * InitialisePort(TUint aPortNum); |
|
54 TBool ClosePort(TUint aPortNum); |
|
55 |
|
56 // member variables |
|
57 |
|
58 TInt m_errPhysicalLoad; |
|
59 TInt m_errLogicalLoad; |
|
60 |
|
61 RSerialPort * portsInUse[MAX_PORTS]; // array for holding set of port info |
|
62 }; |
|
63 |
|
64 |
|
65 class CSerialPort |
|
66 { |
|
67 public: |
|
68 CSerialPort(); |
|
69 virtual ~CSerialPort(); |
|
70 |
|
71 TBool Open(CSerialServer & aServer, TUint aPort); |
|
72 TBool Close(void); |
|
73 |
|
74 TBool Read(TRequestStatus & aStatus, |
|
75 TTimeIntervalMicroSeconds32 aTimeout, |
|
76 TDes8 &aDes, |
|
77 TInt aLength); |
|
78 |
|
79 TBool Write(TRequestStatus & aStatus, |
|
80 TTimeIntervalMicroSeconds32 aTimeout, |
|
81 const TDesC8 &aDes, |
|
82 TInt aLength); |
|
83 |
|
84 TInt SetConfig(const TCommConfig & aRequiredConfig); |
|
85 |
|
86 TBool GetPortConfig(TCommConfig & aPortSettings); |
|
87 |
|
88 TBool ReadCancel(void); |
|
89 |
|
90 TBool WriteCancel(void); |
|
91 |
|
92 TBool SetReceiveBufferLength(TInt aSize); |
|
93 |
|
94 TBool ReceiveBufferLength(TInt & aSize); |
|
95 |
|
96 public: |
|
97 |
|
98 //functions |
|
99 RSerialPort * GivePortDetails(void); |
|
100 |
|
101 // Member variables |
|
102 CSerialServer * m_pOurServer; |
|
103 |
|
104 TUint m_portId; |
|
105 |
|
106 }; |
|
107 |
|
108 #endif |