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