static void ErrorPrompt (char* Msg) /* Display an error message and wait for a key */ { /* Save the current prompt */ char* OldPrompt = ActivePrompt; /* Display the new one */ DisplayPrompt (Msg); /* Wait for a key and discard it */ cgetc (); /* Restore the old prompt */ DisplayPrompt (OldPrompt); }
static void ActivateFrame (int Num, unsigned char Clear) /* Activate a new frame, deactivate the old one */ { unsigned char y; register FrameDesc* F; if (ActiveFrame != Num) { /* Deactivate the old one */ if (ActiveFrame >= 0) { DrawFrame (Frames [ActiveFrame], 0); } /* Activate the new one */ if ((ActiveFrame = Num) >= 0) { F = Frames [ActiveFrame]; /* Clear the frame if requested */ if (Clear) { for (y = F->fd_y1+1; y < F->fd_y2; ++y) { cclearxy (F->fd_x1+1, y, F->fd_width); } } DrawFrame (F, 1); } /* Redraw the current prompt line */ DisplayPrompt (ActivePrompt); } }
mmInt mmConsole::mmClient::Run(void) { ::_cwprintf_s( L"\r\n" L" Welcome to Calculation2D command line! \r\n\r\n" L" %d calculation methods are available, for a list of commands press TAB\r\n\r\n", m_psMethodsContainer->GetAvailableImagesCalculationMethods().size()); DisplayPrompt(); for(wchar_t v_cCurrent = ::_getwch(); Aggregate(v_cCurrent); v_cCurrent = ::_getwch()); return EXIT_SUCCESS; }
void CCLITerminal::DisplaySplash(CLISESSION *pSession) { char szVersion[128]; if (pSession->nMode == CLIMODE_USER) { DisplayUserMenu(pSession); return; } WriteStream(pSession, "\033[H\033[J"); sprintf(szVersion, "AIMIR Management Console (%s)\xd\xa", m_pMcuVersionString); WriteStream(pSession, szVersion); WriteStream(pSession, COPYRIGHT "\xd\xa"); WriteStream(pSession, "\xd\xa"); DisplayPrompt(pSession); }
void CCLITerminal::ReplaceCommand(CLISESSION *pSession, const char *pszCommand) { char szWhite[256]; char * pszCmd = NULL; if (pszCommand == NULL) pszCmd = const_cast<char*>(""); else pszCmd = const_cast<char*>(pszCommand); strcpy(pSession->szCommand, pszCmd); pSession->nCmdLength = strlen(pszCmd); WriteStream(pSession, "\xd"); memset(szWhite, ' ', 79); szWhite[79] = 0; WriteStream(pSession, szWhite); WriteStream(pSession, "\xd"); DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); }
//****************************************************************************** // // FUNCTION: DebugHandler // // USAGE: Handles debug commands from the UART // // // INPUT: N/A // // OUTPUT: N/A // // GLOBALS: TopDebugCmdList // //****************************************************************************** void DebugHandler(void) { // // Fill Input Stack // Design decision: only one command can be executed each iteration, TomW // if ( UartRcvDebugCommandRdy() ) { SetLEDStatus(LED_DEBUG_BUSY); if (!CmdParser(UartRcvStack, &TopDebugCmdList)) { DebugMsg("unrecognized command, try 'help'\n\r"); } DisplayPrompt(); SetLEDStatus(LED_DEBUG_NOT_BUSY); } }
void c_main() { int i; bool autoboot=true; char cmd[128]; long timeout; int argc=0; char *argv[MAX_ARGS]; CMD_TBL *cptr; // initiate status. status.terminalSpeed = SERIAL_SPEED; status.downloadSpeed = SERIAL_DOWNLOAD_SPEED; /* initiate serial and timer */ // serial and timer init. SerialInit(status.terminalSpeed); printf("\n\nFFUART has been initiated"); TimerInit(); //// printf the required GPL string. ////////////////////////////////////// printf("\n\n"); //printf(" "PACKAGE "-" VERSION "\n Copyright 2005 Embedded Group at 211.1010@UESTC\n"); //printf(" Support:211.1010@UESTC\n"); printf("\n"); //MemCpy((char *)KERNEL_DRAM_BASE, (char *)KERNEL_SRAM_BASE, KERNEL_MAX_SIZE); // kernel image reload EthInit(); //sendtest(); ///// wait 10 seconds before starting autoboot. /////////////////////////// printf("Autoboot in progress, press any key to stop "); for (i=0; i<3; i++){ timeout = GetTime()+1; // 1ÃÊ°£ Delay printf("."); while (GetTime()<timeout){ if ((FFLSR & 0x00000001)){ // Serial FFRBR; autoboot = false; break; } } if (autoboot==false) break; } /* No key was pressed, so proceed booting the kernel. */ if (autoboot) { printf("Autoboot started.\n"); for (cptr=cmdTbl; cptr->cmd; cptr++){ if (!StrCmp(cptr->cmd, "boot")) break; } DoBootKernel(cptr, 1, 0); } /* Key was pressed, so proceed command mode. */ printf("\nAutoboot aborted\n"); printf("Type \"help\" to get a list of commands\n"); // the command loop. endless, of course. for(;;) { DisplayPrompt("bootloader>"); // wait an hour to get a command. GetCommand(cmd, 128, 3600); if (!cmd || !cmd[0]) continue; argc = GetArgs(cmd, argv); for (cptr=cmdTbl; cptr->cmd; cptr++){ if (!StrCmp(argv[0], cptr->cmd)){ (cptr->run)(cptr, argc, argv); break; } } if (!StrCmp(argv[0], "help") || !StrCmp(argv[0], "?")){ DoPrintfHelp(argc, argv); } else if (!(cptr->cmd)){ printf("\tUnknown command : %s\n", argv[0]); } } } // CMain.
//***************************************************************************** // //! Main function handling the I2C example //! //! \param None //! //! \return None //! //***************************************************************************** void main() { int iRetVal; char acCmdStore[512]; // // Initialize board configurations // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // I2C Init // I2C_IF_Open(I2C_MASTER_MODE_FST); // // Display the banner followed by the usage description // DisplayBanner(APP_NAME); DisplayUsage(); while(FOREVER) { // // Provide a prompt for the user to enter a command // DisplayPrompt(); // // Get the user command line // iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore)); if(iRetVal < 0) { // // Error in parsing the command as length is exceeded. // UART_PRINT("Command length exceeded 512 bytes \n\r"); DisplayUsage(); } else if(iRetVal == 0) { // // No input. Just an enter pressed probably. Display a prompt. // } else { // // Parse the user command and try to process it. // iRetVal = ParseNProcessCmd(acCmdStore); if(iRetVal < 0) { UART_PRINT("Error in processing command\n\r"); DisplayUsage(); } } } }
BOOL CCLITerminal::CommandTask(CLISESSION *pSession, BOOL bComplete, BOOL bAddHistory) { CLIHANDLER *pHandler; char szCommand[256] = ""; int nResult, nDepts=0, nCommand; int i, nIndex, argc, nParam, nPos; // Make New Line WriteStream(pSession, "\n\r"); pSession->szCommand[pSession->nCmdLength] = '\0'; if (pSession->nMode == CLIMODE_USER) { nCommand = atoi(pSession->szCommand); pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; switch(nCommand) { case 1 : FirmwareDownload(pSession); WriteStream(pSession, "\n\r"); break; case 2 : pSession->nMode = CLIMODE_COMMAND; DisplayPrompt(pSession); return TRUE; } DisplaySplash(pSession); return TRUE; } // Check Login State if (!pSession->bLogined) { if (pSession->bNeedUser) { if (!CheckUser(pSession)) { // Display Login Error Message WriteStream(pSession, "Invalid User.\r\n"); } // Clear Command Buffer pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; DisplayPrompt(pSession); return TRUE; } else if (!CheckLogin(pSession)) { // Clear Command Buffer pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; pSession->bNeedUser = TRUE; // Display Login Error Message WriteStream(pSession, "Invalid account or password.\r\n\r\n"); strcpy(pSession->szPrompt, m_pCLIService->m_szUserPrompt); pSession->nLoginRetry++; if (pSession->nLoginRetry >= 3) { if (pSession->nType == CLITYPE_SERIAL) sleep(3); return FALSE; } DisplayPrompt(pSession); return TRUE; } // Clear Command Buffer pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; // Callback Login if (m_pCLIService->m_pConstruct && m_pCLIService->m_pConstruct->pfnOnLogin) m_pCLIService->m_pConstruct->pfnOnLogin(pSession); // Login Complete pSession->bLogined = TRUE; WriteStream(pSession, "\n\r"); strcpy(pSession->szPrompt, m_pCLIService->m_szDefaultPrompt); DisplayPrompt(pSession); return TRUE; } if (pSession->nCmdLength > 0) { // Find Command nResult = CLIERR_OK; pSession->szCommand[pSession->nCmdLength] = '\0'; if (pSession->szCommand[0] == '!') { if (strcmp(pSession->szCommand, "!!") == 0) { strcpy(pSession->szCommand, pSession->pszHistory[pSession->nHistoryCount-1]); pSession->nCmdLength = strlen(pSession->szCommand); } else { nIndex = atoi(&pSession->szCommand[1]); if ((nIndex > 0) && (nIndex <= pSession->nHistoryCount)) { strcpy(pSession->szCommand, pSession->pszHistory[nIndex-1]); pSession->nCmdLength = strlen(pSession->szCommand); } } } pSession->pszArgString = strdup(pSession->szCommand); if (bAddHistory) AddHistory(pSession, pSession->szCommand); SpliteParameter(pSession); pHandler = FindCommandHandler(pSession, nDepts, szCommand); if (pHandler != NULL) { // Execute Command nParam = GetParamCount(pHandler); argc = pSession->argc - (nDepts + 1); for(i=0; i<argc; i++) pSession->argv[i] = pSession->argv[nDepts+i+1]; // 파라메터의 갯수가 더 많은 경우를 막을때, add apn 명령 때문에 허용하도록 변경 2007/9/5 // if ((nParam == argc) || (pHandler->pszParam && (argc >= GetMinParamCount(pHandler)) && (argc <= nParam))) if ((nParam == argc) || (pHandler->pszParam && (argc >= GetMinParamCount(pHandler)))) { nPos = ValidateParameter(pSession, pHandler); if (nPos == -1) { pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; if (m_pCLIService->m_pConstruct && m_pCLIService->m_pConstruct->pfnOnCommand) m_pCLIService->m_pConstruct->pfnOnCommand(pSession, argc, pSession->argv, pHandler); if (pHandler->nGroup >= pSession->nGroup) { if (m_pCLIService->m_bEnableLog && pHandler->bLogFlag) m_pCLIService->AddLog(pSession->szUser, pSession->szCommand); nResult = pHandler->pfnCommand(pSession, argc, pSession->argv, (void *)pHandler); WriteStream(pSession, "\xd\xa"); } else { WriteStream(pSession, "Permission Denied."); WriteStream(pSession, "\xd\xa"); } } else { WriteStream(pSession, "Invalid parameter : '"); WriteStream(pSession, pSession->argv[nPos]); WriteStream(pSession, "'\xd\xa"); WriteStream(pSession, "\xd\xa"); } } else { WriteStream(pSession, "usage: "); WriteStream(pSession, szCommand); DisplayWideParameter(pSession, pHandler); DisplayAllParameter(pSession, pHandler); WriteStream(pSession, "\xd\xa"); } } if (pSession->pszArgString) FREE(pSession->pszArgString); pSession->pszArgString = NULL; if (nResult == CLIERR_ERROR) return FALSE; } // Clear Command Buffer pSession->nCmdLength = 0; pSession->szCommand[0] = '\0'; // Display Prompt DisplayPrompt(pSession); return TRUE; }
int CCLITerminal::FindBestMatchCommand(CLISESSION *pSession, CLIHANDLER **pHandler, BOOL bComment) { CLIHANDLER *pLast = NULL; char szBuffer[1024]; int i, nResult, nSize; int nDepts=0; *pHandler = NULL; pSession->pszArgString = strdup(pSession->szCommand); SpliteParameter(pSession); if (pSession->argc == 0) { if (!bComment) return 0; WriteStream(pSession, "\xd\xa"); for(i=0; m_pCommandHandlers[i].pszCommand; i++) { #if defined(__PATCH_6_2084__) if(m_bEnableHiddenCommand && m_pCommandHandlers[i].bHidden) continue; #else if(m_pCommandHandlers[i].bHidden) continue; #endif if (m_pCommandHandlers[i].nGroup < pSession->nGroup) continue; sprintf(szBuffer, " %c%-20s %s\xd\xa", m_pCommandHandlers[i].bHidden ? '*' : ' ', m_pCommandHandlers[i].pszCommand, m_pCommandHandlers[i].pszDescr); WriteStream(pSession, szBuffer); } DisplayPrompt(pSession); if (pSession->pszArgString) FREE(pSession->pszArgString); pSession->pszArgString = NULL; return 0; } nResult = CheckCommandSyntax(pSession, m_pCommandHandlers, nDepts, pHandler, &pLast); switch(nResult) { case -1 : if (strlen(pLast->pszCommand) != strlen(pSession->argv[nDepts])) { strcat(pSession->szCommand, &pLast->pszCommand[strlen(pSession->argv[nDepts])]); if (!bComment) WriteStream(pSession, &pLast->pszCommand[strlen(pSession->argv[nDepts])]); if (pLast->pNext || pLast->pszParam) { if (!bComment) WriteStream(pSession, " "); strcat(pSession->szCommand, " "); } pSession->nCmdLength = strlen(pSession->szCommand); if (!bComment) break; WriteStream(pSession, "\xd\xa"); for(i=0; (*pHandler)[i].pszCommand; i++) { #if defined(__PATCH_6_2084__) if(m_bEnableHiddenCommand && (*pHandler)[i].bHidden) continue; #else if((*pHandler)[i].bHidden) continue; #endif if ((*pHandler)[i].nGroup < pSession->nGroup) continue; sprintf(szBuffer, " %c%-20s %s\xd\xa", (*pHandler)[i].bHidden ? '*' : ' ', (*pHandler)[i].pszCommand, (*pHandler)[i].pszDescr); WriteStream(pSession, szBuffer); } DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); } else if (pLast != *pHandler) { if (pSession->szCommand[pSession->nCmdLength-1] != ' ') { strcat(pSession->szCommand, " "); pSession->nCmdLength = strlen(pSession->szCommand); if (!bComment) WriteStream(pSession, " "); } if (!bComment) break; WriteStream(pSession, "\xd\xa"); for(i=0; (*pHandler)[i].pszCommand; i++) { #if defined(__PATCH_6_2084__) if(m_bEnableHiddenCommand && (*pHandler)[i].bHidden) continue; #else if((*pHandler)[i].bHidden) continue; #endif if ((*pHandler)[i].nGroup < pSession->nGroup) continue; sprintf(szBuffer, " %c%-20s %s\xd\xa", (*pHandler)[i].bHidden ? '*' : ' ', (*pHandler)[i].pszCommand, (*pHandler)[i].pszDescr); WriteStream(pSession, szBuffer); } DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); } break; case 0 : if (!bComment) break; WriteStream(pSession, "\xd\xa"); for(i=0; (*pHandler)[i].pszCommand; i++) { #if defined(__PATCH_6_2084__) if(m_bEnableHiddenCommand && (*pHandler)[i].bHidden) continue; #else if((*pHandler)[i].bHidden) continue; #endif if ((*pHandler)[i].nGroup < pSession->nGroup) continue; sprintf(szBuffer, " %c%-20s %s\xd\xa", (*pHandler)[i].bHidden ? '*' : ' ', (*pHandler)[i].pszCommand, (*pHandler)[i].pszDescr); WriteStream(pSession, szBuffer); } *pSession->szCommand = '\0'; for(i=0; i<nDepts; i++) { strcat(pSession->szCommand, pSession->argv[i]); strcat(pSession->szCommand, " "); } pSession->nCmdLength = strlen(pSession->szCommand); DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); break; case 1 : if (strlen(pLast->pszCommand) != strlen(pSession->argv[nDepts])) { strcat(pSession->szCommand, &pLast->pszCommand[strlen(pSession->argv[nDepts])]); if (pLast->pNext || pLast->pszParam) strcat(pSession->szCommand, " "); pSession->nCmdLength = strlen(pSession->szCommand); if (!bComment) { WriteStream(pSession, &pLast->pszCommand[strlen(pSession->argv[nDepts])]); if (pLast->pNext || pLast->pszParam) WriteStream(pSession, " "); } } else if (pLast->pszParam && (pSession->szCommand[pSession->nCmdLength-1] != ' ')) { if (pSession->argc <= (nDepts+1)) { strcat(pSession->szCommand, " "); pSession->nCmdLength = strlen(pSession->szCommand); if (!bComment) { if (pLast->pNext || pLast->pszParam) WriteStream(pSession, " "); } } } if (!pLast->pszParam) break; if (!bComment) break; DisplayAllParameter(pSession, pLast); DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); break; default : if (!bComment) break; WriteStream(pSession, "\xd\xa"); nSize = strlen(pSession->argv[nDepts]); for(i=0; (*pHandler)[i].pszCommand; i++) { if (strncmp((*pHandler)[i].pszCommand, pSession->argv[nDepts], nSize) != 0) continue; #if defined(__PATCH_6_2084__) if(m_bEnableHiddenCommand && (*pHandler)[i].bHidden) continue; #else if((*pHandler)[i].bHidden) continue; #endif if ((*pHandler)[i].nGroup < pSession->nGroup) continue; sprintf(szBuffer, " %c%-20s %s\xd\xa", (*pHandler)[i].bHidden ? '*' : ' ', (*pHandler)[i].pszCommand, (*pHandler)[i].pszDescr); WriteStream(pSession, szBuffer); } DisplayPrompt(pSession); WriteStream(pSession, pSession->szCommand); break; } if (pSession->pszArgString) FREE(pSession->pszArgString); pSession->pszArgString = NULL; return nResult; }
bool mmConsole::mmClient::Aggregate(wchar_t const p_cCurrent) { if(p_cCurrent == cNavTrigger1 || p_cCurrent == cNavTrigger2) { wchar_t v_cDirection = ::_getwch(); if(v_cDirection == cNavUp && m_sPositionInHistory != m_sHistory.begin()) { m_bNavigate = true; EraseToPrompt(); --m_sPositionInHistory; Write(m_sPositionInHistory->Print(cEndOfWord, cEscape)); } else if(v_cDirection == cNavDown && m_sPositionInHistory != m_sHistory.end()) { m_bNavigate = true; EraseToPrompt(); ++m_sPositionInHistory; if(m_sPositionInHistory != m_sHistory.end()) Write(m_sPositionInHistory->Print(cEndOfWord, cEscape)); else Write(m_sCommandLine.Print(cEndOfWord, cEscape)); } } else { if(m_bNavigate) { if(m_sPositionInHistory != m_sHistory.end()) { m_sCommandLine = *m_sPositionInHistory; m_sPositionInHistory = m_sHistory.end(); } m_bNavigate = false; } } if(p_cCurrent == cEndOfWord) { m_sCommandLine.AddParam(); Write(p_cCurrent); } else if(p_cCurrent == cEndOfLine) { // optionally find method if not found std::vector<std::wstring> v_sCommandLineElements = m_sCommandLine.GetParams(); if(m_psCommand == NULL) m_psCommand = FindCommand(v_sCommandLineElements.front()); // print new line NewLine(); // interpret command if(m_psCommand != NULL) { std::vector<mmCommands::mmParam> v_sExpectedParams = m_psCommand->GetInputParams(); std::vector<std::wstring> v_sReceivedParams(v_sCommandLineElements.empty() ? v_sCommandLineElements.begin() : (v_sCommandLineElements.begin() + 1), v_sCommandLineElements.end()); if(! ValidateParams(v_sReceivedParams, v_sExpectedParams)) { WriteLn(m_psCommand->GetInfo()); } else if(! m_psCommand->Run(v_sCommandLineElements.front(), v_sExpectedParams)) { WriteLn(L"error: " + m_psCommand->GetErrorMessage()); } } else { WriteLn(v_sCommandLineElements.front() + L": command not found"); } // clear command m_psCommand = NULL; m_sHistory.push_back(m_sCommandLine); m_sCommandLine = mmCommandLine(); // reset current position in history m_sPositionInHistory = m_sHistory.end(); // display prompt DisplayPrompt(); } else if(p_cCurrent == cAutoComplete) { // run autocomplete for current context if(! AutoComplete()) { // display prompt DisplayPrompt(); } // echo all Write(m_sCommandLine.Print(cEndOfWord, cEscape)); } else if(p_cCurrent == cBackSpace) { bool v_bSuccess = false; if(! m_sCommandLine.IsParamEmpty()) v_bSuccess = m_sCommandLine.EraseFromParam(); else v_bSuccess = m_sCommandLine.EraseParam(); if(v_bSuccess) { Write(cBackSpace); Write(L' '); Write(cBackSpace); } } else if(IsAllowedCharacter(p_cCurrent)) { m_sCommandLine.AddToParam(p_cCurrent); Write(p_cCurrent); } return true; }
void c_main(char *blockBase, u32 blockSize) { int numRead = 0; char commandline[128]; blobStatus status; int i; int retval = 0; /* We really want to be able to communicate, so initialise the * serial port at 9k6 (which works good for terminals) */ SerialInit(baud9k6); TimerInit(); /* initialise status */ status.kernelSize = 0; status.kernelType = fromFlash; status.ramdiskSize = 0; status.ramdiskType = fromFlash; status.blockSize = blockSize; status.downloadSpeed = baud115k2; /* Load kernel and ramdisk from flash to RAM */ Reload("kernel", &status); Reload("ramdisk", &status); /* Print the required GPL string */ SerialOutputString("\r" PACKAGE " version " VERSION "\r" "Copyright (C) 1999 2000 " "Jan-Derk Bakker and Erik Mouw\r" "Copyright (C) 2000 " "Johan Pouwelse.\r"); SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " "read the GNU GPL for details.\r"); SerialOutputString("This is free software, and you are welcome " "to redistribute it\r"); SerialOutputString("under certain conditions; " "read the GNU GPL for details.\r\r"); /* and some information */ #ifdef BLOB_DEBUG SerialOutputString("Running from "); if(RunningFromInternal()) SerialOutputString("internal flash\r"); else SerialOutputString("external flash\r"); SerialOutputString("blockBase = 0x"); SerialOutputHex((int) blockBase); SerialOutputString(", blockSize = 0x"); SerialOutputHex(blockSize); SerialOutputByte('\r'); #endif /* wait 10 seconds before starting autoboot */ SerialOutputString("Autoboot in progress, press any key to stop "); for(i = 0; i < 10; i++) { SerialOutputByte('.'); retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; } /* no key was pressed, so proceed booting the kernel */ if(retval == 0) { commandline[0] = '\0'; BootKernel(commandline); } SerialOutputString("\rAutoboot aborted\r"); SerialOutputString("Type \"help\" to get a list of commands\r"); /* the command loop. endless, of course */ for(;;) { DisplayPrompt(NULL); /* wait an hour to get a command */ numRead = GetCommand(commandline, 128, 3600); if(numRead > 0) { if(MyStrNCmp(commandline, "boot", 4) == 0) { BootKernel(commandline + 4); } else if(MyStrNCmp(commandline, "clock", 5) == 0) { SetClock(commandline + 5); } else if(MyStrNCmp(commandline, "download ", 9) == 0) { Download(commandline + 9, &status); } else if(MyStrNCmp(commandline, "flash ", 6) == 0) { Flash(commandline + 6, &status); } else if(MyStrNCmp(commandline, "help", 4) == 0) { PrintHelp(); } else if(MyStrNCmp(commandline, "reload ", 7) == 0) { Reload(commandline + 7, &status); } else if(MyStrNCmp(commandline, "reset", 5) == 0) { ResetTerminal(); } else if(MyStrNCmp(commandline, "speed ", 6) == 0) { SetDownloadSpeed(commandline + 6, &status); } else if(MyStrNCmp(commandline, "status", 6) == 0) { PrintStatus(&status); } else { SerialOutputString("*** Unknown command: "); SerialOutputString(commandline); SerialOutputByte('\r'); } } } } /* c_main */
static void AnyKeyPrompt (void) { DisplayPrompt ("Press any key to continue"); }
static void HelpPrompt (void) /* Display a prompt line mentioning the help key */ { DisplayPrompt ("Press F1 for help"); }
void TaskStart ( void *data ) { PWINDOWS ptr = GetActiveWindow(); UBYTE i; char sCmd[MAX_X]; WORD key; WORD index, pos = 0x00; data = data; /* Prevent compiler warning */ OS_ENTER_CRITICAL(); PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */ PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */ OS_EXIT_CRITICAL(); PC_DispChar(0, 0, ' ', 0x00); PC_DispStr (8, 16, "Determining CPU's capacity ...", DISP_FGND_WHITE); CreateWindow (0, StartY, MAX_X, EndY, DISP_FGND_WHITE, DISP_BGND_BLUE, "[ Prompt Window ]"); CreateTaskWindows(); OSStatInit(); /* Initialize uC/OS-II's statistics */ for (i = 0; i < N_TASKS; i ++) { /* Create N_TASKS identical tasks */ TaskData[i] = '0' + i; /* Each task will display its own letter */ OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1); } DisplayTitle(); ClearWindow(); memset(sCmd, 0x00, MAX_X); DisplayPrompt(); for (;;) { DisplayStatus(); // display status of tasks if (PC_GetKey(&key) == TRUE) { /* See if key has been pressed */ if (key == 0x1B) { /* Yes, see if it's the ESCAPE key */ PC_DOSReturn(); /* Return to DOS */ } else if (key == 0x08) // backspace { pos --; pos = pos <= 0x00 ? 0x00 : pos; sCmd[pos] = '\0'; PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, ' ', ptr->color); DisplayCursor(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy); } else if (key == 0x0d || key == 0x0a) // enter { if (pos) { index = ParseCommand(sCmd); HandleCommand(index); } memset(sCmd, 0x00, MAX_X); pos = 0x00; ptr->cy ++; if (ptr->cy == ptr->ey - 1) ClearWindow(); DisplayPrompt(); } else if ((key >= '0' && key <= '9') || (key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z')) { if (pos < MAX_X) { sCmd[pos] = (char)key; PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, key, ptr->color); DisplayCursor (ptr->cx + pos + strlen(sCmdPrompt) + 1, ptr->cy); } pos ++; } } OSTimeDlyHMSM(0, 0, 0, 200); /* Wait 200 ms */ } }