Lines Matching refs:shellContextHandle

185 static void SHELL_ProcessCommand(shell_context_handle_t *shellContextHandle, const char *cmd); /*!<…
187 static void SHELL_GetHistoryCommand(shell_context_handle_t *shellContextHandle,
190 static void SHELL_AutoComplete(shell_context_handle_t *shellContextHandle); /*!< auto complete comm…
192 static shell_status_t SHELL_GetChar(shell_context_handle_t *shellContextHandle,
257 shell_context_handle_t *shellContextHandle; in SHELL_WriteBuffer() local
259 shellContextHandle = (shell_context_handle_t *)(void *)buffer; in SHELL_WriteBuffer()
266 if (NULL == shellContextHandle->serialHandle) in SHELL_WriteBuffer()
270 (void)putchar(shellContextHandle->printBuffer[index]); in SHELL_WriteBuffer()
276 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, in SHELL_WriteBuffer()
277 … (uint8_t *)shellContextHandle->printBuffer, (uint32_t)*indicator); in SHELL_WriteBuffer()
280 shellContextHandle->printLength += (uint32_t)*indicator; in SHELL_WriteBuffer()
284 shellContextHandle->printBuffer[*indicator] = val; in SHELL_WriteBuffer()
291 shell_context_handle_t *shellContextHandle; in SHELL_Sprintf() local
293 shellContextHandle = (shell_context_handle_t *)buffer; in SHELL_Sprintf()
296 shellContextHandle->printLength += length; in SHELL_Sprintf()
307 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)param; in SHELL_Task() local
309 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Task()
313 if (NULL != shellContextHandle) in SHELL_Task()
318 shellContextHandle->notificationPost = 0U; in SHELL_Task()
319 if (shellContextHandle->taskBusy > 0U) in SHELL_Task()
324 shellContextHandle->taskBusy = 1U; in SHELL_Task()
336 …if (KOSA_StatusSuccess == OSA_EventWait((osa_event_handle_t)shellContextHandle->event, osaEventFla… in SHELL_Task()
346 shellContextHandle->notificationPost = 0U; in SHELL_Task()
349 if ((bool)shellContextHandle->exit) in SHELL_Task()
351 if (shellContextHandle->serialReadHandle != NULL) in SHELL_Task()
353 (void)SerialManager_CloseReadHandle(shellContextHandle->serialReadHandle); in SHELL_Task()
354 shellContextHandle->serialReadHandle = NULL; in SHELL_Task()
356 if (shellContextHandle->serialWriteHandle != NULL) in SHELL_Task()
358 (void)SerialManager_CloseWriteHandle(shellContextHandle->serialWriteHandle); in SHELL_Task()
359 shellContextHandle->serialWriteHandle = NULL; in SHELL_Task()
363 if (kStatus_SHELL_Success != (shell_status_t)SHELL_GetChar(shellContextHandle, &ch)) in SHELL_Task()
372 shellContextHandle->stat = kSHELL_Special; in SHELL_Task()
375 else if (shellContextHandle->stat == kSHELL_Special) in SHELL_Task()
380 shellContextHandle->stat = kSHELL_Function; in SHELL_Task()
383 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
385 else if (shellContextHandle->stat == kSHELL_Function) in SHELL_Task()
387 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
393 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
394 … if (shellContextHandle->hist_current < (shellContextHandle->hist_count - 1U)) in SHELL_Task()
396 shellContextHandle->hist_current++; in SHELL_Task()
400 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
401 if (shellContextHandle->hist_current > 0U) in SHELL_Task()
403 shellContextHandle->hist_current--; in SHELL_Task()
407 if ((bool)shellContextHandle->c_pos) in SHELL_Task()
409 (void)SHELL_WRITEX(shellContextHandle, "\b", 1); in SHELL_Task()
410 shellContextHandle->c_pos--; in SHELL_Task()
414 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
416 (void)SHELL_WRITEX(shellContextHandle, in SHELL_Task()
417 … &shellContextHandle->line[shellContextHandle->c_pos], 1); in SHELL_Task()
418 shellContextHandle->c_pos++; in SHELL_Task()
433 for (i = 0; i < (uint32_t)shellContextHandle->c_pos; i++) in SHELL_Task()
435 (void)SHELL_WRITEX(shellContextHandle, "\b", 1); in SHELL_Task()
438 SHELL_AutoComplete(shellContextHandle); in SHELL_Task()
440 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->line); in SHELL_Task()
441 shellContextHandle->c_pos = shellContextHandle->l_pos; in SHELL_Task()
449 if (shellContextHandle->c_pos == 0U) in SHELL_Task()
454 shellContextHandle->l_pos--; in SHELL_Task()
455 shellContextHandle->c_pos--; in SHELL_Task()
457 if (shellContextHandle->l_pos > shellContextHandle->c_pos) in SHELL_Task()
459 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
460 &shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
461 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
462 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
463 (void)SHELL_WRITEX(shellContextHandle, "\b", 1); in SHELL_Task()
464 … (void)SHELL_WRITEX(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
465 … strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
466 (void)SHELL_WRITEX(shellContextHandle, " \b", 3); in SHELL_Task()
470 … for (i = (uint32_t)shellContextHandle->c_pos; i <= (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
472 (void)SHELL_WRITEX(shellContextHandle, "\b", 1); in SHELL_Task()
477 (void)SHELL_WRITEX(shellContextHandle, "\b \b", 3); in SHELL_Task()
478 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
488 if (shellContextHandle->l_pos >= (SHELL_BUFFER_SIZE - 1U)) in SHELL_Task()
490 shellContextHandle->l_pos = 0U; in SHELL_Task()
506 (void)SHELL_WRITEX(shellContextHandle, "\r\n", 2U); in SHELL_Task()
508 if (0U != strlen(shellContextHandle->line)) in SHELL_Task()
510 SHELL_ProcessCommand(shellContextHandle, shellContextHandle->line); in SHELL_Task()
513 (void)SHELL_WRITEX(shellContextHandle, shellContextHandle->prompt, in SHELL_Task()
514 strlen(shellContextHandle->prompt)); in SHELL_Task()
516 shellContextHandle->c_pos = shellContextHandle->l_pos = 0; in SHELL_Task()
517 shellContextHandle->hist_current = 0; in SHELL_Task()
518 (void)memset(shellContextHandle->line, 0, sizeof(shellContextHandle->line)); in SHELL_Task()
524 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
526 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
527 &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
528 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
529 shellContextHandle->line[shellContextHandle->c_pos] = (char)ch; in SHELL_Task()
530 … (void)SHELL_WRITEX(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
531 … strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
534 … for (i = (uint32_t)shellContextHandle->c_pos; i < (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
536 (void)SHELL_WRITEX(shellContextHandle, "\b", 1); in SHELL_Task()
541 shellContextHandle->line[shellContextHandle->l_pos] = (char)ch; in SHELL_Task()
542 … (void)SHELL_WRITEX(shellContextHandle, &shellContextHandle->line[shellContextHandle->l_pos], 1); in SHELL_Task()
546 shellContextHandle->l_pos++; in SHELL_Task()
547 shellContextHandle->c_pos++; in SHELL_Task()
548 } while (0U == shellContextHandle->exit); in SHELL_Task()
564 shellContextHandle->taskBusy = 0U; in SHELL_Task()
571 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_HelpCommand() local
573 list_element_handle_t p = LIST_GetHead(&shellContextHandle->commandContextListHead); in SHELL_HelpCommand()
580 (void)SHELL_WRITEX(shellContextHandle, shellCommandContextHandle->pcHelpString, in SHELL_HelpCommand()
591 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_ExitCommand() local
593 (void)SHELL_WRITEX(shellContextHandle, "\r\nSHELL exited\r\n", strlen("\r\nSHELL exited\r\n")); in SHELL_ExitCommand()
594 shellContextHandle->exit = (uint8_t) true; in SHELL_ExitCommand()
598 static void SHELL_ProcessCommand(shell_context_handle_t *shellContextHandle, const char *cmd) in SHELL_ProcessCommand() argument
615 p = LIST_GetHead(&shellContextHandle->commandContextListHead); in SHELL_ProcessCommand()
660 shellContextHandle, in SHELL_ProcessCommand()
669 …if (tmpLen != (uint8_t)SHELL_StringCompare(cmd, shellContextHandle->hist_buf[0], (int32_t)strlen(c… in SHELL_ProcessCommand()
673 (void)memset(shellContextHandle->hist_buf[i], (int)'\0', SHELL_BUFFER_SIZE); in SHELL_ProcessCommand()
674 tmpLen = (uint8_t)strlen(shellContextHandle->hist_buf[i - 1U]); in SHELL_ProcessCommand()
675 … (void)memcpy(shellContextHandle->hist_buf[i], shellContextHandle->hist_buf[i - 1U], tmpLen); in SHELL_ProcessCommand()
677 (void)memset(shellContextHandle->hist_buf[0], (int)'\0', SHELL_BUFFER_SIZE); in SHELL_ProcessCommand()
679 (void)memcpy(shellContextHandle->hist_buf[0], cmd, tmpLen); in SHELL_ProcessCommand()
680 if (shellContextHandle->hist_count < SHELL_HISTORY_COUNT) in SHELL_ProcessCommand()
682 shellContextHandle->hist_count++; in SHELL_ProcessCommand()
685 (void)tmpCommand->pFuncCallBack(shellContextHandle, argc, argv); in SHELL_ProcessCommand()
690 shellContextHandle, in SHELL_ProcessCommand()
696 static void SHELL_GetHistoryCommand(shell_context_handle_t *shellContextHandle, uint8_t hist_pos) in SHELL_GetHistoryCommand() argument
701 if (shellContextHandle->hist_buf[0][0] == '\0') in SHELL_GetHistoryCommand()
703 shellContextHandle->hist_current = 0; in SHELL_GetHistoryCommand()
715 tmp = strlen(shellContextHandle->line); in SHELL_GetHistoryCommand()
719 (void)memset(shellContextHandle->line, (int)'\0', tmp); in SHELL_GetHistoryCommand()
722 (void)SHELL_WRITEX(shellContextHandle, "\b \b", 3); in SHELL_GetHistoryCommand()
726 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->hist_buf[hist_pos]); in SHELL_GetHistoryCommand()
727 shellContextHandle->c_pos = shellContextHandle->l_pos; in SHELL_GetHistoryCommand()
728 …(void)memcpy(shellContextHandle->line, shellContextHandle->hist_buf[hist_pos], shellContextHandle-… in SHELL_GetHistoryCommand()
729 (void)SHELL_WRITEX(shellContextHandle, shellContextHandle->hist_buf[hist_pos], in SHELL_GetHistoryCommand()
730 strlen(shellContextHandle->hist_buf[hist_pos])); in SHELL_GetHistoryCommand()
733 static void SHELL_AutoComplete(shell_context_handle_t *shellContextHandle) in SHELL_AutoComplete() argument
745 if (shellContextHandle->line[0] == '\0') in SHELL_AutoComplete()
747 (void)SHELL_HelpCommand(shellContextHandle, 0, NULL); in SHELL_AutoComplete()
751 (void)SHELL_WRITEX(shellContextHandle, "\r\n", 2); in SHELL_AutoComplete()
754 p = LIST_GetHead(&shellContextHandle->commandContextListHead); in SHELL_AutoComplete()
759 …if (SHELL_StringCompare(shellContextHandle->line, cmdName, (int32_t)strlen(shellContextHandle->lin… in SHELL_AutoComplete()
762 (void)SHELL_Printf(shellContextHandle, "%s ", cmdName); in SHELL_AutoComplete()
774 (void)memcpy(shellContextHandle->line, namePtr, (uint32_t)minLen); in SHELL_AutoComplete()
776 SHELL_PrintPrompt(shellContextHandle); in SHELL_AutoComplete()
777 …(void)SHELL_WRITEX(shellContextHandle, shellContextHandle->line, strlen(shellContextHandle->line)); in SHELL_AutoComplete()
854 static shell_status_t SHELL_GetChar(shell_context_handle_t *shellContextHandle, uint8_t *ch) in SHELL_GetChar() argument
859 if (NULL == shellContextHandle->serialHandle) in SHELL_GetChar()
879 (void)SerialManager_TryRead(shellContextHandle->serialReadHandle, ch, 1, &length); in SHELL_GetChar()
890 … status = (shell_status_t)SerialManager_ReadBlocking(shellContextHandle->serialReadHandle, ch, 1); in SHELL_GetChar()
899 shell_context_handle_t *shellContextHandle; in SHELL_Init() local
910 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Init()
929 … if (KOSA_StatusSuccess != OSA_EventCreate((osa_event_handle_t)shellContextHandle->event, 1U)) in SHELL_Init()
935 …OSA_TaskCreate((osa_task_handle_t)shellContextHandle->taskId, OSA_TASK(SHELL_Task), shellContextHa… in SHELL_Init()
946 shellContextHandle->prompt = prompt; in SHELL_Init()
947 shellContextHandle->serialHandle = serialHandle; in SHELL_Init()
956shellContextHandle->serialWriteHandle = (serial_write_handle_t)&shellContextHandle->serialWriteHan… in SHELL_Init()
957 …status = SerialManager_OpenWriteHandle(shellContextHandle->serialHandle, shellContextHandle->seria… in SHELL_Init()
960shellContextHandle->serialReadHandle = (serial_read_handle_t)&shellContextHandle->serialReadHandle… in SHELL_Init()
961 …status = SerialManager_OpenReadHandle(shellContextHandle->serialHandle, shellContextHandle->serial… in SHELL_Init()
965 …status = SerialManager_InstallRxCallback(shellContextHandle->serialReadHandle, SHELL_SerialManager… in SHELL_Init()
966 shellContextHandle); in SHELL_Init()
972 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(help)); in SHELL_Init()
973 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(exit)); in SHELL_Init()
975 …(void)SHELL_Write(shellContextHandle, "\r\nCopyright 2020 NXP\r\n", strlen("\r\nCopyright 2020 … in SHELL_Init()
976 SHELL_PrintPrompt(shellContextHandle); in SHELL_Init()
983 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_RegisterCommand() local
990 (void)LIST_AddTail(&shellContextHandle->commandContextListHead, &shellCommand->link); in SHELL_RegisterCommand()
1009 shell_context_handle_t *shellContextHandle; in SHELL_Write() local
1021 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Write()
1024 if ((bool)shellContextHandle->printBusy) in SHELL_Write()
1029 shellContextHandle->printBusy = 1U; in SHELL_Write()
1032 if (NULL == shellContextHandle->serialHandle) in SHELL_Write()
1043 …status = (shell_status_t)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, (uint8… in SHELL_Write()
1047 shellContextHandle->printBusy = 0U; in SHELL_Write()
1054 shell_context_handle_t *shellContextHandle; in SHELL_Printf() local
1062 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Printf()
1065 if ((bool)shellContextHandle->printBusy) in SHELL_Printf()
1070 shellContextHandle->printBusy = 1U; in SHELL_Printf()
1075 shellContextHandle->printLength = 0U; in SHELL_Printf()
1078 if (NULL == shellContextHandle->serialHandle) in SHELL_Printf()
1082 (void)putchar(shellContextHandle->printBuffer[index]); in SHELL_Printf()
1088 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, in SHELL_Printf()
1089 (uint8_t *)shellContextHandle->printBuffer, length); in SHELL_Printf()
1093 shellContextHandle->printBusy = 0U; in SHELL_Printf()
1094 return (int32_t)shellContextHandle->printLength; in SHELL_Printf()
1114 shell_context_handle_t *shellContextHandle; in SHELL_PrintfSynchronization() local
1120 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_PrintfSynchronization()
1126 status = SHELL_Write(shellHandle, (const char *)shellContextHandle->printBuffer, length); in SHELL_PrintfSynchronization()
1134 shell_context_handle_t *shellContextHandle; in SHELL_ChangePrompt() local
1138 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_ChangePrompt()
1140 shellContextHandle->prompt = prompt; in SHELL_ChangePrompt()
1141 SHELL_PrintPrompt(shellContextHandle); in SHELL_ChangePrompt()
1146 shell_context_handle_t *shellContextHandle; in SHELL_PrintPrompt() local
1149 shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_PrintPrompt()
1151 (void)SHELL_Write(shellContextHandle, "\r\n", 2U); in SHELL_PrintPrompt()
1152 …(void)SHELL_Write(shellContextHandle, shellContextHandle->prompt, strlen(shellContextHandle->promp… in SHELL_PrintPrompt()