|
1 /* |
|
2 * Copyright (c) 2009 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 using System; |
|
19 using System.Collections.Generic; |
|
20 using System.Text; |
|
21 using SymbianUtils.BasicTypes; |
|
22 using SymbianETMLib.Common.Types; |
|
23 using SymbianETMLib.Common.Packets; |
|
24 using SymbianETMLib.Common.Exception; |
|
25 |
|
26 namespace SymbianETMLib.Common.State |
|
27 { |
|
28 public class ETMDecodeStateASync : ETMDecodeState |
|
29 { |
|
30 #region Constructors |
|
31 public ETMDecodeStateASync( ETMStateData aManager ) |
|
32 : base( aManager ) |
|
33 { |
|
34 } |
|
35 #endregion |
|
36 |
|
37 #region API |
|
38 public override ETMDecodeState HandleByte( SymByte aByte ) |
|
39 { |
|
40 ETMDecodeState nextState = this; |
|
41 // |
|
42 if ( aByte == 0 ) |
|
43 { |
|
44 ++iASyncConsecutiveNullByteCount; |
|
45 } |
|
46 else if ( aByte == 0x80 && iASyncConsecutiveNullByteCount == 5 ) |
|
47 { |
|
48 // That's the start of the a-sync packet |
|
49 iASyncConsecutiveNullByteCount = 0; |
|
50 base.StateData.SetSynchronized(); |
|
51 nextState = new ETMDecodeStateSynchronized( base.StateData ); |
|
52 Trace(); |
|
53 } |
|
54 else |
|
55 { |
|
56 // Invalid byte |
|
57 throw new ETMException( "ERROR - data is corrupt - expected null byte or end marker during A-SYNC" ); |
|
58 } |
|
59 // |
|
60 return nextState; |
|
61 } |
|
62 #endregion |
|
63 |
|
64 #region Properties |
|
65 #endregion |
|
66 |
|
67 #region Internal methods |
|
68 private void Trace() |
|
69 { |
|
70 base.DbgTrace( "A-SYNC", string.Empty ); |
|
71 } |
|
72 #endregion |
|
73 |
|
74 #region From System.Object |
|
75 #endregion |
|
76 |
|
77 #region Data members |
|
78 private int iASyncConsecutiveNullByteCount = 0; |
|
79 #endregion |
|
80 } |
|
81 } |