First public contribution.
1 #ifndef __ENDPOINT_WRITER_H
2 #define __ENDPOINT_WRITER_H
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
12 * Initial Contributors:
13 * Nokia Corporation - initial contribution.
18 * @file endpointwriter.h
28 namespace NUnitTesting_USBDI
32 This class describes a generic writer of data to host endpoints
34 class CEndpointWriter : public CActive
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
42 CEndpointWriter(RDevUsbcClient& aClientDriver,TEndpointNumber aEndpoint);
47 virtual ~CEndpointWriter();
50 Get numebr of bytes writtenat an instant in time if doing a multiple asynchronous 'Write'
52 TUint NumBytesWrittenSoFar();
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)
60 void Write(const TDesC8& aData, TBool aUseZLP, TBool aCreateBuffer = ETrue);
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
67 TInt WriteSynchronous(const TDesC8& aData, TBool aUseZLP);
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
75 void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytesconst, TBool aUseZLP);
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
83 void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytes);
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
91 void WriteSynchronousUsingPatternAndHaltL(const TDesC8& aDataPattern, const TUint aNumBytes);
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
98 void WriteUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP);
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
107 void WriteInPartsUsingPatternL(const TDesC8& aData, const TUint aNumBytesPerWrite, TUint aTotalNumBytes, const TBool aUseZLP);
110 private: // From CActive
121 TInt RunError(TInt aError);
125 void CreateBigBuffer(const TDesC8& aData, const TUint aRepeats);
129 The channel to the USB client driver
131 RDevUsbcClient& iClientDriver;
134 The endpoint number that this writer will write to
136 TEndpointNumber iEndpoint;
139 The total number of bytes in a repeated 'Write'
141 TUint iTotalNumBytes;
144 The number of bytes currently writte in a repeated write
146 TUint iNumBytesWritten;
149 The number of bytes to write at each successive a 'Write'
151 TUint iNumBytesOnCurrentWrite;
154 The length of the data pattern in a repeated write
156 TUint iDataPatternLength;
159 Is a ZLP required for the last 'Write' in a successive 'Write'
164 Buffer for WriteInOne
169 Ptr to buffer for WriteInOne