|
1 #ifndef __ENDPOINT_WRITER_H |
|
2 #define __ENDPOINT_WRITER_H |
|
3 |
|
4 /* |
|
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 * All rights reserved. |
|
7 * This component and the accompanying materials are made available |
|
8 * under the terms of the License "Eclipse Public License v1.0" |
|
9 * which accompanies this distribution, and is available |
|
10 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 * |
|
12 * Initial Contributors: |
|
13 * Nokia Corporation - initial contribution. |
|
14 * |
|
15 * Contributors: |
|
16 * |
|
17 * Description: |
|
18 * @file endpointwriter.h |
|
19 * @internalComponent |
|
20 * |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 #include <d32usbc.h> |
|
27 |
|
28 namespace NUnitTesting_USBDI |
|
29 { |
|
30 |
|
31 /** |
|
32 This class describes a generic writer of data to host endpoints |
|
33 */ |
|
34 class CEndpointWriter : public CActive |
|
35 { |
|
36 public: |
|
37 /** |
|
38 Constructor, build an endpoint writer |
|
39 @param aClientDriver a referrence to a channel to the client USB driver |
|
40 @param aEndpoint the endpoint number to write to |
|
41 */ |
|
42 CEndpointWriter(RDevUsbcClient& aClientDriver,TEndpointNumber aEndpoint); |
|
43 |
|
44 /** |
|
45 Destructor |
|
46 */ |
|
47 virtual ~CEndpointWriter(); |
|
48 |
|
49 /** |
|
50 Get numebr of bytes writtenat an instant in time if doing a multiple asynchronous 'Write' |
|
51 */ |
|
52 TUint NumBytesWrittenSoFar(); |
|
53 |
|
54 /** |
|
55 Write the supplied data to through the endpoint to the host |
|
56 @param aData the byte data to write to the host |
|
57 @param aUseZLP send a zero length packet if appropriate |
|
58 @param aCreateBuffer reallocate this object's 'iBuffer' and copy the data into it (required for aData is transient) |
|
59 */ |
|
60 void Write(const TDesC8& aData, TBool aUseZLP, TBool aCreateBuffer = ETrue); |
|
61 |
|
62 /** |
|
63 Write the supplied data to through the endpoint to the host and wait for completion |
|
64 @param aData the byte data to write to the host |
|
65 @return error |
|
66 */ |
|
67 TInt WriteSynchronous(const TDesC8& aData, TBool aUseZLP); |
|
68 |
|
69 /** |
|
70 Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host |
|
71 @param aDataPattern the byte data pattern to use when writing to the host |
|
72 @param aNumBytes the number of bytes to write to the host |
|
73 @param aUseZLP use a zero lengt packet if last write packet conatins max packet's worth of data |
|
74 */ |
|
75 void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytesconst, TBool aUseZLP); |
|
76 |
|
77 /** |
|
78 Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host |
|
79 and wait for completion. |
|
80 @param aDataPattern the byte data pattern to use when writing to the host |
|
81 @param aNumBytes the number of bytes to write to the host |
|
82 */ |
|
83 void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytes); |
|
84 |
|
85 /** |
|
86 Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host, |
|
87 and then halt the endpoint. |
|
88 @param aDataPattern the byte data pattern to use when writing to the host |
|
89 @param aNumBytes the number of bytes to write to the host |
|
90 */ |
|
91 void WriteSynchronousUsingPatternAndHaltL(const TDesC8& aDataPattern, const TUint aNumBytes); |
|
92 |
|
93 /** |
|
94 Kick off a 'Write' of 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host. |
|
95 @param aData the byte data to write to the host |
|
96 @param aNumRepeats the number of times to repeat in the buffer to be used when sending |
|
97 */ |
|
98 void WriteUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP); |
|
99 |
|
100 /** |
|
101 Kick off a sequence of 'Writes' which in total will write 'aNumBytes' bytes of data using 'aDataPattern' |
|
102 through the endpoint to the host. |
|
103 @param aNumBytesPerWrite the number of bytes of data to write to the host per call to USB client 'Write' |
|
104 @param aTotalNumBytes the total number of bytes of data to write to the host |
|
105 @param aNumRepeats the number of times to repeat in the buffer to be used when sending |
|
106 */ |
|
107 void WriteInPartsUsingPatternL(const TDesC8& aData, const TUint aNumBytesPerWrite, TUint aTotalNumBytes, const TBool aUseZLP); |
|
108 |
|
109 |
|
110 private: // From CActive |
|
111 /** |
|
112 */ |
|
113 void DoCancel(); |
|
114 |
|
115 /** |
|
116 */ |
|
117 void RunL(); |
|
118 |
|
119 /** |
|
120 */ |
|
121 TInt RunError(TInt aError); |
|
122 |
|
123 /** |
|
124 */ |
|
125 void CreateBigBuffer(const TDesC8& aData, const TUint aRepeats); |
|
126 |
|
127 private: |
|
128 /** |
|
129 The channel to the USB client driver |
|
130 */ |
|
131 RDevUsbcClient& iClientDriver; |
|
132 |
|
133 /** |
|
134 The endpoint number that this writer will write to |
|
135 */ |
|
136 TEndpointNumber iEndpoint; |
|
137 |
|
138 /** |
|
139 The total number of bytes in a repeated 'Write' |
|
140 */ |
|
141 TUint iTotalNumBytes; |
|
142 |
|
143 /** |
|
144 The number of bytes currently writte in a repeated write |
|
145 */ |
|
146 TUint iNumBytesWritten; |
|
147 |
|
148 /** |
|
149 The number of bytes to write at each successive a 'Write' |
|
150 */ |
|
151 TUint iNumBytesOnCurrentWrite; |
|
152 |
|
153 /** |
|
154 The length of the data pattern in a repeated write |
|
155 */ |
|
156 TUint iDataPatternLength; |
|
157 |
|
158 /** |
|
159 Is a ZLP required for the last 'Write' in a successive 'Write' |
|
160 */ |
|
161 TUint iUseZLP; |
|
162 |
|
163 /** |
|
164 Buffer for WriteInOne |
|
165 */ |
|
166 HBufC8* iBuffer; |
|
167 |
|
168 /** |
|
169 Ptr to buffer for WriteInOne |
|
170 */ |
|
171 TPtr8 iBufPtr; |
|
172 |
|
173 }; |
|
174 |
|
175 |
|
176 } |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 #endif |