#include <ctaskconsole.h>


Public Member Functions | |
| CTaskConsole (CCommunication *comm) | |
| virtual void | event (CEvent *e) |
| virtual CMachine::bit32 | fault () |
| The CTaskScheduler will call the fault() method when a fault code was returned by any of the task's other methods. | |
| virtual CMachine::bit32 | init () |
| called exactly once. perform task initialization such as initializing private variable. other tasks are not guaranteed so do not interract with other tasks at this stage. | |
| virtual const char * | name () |
| virtual CMachine::bit32 | run () |
| called periodically by CTaskScheduler to do a piece of work. | |
| virtual CMachine::bit32 | start () |
| called exactly once. all tasks are initialized at this point. called just prior to first call to run() | |
| virtual CMachine::bit32 | stop () |
| The CTaskScheduler will call the stop () method after the task was scheduled for cancelation. | |
| virtual | ~CTaskConsole () |
Protected Member Functions | |
| CMachine::bit32 | commandDump (CArray< CString * > *argv) |
| CMachine::bit32 | commandFlash (CArray< CString * > *argv) |
| CMachine::bit32 | commandHelp (CArray< CString * > *argv) |
| CMachine::bit32 | commandPeek (CArray< CString * > *argv) |
| CMachine::bit32 | commandPoke (CArray< CString * > *argv) |
| CMachine::bit32 | commandReset (CArray< CString * > *argv) |
| CMachine::bit32 | commandTop (CArray< CString * > *argv) |
| void | drawCommandPrompt () |
| Draw the command prompt. | |
| void | drawStatusBar () |
| Draw status bar. | |
| CMachine::bit32 | execute (CString *command) |
| Execute a command. | |
| virtual void | monitor () |
Definition at line 34 of file ctaskconsole.h.
| PikeAero::CTaskConsole::CTaskConsole | ( | CCommunication * | comm | ) |
| PikeAero::CTaskConsole::~CTaskConsole | ( | ) | [virtual] |
| CMachine::bit32 PikeAero::CTaskConsole::commandDump | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 285 of file ctaskconsole.cpp.
References PikeAero::CArray< T >::at(), and PikeAero::CArray< T >::count().
Referenced by execute().
00286 { 00287 CString addr = (argv->count() > 2) ? *(argv->at(1)) : ""; 00288 CString size = (argv->count() > 2) ? *(argv->at(2)) : ""; 00289 return 0; 00290 }


| CMachine::bit32 PikeAero::CTaskConsole::commandFlash | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 299 of file ctaskconsole.cpp.
Referenced by execute().

| CMachine::bit32 PikeAero::CTaskConsole::commandHelp | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 304 of file ctaskconsole.cpp.
References PikeAero::CArray< T >::at(), PikeAero::CTaskTerminal::comm(), PikeAero::CArray< T >::count(), and PikeAero::CCommunication::tx().
Referenced by execute(), and run().
00305 { 00306 CString arg = (argv != NULL && argv->count() > 1) ? *(argv->at(1)) : ""; 00307 00308 comm()->tx( "--------------- help ---------------\r\n" ); 00309 comm()->tx( "\r\n" ); 00310 00311 if ( arg == "" || arg == "top" ) 00312 { 00313 comm()->tx( "top\r\n" ); 00314 if ( arg == "top" ) 00315 { 00316 comm()->tx( "\r\n" ); 00317 comm()->tx( "Continuously monitor tasks\r\n" ); 00318 comm()->tx( "and A/D inputs.\r\n" ); 00319 comm()->tx( "\r\n" ); 00320 comm()->tx( "Updates display once per second.\r\n" ); 00321 } 00322 } 00323 00324 if ( arg == "" || arg == "peek" ) 00325 { 00326 comm()->tx( "peek <address>\r\n" ); 00327 } 00328 00329 if ( arg == "" || arg == "poke" ) 00330 { 00331 comm()->tx( "poke <address> <data> <byte|short|word>\r\n" ); 00332 } 00333 00334 if ( arg == "" || arg == "dump" ) 00335 { 00336 comm()->tx( "dump <address> <size> <byte|short|word>\r\n" ); 00337 } 00338 00339 if ( arg == "" || arg == "reset" ) 00340 { 00341 comm()->tx( "reset\r\n" ); 00342 } 00343 00344 if ( arg == "" || arg == "flash" ) 00345 { 00346 comm()->tx( "flash\r\n" ); 00347 } 00348 00349 return 0; 00350 }


| CMachine::bit32 PikeAero::CTaskConsole::commandPeek | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 275 of file ctaskconsole.cpp.
Referenced by execute().

| CMachine::bit32 PikeAero::CTaskConsole::commandPoke | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 280 of file ctaskconsole.cpp.
Referenced by execute().

| CMachine::bit32 PikeAero::CTaskConsole::commandReset | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 292 of file ctaskconsole.cpp.
References PRCCU, PRCCU_HALT, and PRCCU_SRESEN.
Referenced by execute().
00293 { 00294 PRCCU->CCR |= PRCCU_SRESEN; 00295 PRCCU->SMR |= PRCCU_HALT; 00296 return 0; 00297 }

| CMachine::bit32 PikeAero::CTaskConsole::commandTop | ( | CArray< CString * > * | argv | ) | [protected] |
Definition at line 268 of file ctaskconsole.cpp.
References PikeAero::CTaskTerminal::eraseDisplay(), PikeAero::CTaskConsoleBase::mMonitorMode, and PikeAero::CTaskConsoleBase::monitorStats.
Referenced by execute().
00269 { 00270 mMonitorMode = monitorStats; 00271 eraseDisplay(); 00272 return 0; 00273 }


| void PikeAero::CTaskConsole::drawCommandPrompt | ( | ) | [protected] |
Draw the command prompt.
Definition at line 142 of file ctaskconsole.cpp.
References PikeAero::CTaskTerminal::comm(), PikeAero::CByteArray::data(), PikeAero::CTaskTerminal::eraseLine(), PikeAero::CTaskConsoleBase::mCommandLine, PikeAero::CString::sprintf(), and PikeAero::CCommunication::tx().
Referenced by run().
00143 { 00144 CString str; 00145 comm()->tx("\r"); 00146 str.sprintf( "STINGRAY III > %s", mCommandLine.data() ); 00147 comm()->tx(str); 00148 eraseLine(); 00149 }


| void PikeAero::CTaskConsole::drawStatusBar | ( | ) | [protected] |
Draw status bar.
Definition at line 154 of file ctaskconsole.cpp.
References PikeAero::CTaskTerminal::comm(), PikeAero::CTaskTerminal::cursorMoveAbsolute(), PikeAero::CTaskTerminal::eraseLine(), PikeAero::CTaskConsoleBase::mAggregator, PikeAero::CTaskAggregator::rpm(), PikeAero::CString::sprintf(), and PikeAero::CCommunication::tx().
Referenced by monitor().
00155 { 00156 CString str; 00157 cursorMoveAbsolute(0,24); 00158 str.sprintf( "RPM: %5d", mAggregator->rpm() ); 00159 comm()->tx(str); 00160 eraseLine(); 00161 }


| void PikeAero::CTaskConsole::event | ( | CEvent * | e | ) | [virtual] |
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 409 of file ctaskconsole.cpp.
References PikeAero::CEvent::Clock, PikeAero::CTaskConsoleBase::mMonitorMode, PikeAero::CTaskConsoleBase::monitorNone, PikeAero::CTaskConsoleBase::mRunMonitor, and PikeAero::CEvent::type().
00410 { 00411 if ( e->type() == CEvent::Clock ) 00412 { 00413 if ( mMonitorMode != monitorNone ) 00414 { 00415 mRunMonitor=true; 00416 } 00417 } 00418 inherited::event(e); 00419 }

| CMachine::bit32 PikeAero::CTaskConsole::execute | ( | CString * | command | ) | [protected] |
Execute a command.
determine what the command is and take action...
Delete the argument string objects...
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 355 of file ctaskconsole.cpp.
References PikeAero::CArray< T >::at(), commandDump(), commandFlash(), commandHelp(), commandPeek(), commandPoke(), commandReset(), commandTop(), PikeAero::CArray< T >::count(), and PikeAero::CString::explode().
Referenced by run().
00356 { 00357 CMachine::bit32 rc = 1; 00358 CArray<CString*> argv = command->explode(' '); 00359 00360 if ( argv.count() ) 00361 { 00362 /** 00363 ** determine what the command is and take action... 00364 */ 00365 if ( *(argv.at(0)) == "help" ) 00366 { 00367 rc = commandHelp(&argv); 00368 } 00369 else if ( *(argv.at(0)) == "top" ) 00370 { 00371 rc = commandTop(&argv); 00372 } 00373 else if ( *(argv.at(0)) == "peek" ) 00374 { 00375 rc = commandPeek(&argv); 00376 } 00377 else if ( *(argv.at(0)) == "poke" ) 00378 { 00379 rc = commandPoke(&argv); 00380 } 00381 else if ( *(argv.at(0)) == "dump" ) 00382 { 00383 rc = commandDump(&argv); 00384 } 00385 else if ( *(argv.at(0)) == "reset" ) 00386 { 00387 rc = commandReset(&argv); 00388 } 00389 else if ( *(argv.at(0)) == "flash" ) 00390 { 00391 rc = commandFlash(&argv); 00392 } 00393 00394 /** 00395 ** Delete the argument string objects... 00396 */ 00397 for ( CMachine::ubit32 i = 0; i < argv.count(); i++ ) 00398 { 00399 CString* str = argv.at(i); 00400 delete str; 00401 } 00402 } 00403 return rc; 00404 }


| CMachine::bit32 PikeAero::CTaskConsole::fault | ( | ) | [virtual] |
The CTaskScheduler will call the fault() method when a fault code was returned by any of the task's other methods.
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 134 of file ctaskconsole.cpp.
References stop().
00135 { 00136 return inherited::stop(); 00137 }

| CMachine::bit32 PikeAero::CTaskConsole::init | ( | ) | [virtual] |
called exactly once. perform task initialization such as initializing private variable. other tasks are not guaranteed so do not interract with other tasks at this stage.
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 46 of file ctaskconsole.cpp.
00047 { 00048 return inherited::init(); 00049 }
| void PikeAero::CTaskConsole::monitor | ( | ) | [protected, virtual] |
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 163 of file ctaskconsole.cpp.
References PikeAero::CTaskAggregator::analog(), PikeAero::CTaskScheduler::at(), PikeAero::CMemHeap::available(), PikeAero::CMemHeap::bottom(), PikeAero::CByteArray::clear(), PikeAero::CTaskTerminal::clearAttributes(), PikeAero::CTaskTerminal::comm(), PikeAero::CTaskScheduler::count(), PikeAero::CTaskTerminal::cursorMoveAbsolute(), PikeAero::CTaskAggregator::days(), PikeAero::CTaskAggregator::deliverEventsPerSecond(), PikeAero::CTaskAggregator::dequeueEventsPerSecond(), drawStatusBar(), PikeAero::CTaskAggregator::enqueueEventsPerSecond(), PikeAero::CTaskTerminal::eraseLine(), PikeAero::CMachine::firmwareVersion(), PikeAero::CMachine::fMCLK(), PikeAero::ITask::getFault(), PikeAero::CTaskAggregator::hours(), PikeAero::CTaskConsoleBase::mAggregator, PikeAero::CTaskAggregator::maxEventsInQueuePerSecond(), PikeAero::CTaskAggregator::minutes(), PikeAero::CTaskConsoleBase::mRunMonitor, PikeAero::ITask::name(), PikeAero::ITask::priority(), PikeAero::ITask::running(), PikeAero::CTaskAggregator::seconds(), PikeAero::CTaskTerminal::setAttributeReverseVideo(), PikeAero::ITask::sleeping(), PikeAero::ITask::slicesPerSecond(), PikeAero::CString::sprintf(), stackPointer, stackTop, stackUsed, PikeAero::CTaskScheduler::tasksEventDriven(), PikeAero::CTaskAggregator::taskSlicesPerSecond(), PikeAero::CTaskScheduler::tasksRunning(), PikeAero::CTaskScheduler::tasksSleeping(), PikeAero::CMemHeap::top(), PikeAero::CCommunication::tx(), PikeAero::CMemHeap::used(), PikeAero::CTaskAggregator::vectorIRQCountPerSecond(), and PikeAero::ITask::yielding().
Referenced by run().
00164 { 00165 if ( mAggregator != NULL && mRunMonitor ) 00166 { 00167 CString str; 00168 CMachine::ubit32 taskCount = CTaskScheduler::count(); 00169 CMachine::ubit32 top = stackTop(); 00170 CMachine::ubit32 ptr = stackPointer(); 00171 CMachine::ubit32 used = stackUsed(); 00172 00173 mRunMonitor=false; 00174 00175 cursorMoveAbsolute(0,2); 00176 str.clear(); 00177 str.sprintf( "STINGRAY III V%s | STR730FZ2 @ %02dMHz | %02d:%02d:%02d:%02d ", 00178 CMachine::firmwareVersion(), 00179 CMachine::fMCLK() > 1000000 ? CMachine::fMCLK()/1000000 : CMachine::fMCLK(), 00180 mAggregator->days(), mAggregator->hours(), mAggregator->minutes(), mAggregator->seconds() ); 00181 setAttributeReverseVideo(); 00182 comm()->tx( str ); 00183 clearAttributes(); 00184 eraseLine(); 00185 00186 cursorMoveAbsolute(0,3); 00187 str.clear(); 00188 str.sprintf( "Tasks: %3d total, %3d running, %3d sleeping, %3d stopped" , 00189 taskCount, 00190 CTaskScheduler::tasksRunning(), 00191 CTaskScheduler::tasksSleeping(), 00192 CTaskScheduler::tasksEventDriven() ); 00193 comm()->tx( str ); 00194 eraseLine(); 00195 00196 cursorMoveAbsolute(0,4); 00197 str.clear(); 00198 str.sprintf( "Slices: %5d slices/sec, %3d uSec/slice, %5d irq/sec" , 00199 mAggregator->taskSlicesPerSecond(), 00200 1000000/mAggregator->taskSlicesPerSecond(), 00201 mAggregator->vectorIRQCountPerSecond() ); 00202 comm()->tx( str ); 00203 eraseLine(); 00204 00205 cursorMoveAbsolute(0,5); 00206 str.clear(); 00207 str.sprintf( "Event: %5d enqueue/sec, %5d dequeue/sec, %5d deliver/sec, %3d maxq/sec" , 00208 mAggregator->enqueueEventsPerSecond(), 00209 mAggregator->dequeueEventsPerSecond(), 00210 mAggregator->deliverEventsPerSecond(), 00211 mAggregator->maxEventsInQueuePerSecond() ); 00212 comm()->tx( str ); 00213 eraseLine(); 00214 00215 cursorMoveAbsolute(0,6); 00216 str.clear(); 00217 str.sprintf( "Stack: %5d total, %5d used, %5d free", 00218 top-(CMachine::ubit32)CMemHeap::top(), 00219 used, 00220 (top-(CMachine::ubit32)CMemHeap::top())-used ); 00221 comm()->tx( str ); 00222 eraseLine(); 00223 00224 cursorMoveAbsolute(0,7); 00225 str.clear(); 00226 str.sprintf( "Heap: %5d total, %5d used, %5d free", 00227 CMemHeap::top()-CMemHeap::bottom(), 00228 CMemHeap::used(), 00229 CMemHeap::available() ); 00230 comm()->tx( str ); 00231 eraseLine(); 00232 00233 cursorMoveAbsolute(0,8); 00234 for( CMachine::ubit32 i=0; i < 16; i++ ) 00235 { 00236 str.clear(); 00237 str.sprintf( "%5d", mAggregator->analog(i)); 00238 comm()->tx(str); 00239 } 00240 00241 cursorMoveAbsolute(0,9); 00242 setAttributeReverseVideo(); 00243 comm()->tx( " PID PR ST ADDRESS FAULT %CPU NAME " ); 00244 clearAttributes(); 00245 eraseLine(); 00246 00247 for( CMachine::ubit32 n=0; n < taskCount; n++ ) 00248 { 00249 ITask* task = CTaskScheduler::at(n); 00250 cursorMoveAbsolute(0,10+n); 00251 str.clear(); 00252 str.sprintf( "%5d %2d %s %08x %5d %4d %s", 00253 n, 00254 (CMachine::ubit32)task->priority(), 00255 task->sleeping() ? " s" : task->yielding() ? "-r" : task->running() ? " R" : " r", 00256 (CMachine::ubit32)task, 00257 task->getFault(), 00258 (task->slicesPerSecond()*100)/mAggregator->taskSlicesPerSecond(), 00259 task->name() ); 00260 comm()->tx( str ); 00261 eraseLine(); 00262 } 00263 00264 drawStatusBar(); 00265 } 00266 }


| virtual const char* PikeAero::CTaskConsole::name | ( | ) | [inline, virtual] |
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 43 of file ctaskconsole.h.
| CMachine::bit32 PikeAero::CTaskConsole::run | ( | ) | [virtual] |
called periodically by CTaskScheduler to do a piece of work.
run in terminal mode
interpret input here
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 72 of file ctaskconsole.cpp.
References PikeAero::CString::append(), PikeAero::CByteArray::clear(), PikeAero::CTaskTerminal::comm(), commandHelp(), drawCommandPrompt(), execute(), PikeAero::CString::length(), PikeAero::CTaskConsoleBase::mCommandLine, PikeAero::CTaskConsoleBase::mFirstTime, PikeAero::CTaskConsoleBase::mMonitorMode, monitor(), PikeAero::CTaskConsoleBase::monitorNone, PikeAero::CString::resize(), PikeAero::CCommunication::rx(), and PikeAero::CCommunication::tx().
00073 { 00074 if ( mFirstTime ) 00075 { 00076 mFirstTime=false; 00077 comm()->tx("\r\nSTINGRAY III\r\n"); 00078 comm()->tx("Copyright (c) 2005-2009 Pike Aerospace Research Corporation\r\n"); 00079 comm()->tx("http://www.pikeaero.com\r\n"); 00080 comm()->tx("info@pikeaero.com\r\n"); 00081 comm()->tx("\r\n"); 00082 00083 drawCommandPrompt(); 00084 } 00085 00086 monitor(); 00087 00088 /** interpret input here */ 00089 while ( comm()->rxReady() ) 00090 { 00091 CMachine::ubit8 ch = comm()->rx(); 00092 mMonitorMode = monitorNone; 00093 switch ( ch ) 00094 { 00095 case '\n': 00096 case '\r': 00097 comm()->tx("\r\n"); 00098 if ( execute( &mCommandLine ) == 0 ) 00099 { 00100 comm()->tx("\r\n"); 00101 mCommandLine.clear(); 00102 } 00103 else 00104 { 00105 commandHelp( NULL ); 00106 } 00107 drawCommandPrompt(); 00108 break; 00109 case '\b': 00110 case 0x7F: 00111 if ( mCommandLine.length() > 0 ) 00112 { 00113 mCommandLine.resize(mCommandLine.length()-1); 00114 comm()->tx("\b \b"); 00115 } 00116 break; 00117 default: 00118 if ( ch >= ' ' && ch <= '~' ) 00119 { 00120 mCommandLine.append(ch); 00121 comm()->tx(ch); 00122 } 00123 break; 00124 } 00125 } 00126 00127 return inherited::run(); 00128 }

| CMachine::bit32 PikeAero::CTaskConsole::start | ( | ) | [virtual] |
called exactly once. all tasks are initialized at this point. called just prior to first call to run()
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 55 of file ctaskconsole.cpp.
00056 { 00057 return inherited::start(); 00058 }
| CMachine::bit32 PikeAero::CTaskConsole::stop | ( | ) | [virtual] |
The CTaskScheduler will call the stop () method after the task was scheduled for cancelation.
Reimplemented from PikeAero::CTaskConsoleBase.
Definition at line 64 of file ctaskconsole.cpp.
Referenced by fault().
00065 { 00066 return inherited::stop(); 00067 }

1.5.8