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