|
1 /* |
|
2 * Copyright (c) 2006-2008 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 the License "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: Debug utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <wlancontrolinterface.h> |
|
20 |
|
21 |
|
22 const TUint KPrintLineLength = 300; |
|
23 const TUint KPrintHexPerLine = 8; |
|
24 const TUint KPrintHexLineLength = KPrintHexPerLine * 3; |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // Debug::PrintBuffer |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 inline void Debug::PrintBuffer( TUint aLength, const TUint8* aData ) |
|
31 { |
|
32 ASSERT( aData != NULL); |
|
33 TBuf<KPrintHexLineLength> line; |
|
34 TUint idx( 0 ); |
|
35 for ( ; idx < aLength; ++idx ) |
|
36 { |
|
37 if ( idx && !( idx % KPrintHexPerLine ) ) |
|
38 { |
|
39 RDebug::Print( line ); |
|
40 line.Zero(); |
|
41 } |
|
42 line.AppendFormat( _L( "%02X " ), aData[idx] ); |
|
43 } |
|
44 RDebug::Print( line ); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // Debug::PrintString |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 inline void Debug::PrintString( const TDesC& aString, TUint aLength, const TUint8* aData ) |
|
52 { |
|
53 TBuf<KPrintLineLength> line; |
|
54 |
|
55 line.Append( aString ); |
|
56 |
|
57 TPtrC8 buf8( aData, aLength ); |
|
58 |
|
59 TBuf<KPrintLineLength> buf16; |
|
60 buf16.Copy( buf8 ); |
|
61 |
|
62 line.Append( buf16 ); |
|
63 |
|
64 RDebug::Print( _L( "%S" ), &line ); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // Debug::PrintTimestamp |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 inline void Debug::PrintTimestamp( const TDesC& aString ) |
|
72 { |
|
73 TBuf<KPrintLineLength> line; |
|
74 TTime time; |
|
75 time.HomeTime(); |
|
76 |
|
77 time.FormatL( line, _L( "%H:%T:%S:%C" ) ); |
|
78 line.Append( _L( " " ) ); |
|
79 line.Append( aString ); |
|
80 |
|
81 RDebug::Print( line ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Debug::PrintRates |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 inline void Debug::PrintRates( const TDesC& aString, TUint aRates ) |
|
89 { |
|
90 TBuf<KPrintLineLength> line; |
|
91 line.Append( aString ); |
|
92 |
|
93 if ( aRates & TWlanRate54mbit ) |
|
94 { |
|
95 line.Append( _L( "54Mbit/s " ) ); |
|
96 } |
|
97 if ( aRates & TWlanRate48mbit ) |
|
98 { |
|
99 line.Append( _L( "48Mbit/s " ) ); |
|
100 } |
|
101 if ( aRates & TWlanRate36mbit ) |
|
102 { |
|
103 line.Append( _L( "36Mbit/s " ) ); |
|
104 } |
|
105 if ( aRates & TWlanRate33mbit ) |
|
106 { |
|
107 line.Append( _L( "33Mbit/s " ) ); |
|
108 } |
|
109 if ( aRates & TWlanRate24mbit ) |
|
110 { |
|
111 line.Append( _L( "24Mbit/s " ) ); |
|
112 } |
|
113 if ( aRates & TWlanRate22mbit ) |
|
114 { |
|
115 line.Append( _L( "22Mbit/s " ) ); |
|
116 } |
|
117 if ( aRates & TWlanRate18mbit ) |
|
118 { |
|
119 line.Append( _L( "18Mbit/s " ) ); |
|
120 } |
|
121 if ( aRates & TWlanRate12mbit ) |
|
122 { |
|
123 line.Append( _L( "12Mbit/s " ) ); |
|
124 } |
|
125 if ( aRates & TWlanRate11mbit ) |
|
126 { |
|
127 line.Append( _L( "11Mbit/s " ) ); |
|
128 } |
|
129 if ( aRates & TWlanRate9mbit ) |
|
130 { |
|
131 line.Append( _L( "9Mbit/s " ) ); |
|
132 } |
|
133 if ( aRates & TWlanRate6mbit ) |
|
134 { |
|
135 line.Append( _L( "6Mbit/s " ) ); |
|
136 } |
|
137 if ( aRates & TWlanRate5p5mbit ) |
|
138 { |
|
139 line.Append( _L( "5.5Mbit/s " ) ); |
|
140 } |
|
141 if ( aRates & TWlanRate2mbit ) |
|
142 { |
|
143 line.Append( _L( "2Mbit/s " ) ); |
|
144 } |
|
145 if ( aRates & TWlanRate1mbit ) |
|
146 { |
|
147 line.Append( _L( "1Mbit/s " ) ); |
|
148 } |
|
149 |
|
150 RDebug::Print( line ); |
|
151 } |