os/kernelhwsrv/kerneltest/e32test/misc/ymodem.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/misc/ymodem.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,72 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\misc\ymodem.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __YMODEM_H__
    1.22 +#define __YMODEM_H__
    1.23 +
    1.24 +#ifndef __KERNEL_MODE__
    1.25 +#include <e32base.h>
    1.26 +typedef CBase BASE;
    1.27 +#else
    1.28 +#include <kernel/kernel.h>
    1.29 +typedef DBase BASE;
    1.30 +#endif
    1.31 +
    1.32 +const TUint8 SOH=0x01;
    1.33 +const TUint8 STX=0x02;
    1.34 +const TUint8 EOT=0x04;
    1.35 +const TUint8 ACK=0x06;
    1.36 +const TUint8 NAK=0x15;
    1.37 +const TUint8 CAN=0x18;
    1.38 +const TUint8 SUB=0x1A;
    1.39 +const TUint8 BIGC=0x43;
    1.40 +const TUint8 BIGG=0x47;
    1.41 +
    1.42 +const TInt KErrZeroLengthPacket=-200;
    1.43 +const TInt KErrPacketTooShort=-201;
    1.44 +const TInt KErrBadPacketType=-202;
    1.45 +const TInt KErrCorruptSequenceNumber=-203;
    1.46 +const TInt KErrWrongSequenceNumber=-204;
    1.47 +const TInt KErrBadCrc=-205;
    1.48 +const TInt KErrBadTerminationPacket=-206;
    1.49 +
    1.50 +class YModem : public BASE
    1.51 +	{
    1.52 +public:
    1.53 +	TInt StartDownload(TBool aG, TInt& aLength, TDes& aName);
    1.54 +	TInt ReadPackets(TUint8*& aDest, TInt aLength);
    1.55 +protected:
    1.56 +	YModem(TBool aG);
    1.57 +	void UpdateCrc(const TUint8* aPtr, TInt aLength);
    1.58 +	TInt CheckPacket(TUint8* aDest);
    1.59 +	TInt ReadPacket(TDes8& aDest);
    1.60 +	virtual TInt ReadBlock(TDes8& aDest)=0;
    1.61 +	virtual void WriteC(TUint aChar)=0;
    1.62 +protected:
    1.63 +	TInt iTimeout;
    1.64 +	TInt iState;
    1.65 +	TInt iPacketSize;
    1.66 +	TInt iBlockSize;
    1.67 +	TUint8 iInitChar;
    1.68 +	TUint8 iSeqNum;
    1.69 +	TUint16 iCrc;
    1.70 +	TInt iFileSize;
    1.71 +	TBuf8<1040> iPacketBuf;
    1.72 +	TBuf<256> iFileName;
    1.73 +	};
    1.74 +
    1.75 +#endif