os/kernelhwsrv/kerneltest/e32test/misc/ymodem.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test\misc\ymodem.h
    15 // 
    16 //
    17 
    18 #ifndef __YMODEM_H__
    19 #define __YMODEM_H__
    20 
    21 #ifndef __KERNEL_MODE__
    22 #include <e32base.h>
    23 typedef CBase BASE;
    24 #else
    25 #include <kernel/kernel.h>
    26 typedef DBase BASE;
    27 #endif
    28 
    29 const TUint8 SOH=0x01;
    30 const TUint8 STX=0x02;
    31 const TUint8 EOT=0x04;
    32 const TUint8 ACK=0x06;
    33 const TUint8 NAK=0x15;
    34 const TUint8 CAN=0x18;
    35 const TUint8 SUB=0x1A;
    36 const TUint8 BIGC=0x43;
    37 const TUint8 BIGG=0x47;
    38 
    39 const TInt KErrZeroLengthPacket=-200;
    40 const TInt KErrPacketTooShort=-201;
    41 const TInt KErrBadPacketType=-202;
    42 const TInt KErrCorruptSequenceNumber=-203;
    43 const TInt KErrWrongSequenceNumber=-204;
    44 const TInt KErrBadCrc=-205;
    45 const TInt KErrBadTerminationPacket=-206;
    46 
    47 class YModem : public BASE
    48 	{
    49 public:
    50 	TInt StartDownload(TBool aG, TInt& aLength, TDes& aName);
    51 	TInt ReadPackets(TUint8*& aDest, TInt aLength);
    52 protected:
    53 	YModem(TBool aG);
    54 	void UpdateCrc(const TUint8* aPtr, TInt aLength);
    55 	TInt CheckPacket(TUint8* aDest);
    56 	TInt ReadPacket(TDes8& aDest);
    57 	virtual TInt ReadBlock(TDes8& aDest)=0;
    58 	virtual void WriteC(TUint aChar)=0;
    59 protected:
    60 	TInt iTimeout;
    61 	TInt iState;
    62 	TInt iPacketSize;
    63 	TInt iBlockSize;
    64 	TUint8 iInitChar;
    65 	TUint8 iSeqNum;
    66 	TUint16 iCrc;
    67 	TInt iFileSize;
    68 	TBuf8<1040> iPacketBuf;
    69 	TBuf<256> iFileName;
    70 	};
    71 
    72 #endif