1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
38 |
38 |
39 #include "rusbotgsession.h" |
39 #include "rusbotgsession.h" |
40 |
40 |
41 #include "cdisplay.h" |
41 #include "cdisplay.h" |
42 #include "husbconsapp.h" |
42 #include "husbconsapp.h" |
43 #include "tmslog.h" |
43 #include "debug.h" |
44 |
44 |
45 |
45 |
46 _LIT(KTxtApp,"HOST USB CONSOLE APP"); |
46 _LIT(KTxtApp,"HOST USB CONSOLE APP"); |
47 |
47 |
48 |
48 |
49 |
49 |
50 CHeartBeat* CHeartBeat::NewLC(CDisplay& aDisplay) |
50 CHeartBeat* CHeartBeat::NewLC(CDisplay& aDisplay) |
51 { |
51 { |
52 CHeartBeat* me = new(ELeave) CHeartBeat(aDisplay); |
52 CHeartBeat* me = new(ELeave) CHeartBeat(aDisplay); |
53 CleanupStack::PushL(me); |
53 CleanupStack::PushL(me); |
54 me->ConstructL(); |
54 me->ConstructL(); |
55 return me; |
55 return me; |
56 } |
56 } |
57 |
57 |
58 |
58 |
59 CHeartBeat::CHeartBeat(CDisplay& aDisplay) |
59 CHeartBeat::CHeartBeat(CDisplay& aDisplay) |
60 : CActive(0), |
60 : CActive(0), |
61 iDisplay(aDisplay) |
61 iDisplay(aDisplay) |
62 {} |
62 {} |
63 |
63 |
64 |
64 |
65 void CHeartBeat::ConstructL() |
65 void CHeartBeat::ConstructL() |
66 { |
66 { |
67 CActiveScheduler::Add(this); |
67 CActiveScheduler::Add(this); |
68 iTimer.CreateLocal(); |
68 iTimer.CreateLocal(); |
69 RunL(); |
69 RunL(); |
70 } |
70 } |
71 |
71 |
72 |
72 |
73 CHeartBeat::~CHeartBeat() |
73 CHeartBeat::~CHeartBeat() |
74 { |
74 { |
75 Cancel(); |
75 Cancel(); |
76 } |
76 } |
77 |
77 |
78 |
78 |
79 void CHeartBeat::DoCancel() |
79 void CHeartBeat::DoCancel() |
80 { |
80 { |
81 iTimer.Cancel(); |
81 iTimer.Cancel(); |
82 } |
82 } |
83 |
83 |
84 |
84 |
85 void CHeartBeat::RunL() |
85 void CHeartBeat::RunL() |
86 { |
86 { |
87 SetActive(); |
87 SetActive(); |
88 // Print RAM usage & up time |
88 // Print RAM usage & up time |
89 iUpTime++; |
89 iUpTime++; |
90 iDisplay.UpTime(iUpTime); |
90 iDisplay.UpTime(iUpTime); |
91 |
91 |
92 TInt mem=0; |
92 TInt mem=0; |
93 if (HAL::Get(HALData::EMemoryRAMFree, mem)==KErrNone) |
93 if (HAL::Get(HALData::EMemoryRAMFree, mem)==KErrNone) |
94 { |
94 { |
95 iDisplay.MemoryFree(mem); |
95 iDisplay.MemoryFree(mem); |
96 } |
96 } |
97 iTimer.After(iStatus, 1000000); |
97 iTimer.After(iStatus, 1000000); |
98 } |
98 } |
99 |
99 |
100 |
100 |
101 GLDEF_C void RunAppL() |
101 GLDEF_C void RunAppL() |
102 { |
102 { |
103 __MSFNSLOG |
|
104 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
103 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
105 CleanupStack::PushL(sched); |
104 CleanupStack::PushL(sched); |
106 CActiveScheduler::Install(sched); |
105 CActiveScheduler::Install(sched); |
107 |
106 |
108 RFs fs; |
107 RFs fs; |
112 RUsbOtgSession usbOtgSession; |
111 RUsbOtgSession usbOtgSession; |
113 TInt err = usbOtgSession.Connect(); |
112 TInt err = usbOtgSession.Connect(); |
114 User::LeaveIfError(err); |
113 User::LeaveIfError(err); |
115 |
114 |
116 CConsoleBase* console; |
115 CConsoleBase* console; |
117 console = Console::NewL(KTxtApp, TSize(KConsFullScreen,KConsFullScreen)); |
116 console = Console::NewL(KTxtApp, TSize(KConsFullScreen,KConsFullScreen)); |
118 CleanupStack::PushL(console); |
117 CleanupStack::PushL(console); |
119 |
118 |
120 CDisplay* display = CDisplay::NewLC(fs, *console); |
119 CDisplay* display = CDisplay::NewLC(fs, *console); |
121 CMessageKeyProcessor::NewLC(*display, usbOtgSession); |
120 CMessageKeyProcessor::NewLC(*display, usbOtgSession); |
122 CHeartBeat::NewLC(*display); |
121 CHeartBeat::NewLC(*display); |
123 |
122 |
124 display->Menu(); |
123 display->Menu(); |
125 display->DriveListL(); |
124 display->DriveListL(); |
126 |
125 |
133 // ************************************************************************* |
132 // ************************************************************************* |
134 // Start Active Scheduler |
133 // Start Active Scheduler |
135 // ************************************************************************* |
134 // ************************************************************************* |
136 CActiveScheduler::Start(); |
135 CActiveScheduler::Start(); |
137 |
136 |
138 // 1 sec delay for sessions to stop |
137 // 1 sec delay for sessions to stop |
139 User::After(1000000); |
138 User::After(1000000); |
140 CleanupStack::PopAndDestroy(usbHost); |
139 CleanupStack::PopAndDestroy(usbHost); |
141 CleanupStack::PopAndDestroy(); // CPeriodUpdate |
140 CleanupStack::PopAndDestroy(); // CPeriodUpdate |
142 CleanupStack::PopAndDestroy(); // CMessageKeyProcessor |
141 CleanupStack::PopAndDestroy(); // CMessageKeyProcessor |
143 CleanupStack::PopAndDestroy(); // CDisplay |
142 CleanupStack::PopAndDestroy(); // CDisplay |
144 CleanupStack::PopAndDestroy(console); |
143 CleanupStack::PopAndDestroy(console); |
147 } |
146 } |
148 |
147 |
149 |
148 |
150 |
149 |
151 GLDEF_C TInt E32Main() |
150 GLDEF_C TInt E32Main() |
152 { |
151 { |
153 __UHEAP_MARK; |
152 __UHEAP_MARK; |
154 CTrapCleanup* cleanup = CTrapCleanup::New(); |
153 CTrapCleanup* cleanup = CTrapCleanup::New(); |
155 TRAPD(error, RunAppL()); |
154 TRAPD(error, RunAppL()); |
156 __ASSERT_ALWAYS(!error, User::Panic(KTxtApp, error)); |
155 __ASSERT_ALWAYS(!error, User::Panic(KTxtApp, error)); |
157 delete cleanup; |
156 delete cleanup; |
158 __UHEAP_MARKEND; |
157 __UHEAP_MARKEND; |
159 return 0; |
158 return 0; |
160 } |
159 } |