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,
223 shell_context_handle_t *shellContextHandle; in SHELL_WriteBuffer() local
225 shellContextHandle = (shell_context_handle_t *)(void *)buffer; in SHELL_WriteBuffer()
232 if (NULL == shellContextHandle->serialHandle) in SHELL_WriteBuffer()
236 (void)putchar(shellContextHandle->printBuffer[index]); in SHELL_WriteBuffer()
242 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, in SHELL_WriteBuffer()
243 … (uint8_t *)shellContextHandle->printBuffer, (uint32_t)*indicator); in SHELL_WriteBuffer()
246 shellContextHandle->printLength += (uint32_t)*indicator; in SHELL_WriteBuffer()
250 shellContextHandle->printBuffer[*indicator] = val; in SHELL_WriteBuffer()
257 shell_context_handle_t *shellContextHandle; in SHELL_Sprintf() local
259 shellContextHandle = (shell_context_handle_t *)buffer; in SHELL_Sprintf()
262 shellContextHandle->printLength += length; in SHELL_Sprintf()
273 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)param; in SHELL_Task() local
275 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle; in SHELL_Task()
279 if (NULL != shellContextHandle) in SHELL_Task()
291 …if (KOSA_StatusSuccess == OSA_EventWait((osa_event_handle_t)shellContextHandle->event, osaEventFla… in SHELL_Task()
301 shellContextHandle->notificationPost = 0; in SHELL_Task()
304 if ((bool)shellContextHandle->exit) in SHELL_Task()
306 if (shellContextHandle->serialReadHandle != NULL) in SHELL_Task()
308 (void)SerialManager_CloseReadHandle(shellContextHandle->serialReadHandle); in SHELL_Task()
309 shellContextHandle->serialReadHandle = NULL; in SHELL_Task()
311 if (shellContextHandle->serialWriteHandle != NULL) in SHELL_Task()
313 (void)SerialManager_CloseWriteHandle(shellContextHandle->serialWriteHandle); in SHELL_Task()
314 shellContextHandle->serialWriteHandle = NULL; in SHELL_Task()
318 if (kStatus_SHELL_Success != (shell_status_t)SHELL_GetChar(shellContextHandle, &ch)) in SHELL_Task()
327 shellContextHandle->stat = kSHELL_Special; in SHELL_Task()
330 else if (shellContextHandle->stat == kSHELL_Special) in SHELL_Task()
335 shellContextHandle->stat = kSHELL_Function; in SHELL_Task()
338 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
340 else if (shellContextHandle->stat == kSHELL_Function) in SHELL_Task()
342 shellContextHandle->stat = kSHELL_Normal; in SHELL_Task()
348 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
349 … if (shellContextHandle->hist_current < (shellContextHandle->hist_count - 1U)) in SHELL_Task()
351 shellContextHandle->hist_current++; in SHELL_Task()
355 … SHELL_GetHistoryCommand(shellContextHandle, (uint8_t)shellContextHandle->hist_current); in SHELL_Task()
356 if (shellContextHandle->hist_current > 0U) in SHELL_Task()
358 shellContextHandle->hist_current--; in SHELL_Task()
362 if ((bool)shellContextHandle->c_pos) in SHELL_Task()
364 (void)SHELL_Write(shellContextHandle, "\b", 1); in SHELL_Task()
365 shellContextHandle->c_pos--; in SHELL_Task()
369 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
371 (void)SHELL_Write(shellContextHandle, in SHELL_Task()
372 … &shellContextHandle->line[shellContextHandle->c_pos], 1); in SHELL_Task()
373 shellContextHandle->c_pos++; in SHELL_Task()
388 for (i = 0; i < (uint32_t)shellContextHandle->c_pos; i++) in SHELL_Task()
390 (void)SHELL_Write(shellContextHandle, "\b", 1); in SHELL_Task()
393 SHELL_AutoComplete(shellContextHandle); in SHELL_Task()
395 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->line); in SHELL_Task()
396 shellContextHandle->c_pos = shellContextHandle->l_pos; in SHELL_Task()
404 if (shellContextHandle->c_pos == 0U) in SHELL_Task()
409 shellContextHandle->l_pos--; in SHELL_Task()
410 shellContextHandle->c_pos--; in SHELL_Task()
412 if (shellContextHandle->l_pos > shellContextHandle->c_pos) in SHELL_Task()
414 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
415 &shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
416 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
417 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
418 (void)SHELL_Write(shellContextHandle, "\b", 1); in SHELL_Task()
419 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
420 … strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
421 (void)SHELL_Write(shellContextHandle, " \b", 3); in SHELL_Task()
425 … for (i = (uint32_t)shellContextHandle->c_pos; i <= (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
427 (void)SHELL_Write(shellContextHandle, "\b", 1); in SHELL_Task()
432 (void)SHELL_Write(shellContextHandle, "\b \b", 3); in SHELL_Task()
433 shellContextHandle->line[shellContextHandle->l_pos] = '\0'; in SHELL_Task()
443 if (shellContextHandle->l_pos >= (SHELL_BUFFER_SIZE - 1U)) in SHELL_Task()
445 shellContextHandle->l_pos = 0U; in SHELL_Task()
461 (void)SHELL_Write(shellContextHandle, "\r\n", 2U); in SHELL_Task()
463 if (0U != strlen(shellContextHandle->line)) in SHELL_Task()
465 SHELL_ProcessCommand(shellContextHandle, shellContextHandle->line); in SHELL_Task()
468 (void)SHELL_Write(shellContextHandle, shellContextHandle->prompt, in SHELL_Task()
469 strlen(shellContextHandle->prompt)); in SHELL_Task()
471 shellContextHandle->c_pos = shellContextHandle->l_pos = 0; in SHELL_Task()
472 shellContextHandle->hist_current = 0; in SHELL_Task()
473 (void)memset(shellContextHandle->line, 0, sizeof(shellContextHandle->line)); in SHELL_Task()
479 if (shellContextHandle->c_pos < shellContextHandle->l_pos) in SHELL_Task()
481 (void)memmove(&shellContextHandle->line[shellContextHandle->c_pos + 1U], in SHELL_Task()
482 &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
483 … (uint32_t)shellContextHandle->l_pos - (uint32_t)shellContextHandle->c_pos); in SHELL_Task()
484 shellContextHandle->line[shellContextHandle->c_pos] = (char)ch; in SHELL_Task()
485 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->c_pos], in SHELL_Task()
486 strlen(&shellContextHandle->line[shellContextHandle->c_pos])); in SHELL_Task()
489 … for (i = (uint32_t)shellContextHandle->c_pos; i < (uint32_t)shellContextHandle->l_pos; i++) in SHELL_Task()
491 (void)SHELL_Write(shellContextHandle, "\b", 1); in SHELL_Task()
496 shellContextHandle->line[shellContextHandle->l_pos] = (char)ch; in SHELL_Task()
497 … (void)SHELL_Write(shellContextHandle, &shellContextHandle->line[shellContextHandle->l_pos], 1); in SHELL_Task()
501 shellContextHandle->l_pos++; in SHELL_Task()
502 shellContextHandle->c_pos++; in SHELL_Task()
503 } while (0U == shellContextHandle->exit); in SHELL_Task()
523 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
525 list_element_handle_t p = LIST_GetHead(&shellContextHandle->commandContextListHead);
532 (void)SHELL_Write(shellContextHandle, shellCommandContextHandle->pcHelpString,
543 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
545 (void)SHELL_Write(shellContextHandle, "\r\nSHELL exited\r\n", strlen("\r\nSHELL exited\r\n"));
546 shellContextHandle->exit = (uint8_t) true;
550 static void SHELL_ProcessCommand(shell_context_handle_t *shellContextHandle, const char *cmd)
567 p = LIST_GetHead(&shellContextHandle->commandContextListHead);
612 shellContextHandle,
621 …if (tmpLen != (uint8_t)SHELL_StringCompare(cmd, shellContextHandle->hist_buf[0], (int32_t)strlen(c…
625 (void)memset(shellContextHandle->hist_buf[i], (int)'\0', SHELL_BUFFER_SIZE);
626 tmpLen = (uint8_t)strlen(shellContextHandle->hist_buf[i - 1U]);
627 … (void)memcpy(shellContextHandle->hist_buf[i], shellContextHandle->hist_buf[i - 1U], tmpLen);
629 (void)memset(shellContextHandle->hist_buf[0], (int)'\0', SHELL_BUFFER_SIZE);
631 (void)memcpy(shellContextHandle->hist_buf[0], cmd, tmpLen);
632 if (shellContextHandle->hist_count < SHELL_HISTORY_COUNT)
634 shellContextHandle->hist_count++;
637 (void)tmpCommand->pFuncCallBack(shellContextHandle, argc, argv);
642 shellContextHandle,
648 static void SHELL_GetHistoryCommand(shell_context_handle_t *shellContextHandle, uint8_t hist_pos)
653 if (shellContextHandle->hist_buf[0][0] == '\0')
655 shellContextHandle->hist_current = 0;
667 tmp = strlen(shellContextHandle->line);
671 (void)memset(shellContextHandle->line, (int)'\0', tmp);
674 (void)SHELL_Write(shellContextHandle, "\b \b", 3);
678 shellContextHandle->l_pos = (uint8_t)strlen(shellContextHandle->hist_buf[hist_pos]);
679 shellContextHandle->c_pos = shellContextHandle->l_pos;
680 …(void)memcpy(shellContextHandle->line, shellContextHandle->hist_buf[hist_pos], shellContextHandle-…
681 (void)SHELL_Write(shellContextHandle, shellContextHandle->hist_buf[hist_pos],
682 strlen(shellContextHandle->hist_buf[hist_pos]));
685 static void SHELL_AutoComplete(shell_context_handle_t *shellContextHandle)
697 if (shellContextHandle->line[0] == '\0')
699 (void)SHELL_HelpCommand(shellContextHandle, 0, NULL);
703 (void)SHELL_Write(shellContextHandle, "\r\n", 2);
706 p = LIST_GetHead(&shellContextHandle->commandContextListHead);
711 …if (SHELL_StringCompare(shellContextHandle->line, cmdName, (int32_t)strlen(shellContextHandle->lin…
714 (void)SHELL_Printf(shellContextHandle, "%s ", cmdName);
726 (void)memcpy(shellContextHandle->line, namePtr, (uint32_t)minLen);
728 SHELL_PrintPrompt(shellContextHandle);
729 … (void)SHELL_Write(shellContextHandle, shellContextHandle->line, strlen(shellContextHandle->line));
806 static shell_status_t SHELL_GetChar(shell_context_handle_t *shellContextHandle, uint8_t *ch)
811 if (NULL == shellContextHandle->serialHandle)
831 (void)SerialManager_TryRead(shellContextHandle->serialReadHandle, ch, 1, &length);
842 … status = (shell_status_t)SerialManager_ReadBlocking(shellContextHandle->serialReadHandle, ch, 1);
851 shell_context_handle_t *shellContextHandle;
862 shellContextHandle = (shell_context_handle_t *)shellHandle;
881 … if (KOSA_StatusSuccess != OSA_EventCreate((osa_event_handle_t)shellContextHandle->event, 1U))
887 …OSA_TaskCreate((osa_task_handle_t)shellContextHandle->taskId, OSA_TASK(SHELL_Task), shellContextHa…
898 shellContextHandle->prompt = prompt;
899 shellContextHandle->serialHandle = serialHandle;
908shellContextHandle->serialWriteHandle = (serial_write_handle_t)&shellContextHandle->serialWriteHan…
909 …status = SerialManager_OpenWriteHandle(shellContextHandle->serialHandle, shellContextHandle->seria…
912shellContextHandle->serialReadHandle = (serial_read_handle_t)&shellContextHandle->serialReadHandle…
913 …status = SerialManager_OpenReadHandle(shellContextHandle->serialHandle, shellContextHandle->serial…
917 …status = SerialManager_InstallRxCallback(shellContextHandle->serialReadHandle, SHELL_SerialManager…
918 shellContextHandle);
924 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(help));
925 (void)SHELL_RegisterCommand(shellContextHandle, SHELL_COMMAND(exit));
927 …(void)SHELL_Write(shellContextHandle, "\r\nCopyright 2020 NXP\r\n", strlen("\r\nCopyright 2020 …
928 SHELL_PrintPrompt(shellContextHandle);
935 shell_context_handle_t *shellContextHandle = (shell_context_handle_t *)shellHandle;
942 (void)LIST_AddTail(&shellContextHandle->commandContextListHead, &shellCommand->link);
961 shell_context_handle_t *shellContextHandle;
973 shellContextHandle = (shell_context_handle_t *)shellHandle;
976 if ((bool)shellContextHandle->printBusy)
981 shellContextHandle->printBusy = 1U;
984 if (NULL == shellContextHandle->serialHandle)
995 …status = (shell_status_t)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle, (uint8…
999 shellContextHandle->printBusy = 0U;
1006 shell_context_handle_t *shellContextHandle;
1014 shellContextHandle = (shell_context_handle_t *)shellHandle;
1017 if ((bool)shellContextHandle->printBusy)
1022 shellContextHandle->printBusy = 1U;
1027 shellContextHandle->printLength = 0U;
1030 if (NULL == shellContextHandle->serialHandle)
1034 (void)putchar(shellContextHandle->printBuffer[index]);
1040 (void)SerialManager_WriteBlocking(shellContextHandle->serialWriteHandle,
1041 (uint8_t *)shellContextHandle->printBuffer, length);
1045 shellContextHandle->printBusy = 0U;
1046 return (int32_t)shellContextHandle->printLength;
1051 shell_context_handle_t *shellContextHandle;
1055 shellContextHandle = (shell_context_handle_t *)shellHandle;
1057 shellContextHandle->prompt = prompt;
1058 SHELL_PrintPrompt(shellContextHandle);
1063 shell_context_handle_t *shellContextHandle;
1066 shellContextHandle = (shell_context_handle_t *)shellHandle;
1068 (void)SHELL_Write(shellContextHandle, "\r\n", 2U);
1069 …(void)SHELL_Write(shellContextHandle, shellContextHandle->prompt, strlen(shellContextHandle->promp…