sl@0: #ifndef __ENDPOINT_WRITER_H sl@0: #define __ENDPOINT_WRITER_H sl@0: sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * @file endpointwriter.h sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: namespace NUnitTesting_USBDI sl@0: { sl@0: sl@0: /** sl@0: This class describes a generic writer of data to host endpoints sl@0: */ sl@0: class CEndpointWriter : public CActive sl@0: { sl@0: public: sl@0: /** sl@0: Constructor, build an endpoint writer sl@0: @param aClientDriver a referrence to a channel to the client USB driver sl@0: @param aEndpoint the endpoint number to write to sl@0: */ sl@0: CEndpointWriter(RDevUsbcClient& aClientDriver,TEndpointNumber aEndpoint); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: virtual ~CEndpointWriter(); sl@0: sl@0: /** sl@0: Get numebr of bytes writtenat an instant in time if doing a multiple asynchronous 'Write' sl@0: */ sl@0: TUint NumBytesWrittenSoFar(); sl@0: sl@0: /** sl@0: Write the supplied data to through the endpoint to the host sl@0: @param aData the byte data to write to the host sl@0: @param aUseZLP send a zero length packet if appropriate sl@0: @param aCreateBuffer reallocate this object's 'iBuffer' and copy the data into it (required for aData is transient) sl@0: */ sl@0: void Write(const TDesC8& aData, TBool aUseZLP, TBool aCreateBuffer = ETrue); sl@0: sl@0: /** sl@0: Write the supplied data to through the endpoint to the host and wait for completion sl@0: @param aData the byte data to write to the host sl@0: @return error sl@0: */ sl@0: TInt WriteSynchronous(const TDesC8& aData, TBool aUseZLP); sl@0: sl@0: /** sl@0: Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host sl@0: @param aDataPattern the byte data pattern to use when writing to the host sl@0: @param aNumBytes the number of bytes to write to the host sl@0: @param aUseZLP use a zero lengt packet if last write packet conatins max packet's worth of data sl@0: */ sl@0: void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytesconst, TBool aUseZLP); sl@0: sl@0: /** sl@0: Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host sl@0: and wait for completion. sl@0: @param aDataPattern the byte data pattern to use when writing to the host sl@0: @param aNumBytes the number of bytes to write to the host sl@0: */ sl@0: void WriteSynchronousUsingPatternL(const TDesC8& aDataPattern, const TUint aNumBytes); sl@0: sl@0: /** sl@0: Write 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host, sl@0: and then halt the endpoint. sl@0: @param aDataPattern the byte data pattern to use when writing to the host sl@0: @param aNumBytes the number of bytes to write to the host sl@0: */ sl@0: void WriteSynchronousUsingPatternAndHaltL(const TDesC8& aDataPattern, const TUint aNumBytes); sl@0: sl@0: /** sl@0: Kick off a 'Write' of 'aNumBytes' bytes of data using 'aDataPattern' through the endpoint to the host. sl@0: @param aData the byte data to write to the host sl@0: @param aNumRepeats the number of times to repeat in the buffer to be used when sending sl@0: */ sl@0: void WriteUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP); sl@0: sl@0: /** sl@0: Kick off a sequence of 'Writes' which in total will write 'aNumBytes' bytes of data using 'aDataPattern' sl@0: through the endpoint to the host. sl@0: @param aNumBytesPerWrite the number of bytes of data to write to the host per call to USB client 'Write' sl@0: @param aTotalNumBytes the total number of bytes of data to write to the host sl@0: @param aNumRepeats the number of times to repeat in the buffer to be used when sending sl@0: */ sl@0: void WriteInPartsUsingPatternL(const TDesC8& aData, const TUint aNumBytesPerWrite, TUint aTotalNumBytes, const TBool aUseZLP); sl@0: sl@0: sl@0: private: // From CActive sl@0: /** sl@0: */ sl@0: void DoCancel(); sl@0: sl@0: /** sl@0: */ sl@0: void RunL(); sl@0: sl@0: /** sl@0: */ sl@0: TInt RunError(TInt aError); sl@0: sl@0: /** sl@0: */ sl@0: void CreateBigBuffer(const TDesC8& aData, const TUint aRepeats); sl@0: sl@0: private: sl@0: /** sl@0: The channel to the USB client driver sl@0: */ sl@0: RDevUsbcClient& iClientDriver; sl@0: sl@0: /** sl@0: The endpoint number that this writer will write to sl@0: */ sl@0: TEndpointNumber iEndpoint; sl@0: sl@0: /** sl@0: The total number of bytes in a repeated 'Write' sl@0: */ sl@0: TUint iTotalNumBytes; sl@0: sl@0: /** sl@0: The number of bytes currently writte in a repeated write sl@0: */ sl@0: TUint iNumBytesWritten; sl@0: sl@0: /** sl@0: The number of bytes to write at each successive a 'Write' sl@0: */ sl@0: TUint iNumBytesOnCurrentWrite; sl@0: sl@0: /** sl@0: The length of the data pattern in a repeated write sl@0: */ sl@0: TUint iDataPatternLength; sl@0: sl@0: /** sl@0: Is a ZLP required for the last 'Write' in a successive 'Write' sl@0: */ sl@0: TUint iUseZLP; sl@0: sl@0: /** sl@0: Buffer for WriteInOne sl@0: */ sl@0: HBufC8* iBuffer; sl@0: sl@0: /** sl@0: Ptr to buffer for WriteInOne sl@0: */ sl@0: TPtr8 iBufPtr; sl@0: sl@0: }; sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: #endif