|
1 /* |
|
2 * Copyright (c) 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: ECOM plugin to communicate over USB serial emulation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CHTIUSBSERIALCOMMECOMPLUGIN_H |
|
20 #define CHTIUSBSERIALCOMMECOMPLUGIN_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <c32comm.h> |
|
24 #include <HTICommPluginInterface.h> // defined in HtiFramework project |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CHtiCfg; |
|
28 |
|
29 // CLASS DECLARATION |
|
30 /** |
|
31 * ECOM plugin module for communicating with PC using USB serial emulation. |
|
32 * |
|
33 */ |
|
34 class CHtiUsbSerialCommEcomPlugin : |
|
35 public CHTICommPluginInterface |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Create instance of plugin. |
|
41 * Reads configuration, opens and initializes USB port. |
|
42 * @return Plugin instance. |
|
43 */ |
|
44 static CHtiUsbSerialCommEcomPlugin* NewL(); |
|
45 |
|
46 /** |
|
47 * Destructor. |
|
48 */ |
|
49 ~CHtiUsbSerialCommEcomPlugin(); |
|
50 |
|
51 public: // Interface implementation |
|
52 |
|
53 /** |
|
54 * Receive data from USB serial port. |
|
55 * The size of supplied buffer must equal to size given |
|
56 * by GetReceiveBufferSize. |
|
57 * The number of received bytes may be anything between 1 |
|
58 * and GetReceiveBufferSize. |
|
59 * |
|
60 * @param aRawdataBuf Buffer where the result is written |
|
61 * @param aStatus Request status |
|
62 */ |
|
63 void Receive( TDes8& aRawdataBuf, TRequestStatus& aStatus ); |
|
64 |
|
65 /** |
|
66 * Send data to USB serial port. The size of data must not |
|
67 * exceed GetSendBufferSize. |
|
68 * @param aRawdataBuf Buffer where the data is read from. |
|
69 * @param aStatus Request status |
|
70 */ |
|
71 void Send( const TDesC8& aRawdataBuf, TRequestStatus& aStatus ); |
|
72 |
|
73 /** |
|
74 * Cancel read operation |
|
75 */ |
|
76 void CancelReceive(); |
|
77 |
|
78 /** |
|
79 * Cancel send operation |
|
80 */ |
|
81 void CancelSend(); |
|
82 |
|
83 /** |
|
84 * Return required buffer size for Send operation. |
|
85 */ |
|
86 TInt GetSendBufferSize(); |
|
87 |
|
88 /** |
|
89 * Return required buffer size for Receive operation. |
|
90 */ |
|
91 TInt GetReceiveBufferSize(); |
|
92 |
|
93 private: |
|
94 |
|
95 /** |
|
96 * Constructor of this plugin. |
|
97 */ |
|
98 CHtiUsbSerialCommEcomPlugin(); |
|
99 |
|
100 /** |
|
101 * Second phase construction. |
|
102 */ |
|
103 void ConstructL(); |
|
104 |
|
105 /** |
|
106 * Load needed drivers and start comm server. |
|
107 */ |
|
108 void InitCommServerL(); |
|
109 |
|
110 /** |
|
111 * Setup USB serial port. |
|
112 */ |
|
113 void InitCommPortL(); |
|
114 |
|
115 /** |
|
116 * Load configuration file. |
|
117 */ |
|
118 void LoadConfigL(); |
|
119 |
|
120 /** |
|
121 * Read and parse the configuration values. |
|
122 */ |
|
123 void ReadConfig(); |
|
124 |
|
125 /** |
|
126 * Helper to get data rate capability bitmask. |
|
127 */ |
|
128 TUint RateCapsBitmaskFromRate( TBps aDataRate ); |
|
129 |
|
130 /** |
|
131 * Show error notifier dialog with text and error code. |
|
132 */ |
|
133 void ShowErrorNotifierL( const TDesC& aText, TInt aErr ); |
|
134 |
|
135 private: // Data |
|
136 |
|
137 CHtiCfg* iCfg; |
|
138 |
|
139 // port settings |
|
140 TInt iPortNumber; |
|
141 TBps iDataRate; |
|
142 TParity iParity; |
|
143 TDataBits iDataBits; |
|
144 TStopBits iStopBits; |
|
145 |
|
146 // bitmask for handshake |
|
147 TInt iHandshake; |
|
148 |
|
149 RCommServ iCommServ; |
|
150 RComm iCommPort; |
|
151 }; |
|
152 |
|
153 #endif // CHTIUSBSERIALCOMMECOMPLUGIN_H |
|
154 |
|
155 // End of file |
|
156 |