dbgagents/trkagent/engine/TrkFramingLayer.h
changeset 0 c6b0df440bee
equal deleted inserted replaced
-1:000000000000 0:c6b0df440bee
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __TRKFRAMINGLAYER_H__
       
    20 #define __TRKFRAMINGLAYER_H__
       
    21 
       
    22 #include "TrkCommPort.h"
       
    23 
       
    24 //
       
    25 // Forward declarations
       
    26 //
       
    27 class CTrkDispatchLayer;
       
    28 
       
    29 
       
    30 //
       
    31 // class CTrkFramingLayer
       
    32 //
       
    33 // Frames outgoing messages to the host and unframes incoming messages
       
    34 // from the host
       
    35 //
       
    36 class CTrkFramingLayer : public CBase
       
    37 {
       
    38 public:
       
    39 
       
    40 	enum TFramingState
       
    41 	{
       
    42 		eWaiting,
       
    43 		eFound,
       
    44 		eInFrame,
       
    45 		eFrameOverflow
       
    46 	};
       
    47 
       
    48 	CTrkFramingLayer(CTrkCommPort* aPort);
       
    49 	~CTrkFramingLayer();
       
    50 
       
    51 	void Listen(CTrkDispatchLayer* aDispatchLayer);
       
    52 	void StopListening();
       
    53 
       
    54 	void HandleByte(TUint8 aByte);
       
    55 
       
    56 	void RespondOkL(const TDesC8& aMsg);
       
    57 	void RespondErr(TUint8 aType, TUint8 aErr);
       
    58 	void InformEventL(const TDesC8& aMsg);
       
    59 	void SendRawMsgL(const TDesC8& aMsg);
       
    60 	
       
    61 	TBool IsBigEndian() { return iIsBigEndian; };
       
    62 	void ResetSequenceIDs() { iSequenceId = 1; iOutSequenceId = 1; };
       
    63 
       
    64 private:
       
    65 
       
    66 	void SendMsgL(const TDesC8& aMsg);
       
    67 
       
    68 	void DiscardFrame();
       
    69 	TBool ProcessFrame();
       
    70 
       
    71 	void IncrementSequenceId() { if (iSequenceId == 0xFF) iSequenceId = 1; else iSequenceId++; };
       
    72 	void IncrementOutSequenceId() { if (iOutSequenceId == 0xFF) iOutSequenceId = 1; else iOutSequenceId++; };
       
    73 
       
    74 private:
       
    75 
       
    76 	CTrkCommPort* iPort;
       
    77 	CTrkDispatchLayer* iDispatchLayer;
       
    78 
       
    79 	TFramingState iFramingState;
       
    80 	TBool iEscape;
       
    81 	TUint8 iFCS;
       
    82 
       
    83 	TBuf8<MAXMESSAGESIZE> iBuffer;	// contains the incoming messages
       
    84 	TUint8 iSequenceId;
       
    85 	TUint8 iOutSequenceId;
       
    86 		
       
    87 	TBool iIsBigEndian;
       
    88 	
       
    89 	HBufC8* iLastReply;
       
    90 };
       
    91 
       
    92 #endif // __TRKFRAMINGLAYER_H__