Lines Matching refs:shellContextHandle
151 static void SHELL_ProcessCommand(shell_context_handle_t *shellContextHandle, const char *cmd); /*!<…
153 static void SHELL_GetHistoryCommand(shell_context_handle_t *shellContextHandle,
156 static void SHELL_AutoComplete(shell_context_handle_t *shellContextHandle); /*!< auto complete comm…
158 static shell_status_t SHELL_GetChar(shell_context_handle_t *shellContextHandle,
225 shell_context_handle_t *shellContextHandle; in SHELL_WriteBuffer() local
227 shellContextHandle = (shell_context_handle_t *)(void *)buffer; in SHELL_WriteBuffer()
234 if (NULL == shellContextHandle->serialHandle) in SHELL_WriteBuffer()
238 (void)putchar(shellContextHandle->printBuffer[index]); in SHELL_WriteBuffer()
244 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, in SHELL_WriteBuffer()
245 … (uint8_t *)shellContextHandle->printBuffer, (uint32_t)*indicator); in SHELL_WriteBuffer()
248 shellContextHandle->printLength += (uint32_t)*indicator; in SHELL_WriteBuffer()
252 shellContextHandle->printBuffer[*indicator] = val; in SHELL_WriteBuffer()
259 shell_context_handle_t *shellContextHandle; in SHELL_Sprintf() local
261 shellContextHandle = (shell_context_handle_t *)buffer; in SHELL_Sprintf()
264 shellContextHandle->printLength += length; in SHELL_Sprintf()
275 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)param; in SHELL_Task() local
277 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Task()
281 if (NULL != shellContextHandle) in SHELL_Task()
293 …if (KOSA_StatusSuccess == OSA_EventWait((osa_event_handle_t)shellContextHandle->event, osaEventFla… in SHELL_Task()
303 shellContextHandle->notificationPost = 0; in SHELL_Task()
306 if ((bool)shellContextHandle->exit) in SHELL_Task()
308 if (shellContextHandle->serialReadHandle != NULL) in SHELL_Task()
310 (void)SerialManager_CloseReadHandle(shellContextHandle->serialReadHandle); in SHELL_Task()
311 shellContextHandle->serialReadHandle = NULL; in SHELL_Task()
313 if (shellContextHandle->serialWriteHandle != NULL) in SHELL_Task()
315 (void)SerialManager_CloseWriteHandle(shellContextHandle->serialWriteHandle); in SHELL_Task()
316 shellContextHandle->serialWriteHandle = NULL; in SHELL_Task()
320 if (kStatus_SHELL_Success != (shell_status_t)SHELL_GetChar(shellContextHandle, &ch)) in SHELL_Task()
329 shellContextHandle->stat = kSHELL_Special; in SHELL_Task()
332 else if (shellContextHandle->stat == kSHELL_Special) in SHELL_Task()
337 shellContextHandle->stat = kSHELL_Function; in SHELL_Task()
340 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
342 else if (shellContextHandle->stat == kSHELL_Function) in SHELL_Task()
344 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
350 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
351 … if (shellContextHandle->hist_current < (shellContextHandle->hist_count - 1U)) in SHELL_Task()
353 shellContextHandle->hist_current++; in SHELL_Task()
357 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
358 if (shellContextHandle->hist_current > 0U) in SHELL_Task()
360 shellContextHandle->hist_current--; in SHELL_Task()
364 if ((bool)shellContextHandle->c_pos) in SHELL_Task()
366 SHELL_WriteWithCopy(shellContextHandle, "\b", 1); in SHELL_Task()
367 shellContextHandle->c_pos--; in SHELL_Task()
371 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
373 (void)SHELL_Write(shellContextHandle, in SHELL_Task()
374 … &shellContextHandle->line[shellContextHandle->c_pos], 1); in SHELL_Task()
375 shellContextHandle->c_pos++; in SHELL_Task()
390 for (i = 0; i < (uint32_t)shellContextHandle->c_pos; i++) in SHELL_Task()
392 SHELL_WriteWithCopy(shellContextHandle, "\b", 1); in SHELL_Task()
395 SHELL_AutoComplete(shellContextHandle); in SHELL_Task()
397 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->line); in SHELL_Task()
398 shellContextHandle->c_pos = shellContextHandle->l_pos; in SHELL_Task()
406 if (shellContextHandle->c_pos == 0U) in SHELL_Task()
411 shellContextHandle->l_pos--; in SHELL_Task()
412 shellContextHandle->c_pos--; in SHELL_Task()
414 if (shellContextHandle->l_pos > shellContextHandle->c_pos) in SHELL_Task()
416 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
417 &shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
418 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
419 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
420 SHELL_WriteWithCopy(shellContextHandle, "\b", 1); in SHELL_Task()
421 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
422 … strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
423 SHELL_WriteWithCopy(shellContextHandle, " \b", 3); in SHELL_Task()
427 … for (i = (uint32_t)shellContextHandle->c_pos; i <= (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
429 SHELL_WriteWithCopy(shellContextHandle, "\b", 1); in SHELL_Task()
434 SHELL_WriteWithCopy(shellContextHandle, "\b \b", 3); in SHELL_Task()
435 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
445 if (shellContextHandle->l_pos >= (SHELL_BUFFER_SIZE - 1U)) in SHELL_Task()
447 shellContextHandle->l_pos = 0U; in SHELL_Task()
463 … SHELL_WriteWithCopy(shellContextHandle, "\r\n", 2U); /* MISRA C-2012 Rule 7.4 */ in SHELL_Task()
465 if (0U != strlen(shellContextHandle->line)) in SHELL_Task()
467 SHELL_ProcessCommand(shellContextHandle, shellContextHandle->line); in SHELL_Task()
470 (void)SHELL_Write(shellContextHandle, shellContextHandle->prompt, in SHELL_Task()
471 strlen(shellContextHandle->prompt)); in SHELL_Task()
473 shellContextHandle->c_pos = shellContextHandle->l_pos = 0; in SHELL_Task()
474 shellContextHandle->hist_current = 0; in SHELL_Task()
475 (void)memset(shellContextHandle->line, 0, sizeof(shellContextHandle->line)); in SHELL_Task()
481 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
483 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
484 &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
485 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
486 shellContextHandle->line[shellContextHandle->c_pos] = (char)ch; in SHELL_Task()
487 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
488 strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
491 … for (i = (uint32_t)shellContextHandle->c_pos; i < (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
493 SHELL_WriteWithCopy(shellContextHandle, "\b", 1); in SHELL_Task()
498 shellContextHandle->line[shellContextHandle->l_pos] = (char)ch; in SHELL_Task()
499 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->l_pos], 1); in SHELL_Task()
503 shellContextHandle->l_pos++; in SHELL_Task()
504 shellContextHandle->c_pos++; in SHELL_Task()
505 } while (0U == shellContextHandle->exit); in SHELL_Task()
525 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
527 list_element_handle_t p = LIST_GetHead(&shellContextHandle->commandContextListHead);
534 (void)SHELL_Write(shellContextHandle, shellCommandContextHandle->pcHelpString,
545 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
547 SHELL_WriteWithCopy(shellContextHandle, "\r\nSHELL exited\r\n", strlen("\r\nSHELL exited\r\n"));
548 shellContextHandle->exit = (uint8_t) true;
552 static void SHELL_ProcessCommand(shell_context_handle_t *shellContextHandle, const char *cmd)
569 p = LIST_GetHead(&shellContextHandle->commandContextListHead);
614 shellContextHandle,
623 …if (tmpLen != (uint8_t)SHELL_StringCompare(cmd, shellContextHandle->hist_buf[0], (int32_t)strlen(c…
627 (void)memset(shellContextHandle->hist_buf[i], (int)'\0', SHELL_BUFFER_SIZE);
628 tmpLen = (uint8_t)strlen(shellContextHandle->hist_buf[i - 1U]);
629 … (void)memcpy(shellContextHandle->hist_buf[i], shellContextHandle->hist_buf[i - 1U], tmpLen);
631 (void)memset(shellContextHandle->hist_buf[0], (int)'\0', SHELL_BUFFER_SIZE);
633 (void)memcpy(shellContextHandle->hist_buf[0], cmd, tmpLen);
634 if (shellContextHandle->hist_count < SHELL_HISTORY_COUNT)
636 shellContextHandle->hist_count++;
639 (void)tmpCommand->pFuncCallBack(shellContextHandle, argc, argv);
644 shellContextHandle,
650 static void SHELL_GetHistoryCommand(shell_context_handle_t *shellContextHandle, uint8_t hist_pos)
655 if (shellContextHandle->hist_buf[0][0] == '\0')
657 shellContextHandle->hist_current = 0;
669 tmp = strlen(shellContextHandle->line);
673 (void)memset(shellContextHandle->line, (int)'\0', tmp);
676 SHELL_WriteWithCopy(shellContextHandle, "\b \b", 3);
680 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->hist_buf[hist_pos]);
681 shellContextHandle->c_pos = shellContextHandle->l_pos;
682 …(void)memcpy(shellContextHandle->line, shellContextHandle->hist_buf[hist_pos], shellContextHandle-…
683 (void)SHELL_Write(shellContextHandle, shellContextHandle->hist_buf[hist_pos],
684 strlen(shellContextHandle->hist_buf[hist_pos]));
687 static void SHELL_AutoComplete(shell_context_handle_t *shellContextHandle)
699 if (shellContextHandle->line[0] == '\0')
701 (void)SHELL_HelpCommand(shellContextHandle, 0, NULL);
705 SHELL_WriteWithCopy(shellContextHandle, "\r\n", 2);
708 p = LIST_GetHead(&shellContextHandle->commandContextListHead);
713 …if (SHELL_StringCompare(shellContextHandle->line, cmdName, (int32_t)strlen(shellContextHandle->lin…
716 (void)SHELL_Printf(shellContextHandle, "%s ", cmdName);
728 (void)memcpy(shellContextHandle->line, namePtr, (uint32_t)minLen);
730 SHELL_PrintPrompt(shellContextHandle);
731 … (void)SHELL_Write(shellContextHandle, shellContextHandle->line, strlen(shellContextHandle->line));
808 static shell_status_t SHELL_GetChar(shell_context_handle_t *shellContextHandle, uint8_t *ch)
813 if (NULL == shellContextHandle->serialHandle)
833 (void)SerialManager_TryRead(shellContextHandle->serialReadHandle, ch, 1, &length);
844 … status = (shell_status_t)SerialManager_ReadBlocking(shellContextHandle->serialReadHandle, ch, 1);
853 shell_context_handle_t *shellContextHandle;
864 shellContextHandle = (shell_context_handle_t *)shellHandle;
883 … if (KOSA_StatusSuccess != OSA_EventCreate((osa_event_handle_t)shellContextHandle->event, 1U))
889 …OSA_TaskCreate((osa_task_handle_t)shellContextHandle->taskId, OSA_TASK(SHELL_Task), shellContextHa…
900 shellContextHandle->prompt = prompt;
901 shellContextHandle->serialHandle = serialHandle;
910 …shellContextHandle->serialWriteHandle = (serial_write_handle_t)&shellContextHandle->serialWriteHan…
911 …status = SerialManager_OpenWriteHandle(shellContextHandle->serialHandle, shellContextHandle->seria…
914 …shellContextHandle->serialReadHandle = (serial_read_handle_t)&shellContextHandle->serialReadHandle…
915 …status = SerialManager_OpenReadHandle(shellContextHandle->serialHandle, shellContextHandle->serial…
919 …status = SerialManager_InstallRxCallback(shellContextHandle->serialReadHandle, SHELL_SerialManager…
920 shellContextHandle);
926 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(help));
927 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(exit));
929 SHELL_WriteWithCopy(shellContextHandle, "\r\nSHELL build: ", strlen("\r\nSHELL build: "));
930 SHELL_WriteWithCopy(shellContextHandle, __DATE__, strlen(__DATE__));
931 …SHELL_WriteWithCopy(shellContextHandle, "\r\nCopyright 2020 NXP\r\n", strlen("\r\nCopyright 202…
932 SHELL_PrintPrompt(shellContextHandle);
939 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
946 (void)LIST_AddTail(&shellContextHandle->commandContextListHead, &shellCommand->link);
965 shell_context_handle_t *shellContextHandle;
977 shellContextHandle = (shell_context_handle_t *)shellHandle;
980 if ((bool)shellContextHandle->printBusy)
985 shellContextHandle->printBusy = 1U;
988 if (NULL == shellContextHandle->serialHandle)
999 …status = (shell_status_t)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, (uint8…
1003 shellContextHandle->printBusy = 0U;
1021 shell_context_handle_t *shellContextHandle;
1029 shellContextHandle = (shell_context_handle_t *)shellHandle;
1032 if ((bool)shellContextHandle->printBusy)
1037 shellContextHandle->printBusy = 1U;
1042 shellContextHandle->printLength = 0U;
1045 if (NULL == shellContextHandle->serialHandle)
1049 (void)putchar(shellContextHandle->printBuffer[index]);
1055 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle,
1056 (uint8_t *)shellContextHandle->printBuffer, length);
1060 shellContextHandle->printBusy = 0U;
1061 return (int32_t)shellContextHandle->printLength;
1066 shell_context_handle_t *shellContextHandle;
1070 shellContextHandle = (shell_context_handle_t *)shellHandle;
1072 shellContextHandle->prompt = prompt;
1073 SHELL_PrintPrompt(shellContextHandle);
1078 shell_context_handle_t *shellContextHandle;
1081 shellContextHandle = (shell_context_handle_t *)shellHandle;
1083 SHELL_WriteWithCopy(shellContextHandle, "\r\n", 2U); /* MISRA C-2012 Rule 7.4 */
1084 …(void)SHELL_Write(shellContextHandle, shellContextHandle->prompt, strlen(shellContextHandle->promp…