Пример #1
0
void SQUEUE_SendString(const unsigned char *str) {
  /*! \todo Implement function */
#if PL_CONFIG_HAS_SQUEUE_SINGLE_CHAR
  while(*str!='\0') {
    if (FRTOS1_xQueueSendToBack(SQUEUE_Queue, str, 100/portTICK_RATE_MS)!=pdPASS) {
      /*for(;;){}*/ /* ups? */ /* loosing character */
    }
    str++;
  }
#else
  unsigned char *ptr;
  size_t bufSize;

  bufSize = UTIL1_strlen(str)+1;
  ptr = FRTOS1_pvPortMalloc(bufSize);
  UTIL1_strcpy(ptr, bufSize, str);
  if (FRTOS1_xQueueSendToBack(SQUEUE_Queue, &ptr, portMAX_DELAY)!=pdPASS) {
    for(;;){} /* ups? */
  }
#endif
}
static uint8_t PrintStatus( Shell_ConstStdIO_t *io )
{
#if configUSE_TRACE_FACILITY || configGENERATE_RUN_TIME_STATS /* FreeRTOS trace feature enabled */
#if configFRTOS_MEMORY_SCHEME==1 /* this scheme does not allow deallocation of memory */
    static unsigned char *taskListBufferP=NULL; /* allocated only once, never deallocated! */
#else
    unsigned char *taskListBufferP;
#endif
    size_t bufSize;
#endif
    uint8_t buf[16];

    Shell_SendStatusStr((unsigned char*) "rtos", (unsigned char*) "\r\n", io->stdOut);
#if 0 && configUSE_TRACE_FACILITY /* FreeRTOS trace feature enabled */
    Shell_SendStr((unsigned char*)"TASK LIST:\r\n", io->stdOut);
    buf[0] = '\0';
    strcatPad(buf, sizeof(buf), (const unsigned char*)"Name", ' ', configMAX_TASK_NAME_LEN);
    Shell_SendStr(buf, io->stdOut);
    Shell_SendStr((unsigned char*)"\tState\tPrio\tStack\tTCB#\r\n", io->stdOut);
    Shell_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);
    Shell_SendStr((unsigned char*)"\r\n", io->stdOut);
    /* task list and status */
    bufSize = 40*uxTaskGetNumberOfTasks(); /* about 40 bytes for a task should be enough */
#if configFRTOS_MEMORY_SCHEME==1 /* this scheme does not allow deallocation of memory */
    if (taskListBufferP==NULL) { /* only if not allocated yet */
        taskListBufferP = FRTOS1_pvPortMalloc(bufSize); /* about 40 bytes for a task should be enough */
    }
#else
    taskListBufferP = FRTOS1_pvPortMalloc(bufSize); /* about 40 bytes for a task should be enough */
#endif
    if (taskListBufferP != NULL) {
        vTaskList((char*)taskListBufferP, bufSize);
        Shell_SendStr(taskListBufferP, io->stdOut);
#if configFRTOS_MEMORY_SCHEME!=1 /* this scheme does not allow deallocation of memory */
        vPortFree(taskListBufferP);
#endif
    } else {
        Shell_SendStr((unsigned char*)"\r\n*** out of heap! ***\r\n", io->stdErr);
    }
#endif
#if ((configGENERATE_RUN_TIME_STATS==1) && (configUSE_STATS_FORMATTING_FUNCTIONS==1))
    Shell_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);
    Shell_SendStr((unsigned char*)"\r\nRTOS RUN-TIME STATISTICS:\r\n", io->stdOut);
    buf[0] = '\0';
    custom_strcatPad(buf, sizeof(buf), (const unsigned char*)"Name", ' ', configMAX_TASK_NAME_LEN);
    Shell_SendStr(buf, io->stdOut);
    Shell_SendStr((unsigned char*)"\tTime\t\t%Time\r\n", io->stdOut);
    Shell_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);
    Shell_SendStr((unsigned char*)"\r\n", io->stdOut);
    /* task list and status */
    bufSize = 40*uxTaskGetNumberOfTasks(); /* about 40 bytes for a task should be enough */
#if configFRTOS_MEMORY_SCHEME==1 /* this scheme does not allow deallocation of memory */
    if (taskListBufferP==NULL) { /* only if not allocated yet */
        taskListBufferP = FRTOS1_pvPortMalloc(bufSize);
    }
#else
    taskListBufferP = FRTOS1_pvPortMalloc(bufSize);
#endif
    if (taskListBufferP != NULL) {
        FRTOS1_vTaskGetRunTimeStats((char*)taskListBufferP, bufSize);
        Shell_SendStr(taskListBufferP, io->stdOut);
#if configFRTOS_MEMORY_SCHEME!=1 /* this scheme does not allow deallocation of memory */
        FRTOS1_vPortFree(taskListBufferP);
#endif
    } else {
        Shell_SendStr((unsigned char*)"\r\n*** out of heap! ***\r\n", io->stdErr);
    }
#endif
    Shell_SendStatusStr((unsigned char*) "  RTOS ticks", (const unsigned char*) "", io->stdOut);
    num16sToStr(buf, sizeof(buf), configTICK_RATE_HZ);
    Shell_SendStr(buf, io->stdOut);
    Shell_SendStr((unsigned char*) " Hz, ", io->stdOut);
    num16sToStr(buf, sizeof(buf), 1000 / configTICK_RATE_HZ);
    Shell_SendStr(buf, io->stdOut);
    Shell_SendStr((unsigned char*) " ms\r\n", io->stdOut);
#if configFRTOS_MEMORY_SCHEME!=3 /* wrapper to malloc() does not have xPortGetFreeHeapSize() */
    Shell_SendStatusStr((unsigned char*) "  Free heap", (const unsigned char*) "", io->stdOut);
    num32uToStr(buf, sizeof(buf), xPortGetFreeHeapSize());
    Shell_SendStr(buf, io->stdOut);
    Shell_SendStr((unsigned char*) " bytes\r\n", io->stdOut);
#endif
    return ERR_OK;
}