dbc.c

来自「基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7」· C语言 代码 · 共 1,633 行 · 第 1/5 页

C
1,633
字号
    
    /* Print a readable time_slice status.  */
    if (time_slice == 0)
        
        /* No time slice.  */
        DBT_String_Cat(Line_Pointers[5],"DISABLED ");
    
    else
    {
        /*sprintf(Output_Line,"%8u ", (UNSIGNED) time_slice);*/
        NU_ULTOA((UNSIGNED) time_slice, temp, 10);
        n = strlen(temp);
        
        if (n >= 8)
            strcpy(Output_Line, temp);
        else
        {
            Output_Line[0] = 0;
            for (i=0; i<(8-n);i++)
                strcat(Output_Line, " ");
            strcat(Output_Line, temp);
        }
        strcat(Output_Line, " ");
        
        DBT_String_Cat(Line_Pointers[5], Output_Line);
    }
    
    /* sprintf(Output_Line,"%08lX ", (UNSIGNED) stack_base);*/
    NU_ITOA((INT) stack_base, temp, 16);
    n = strlen(temp);
    
    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    DBT_String_Cat(Line_Pointers[6], Output_Line);
    
    /* sprintf(Output_Line,"%8u ", (UNSIGNED) stack_size);*/
    NU_ULTOA((UNSIGNED) stack_size, temp, 10);
    n = strlen(temp);
    
    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    DBT_String_Cat(Line_Pointers[7], Output_Line);
    
    /* sprintf(Output_Line,"%8u ", (UNSIGNED) minimum_stack);*/
    NU_ULTOA((UNSIGNED) minimum_stack, temp, 10);
    n = strlen(temp);
    
    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    DBT_String_Cat(Line_Pointers[8], Output_Line);
    
} /* DBC_Task_Information */

/************************************************************************
*                                                                       
*  FUNCTION                                
*
*       DBC_Mailbox_Fields                                                              
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       This routine prints out the mailbox fields.                      
*                                                                       
*   INPUTS                                                                
*                                                                       
*       None
*                                                                       
*   OUTPUTS                                                               
*                                                                       
*       None                                                             
*                                                                       
************************************************************************/
VOID  DBC_Mailbox_Fields(VOID)
{
    
    /* Initialize the various output lines.  */
    /*sprintf(Line_Pointers[0],"Mailbox Name:       ");
    sprintf(Line_Pointers[1],"Suspend Type:       ");
    sprintf(Line_Pointers[2],"Message Present:    ");
    sprintf(Line_Pointers[3],"Tasks Waiting:      ");
    sprintf(Line_Pointers[4],"First Task Waiting: "); */
    strcpy(Line_Pointers[0],"Mailbox Name:       ");
    strcpy(Line_Pointers[1],"Suspend Type:       ");
    strcpy(Line_Pointers[2],"Message Present:    ");
    strcpy(Line_Pointers[3],"Tasks Waiting:      ");
    strcpy(Line_Pointers[4],"First Task Waiting: ");
}

/************************************************************************
*                                                                       
*   FUNCTION                                
*
*       DBC_Mailbox_Information                                                               
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       This routine prints out the mailbox Information.                 
*                                                                       
*   INPUTS                                                                
*                                                                       
*       counter     Current count                
*                                                                       
*   OUTPUTS                                                               
*                                                                       
*       None                                                             
*                                                                       
************************************************************************/
VOID DBC_Mailbox_Information(INT counter)
{
    INT             k;
    CHAR            name[9];                          /* Mailbox Name       */
    OPTION          suspend_type;                     /* Mbox suspend type  */
    DATA_ELEMENT    message_present;                  /* Message present    */
    UNSIGNED        tasks_waiting;                    /* Scheduled count    */
    NU_TASK         *first_task;                      /* First task waiting */
    CHAR            temp[20];                   /* temp buffer for sprintf */    
    INT             n, i;
    
    /* Get information */
    NU_Mailbox_Information(DBC_List[counter], name, &suspend_type,
        &message_present, &tasks_waiting,
        &first_task);
    
    /* NUL terminate name */
    name[8] = NUL;
    
    /* Build the Mailbox's fields.  */
    /* sprintf(Output_Line,"%8s ", name); */
    n = strlen(name);
    if (n>=8)
    {
        strcpy(Output_Line, name);
        strcat(Output_Line, " ");
    }
    else
    {
        Output_Line[0] = 0;
        for (i=0;i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, name);
        strcat(Output_Line, " ");
    }
    
    DBT_String_Cat(Line_Pointers[0], Output_Line);
    
    /* Print a readable suspend status.  */
    switch (suspend_type)
    {
        
    case    NU_FIFO:
        
        /* Mailbox is FIFO.  */
        DBT_String_Cat(Line_Pointers[1],"    FIFO ");
        break;
        
    case    NU_PRIORITY:
        
        /* Mailbox is PRIORITY.  */
        DBT_String_Cat(Line_Pointers[1],"PRIORITY ");
        break;
        
    default:
        
        /* sprintf(Output_Line,"%8u ", (UNSIGNED) suspend_type);*/
        NU_ULTOA((UNSIGNED) suspend_type, temp, 10);
        n = strlen(temp);
        
        if (n >= 8)
            strcpy(Output_Line, temp);
        else
        {
            Output_Line[0] = 0;
            for (i=0; i<(8-n);i++)
                strcat(Output_Line, " ");
            strcat(Output_Line, temp);
        }
        strcat(Output_Line, " ");
        
        DBT_String_Cat(Line_Pointers[1], Output_Line);
        break;
    }
    
    switch (message_present)
    {
        
    case    NU_TRUE:
        
        /* Mailbox has message.  */
        DBT_String_Cat(Line_Pointers[2],"     YES ");
        break;
        
    case    NU_FALSE:
        
        /* Mailbox doesn't have message.  */
        DBT_String_Cat(Line_Pointers[2],"      NO ");
        break;
        
    default:
        
        /* sprintf(Output_Line,"%8u ", (UNSIGNED) message_present); */
        NU_ULTOA((UNSIGNED) message_present, temp, 10);
        n = strlen(temp);
        
        if (n >= 8)
            strcpy(Output_Line, temp);
        else
        {
            Output_Line[0] = 0;
            for (i=0; i<(8-n);i++)
                strcat(Output_Line, " ");
            strcat(Output_Line, temp);
        }
        strcat(Output_Line, " ");
        
        DBT_String_Cat(Line_Pointers[2], Output_Line);
    }
    
    /* sprintf(Output_Line,"%8u ", (UNSIGNED) tasks_waiting); */
    NU_ULTOA((UNSIGNED) tasks_waiting, temp, 10);
    n = strlen(temp);
    
    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    DBT_String_Cat(Line_Pointers[3], Output_Line);
    
    /* Check for task waiting */
    if (first_task == NUL)
        DBT_String_Cat(Line_Pointers[4],"    NONE ");
    
    else
    {
        for (k = 0; k < 8; k++)
        {
            name[k] = ((TC_TCB *) first_task)->tc_name[k];
        }
        name[8] = NUL;
        /* sprintf(Output_Line,"%8s ", name); */
        n = strlen(name);
        if (n>=8)
        {
            strcpy(Output_Line, name);
            strcat(Output_Line, " ");
        }
        else
        {
            Output_Line[0] = 0;
            for (i=0;i<(8-n);i++)
                strcat(Output_Line, " ");
            strcat(Output_Line, name);
            strcat(Output_Line, " ");
        }
        DBT_String_Cat(Line_Pointers[4], Output_Line);
    }
} /* DBC_Mailbox_Information */

/************************************************************************
*                                                                       
*   FUNCTION
*
*       DBC_Queue_Fields                                               
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       This routine prints out the queue fields.                        
*                                                                       
*   INPUTS                                                                
*       
*       None                                                                
*                                                                       
*   OUTPUTS                                                               
*                                                                       
*       None                                                             
*                                                                       
************************************************************************/
VOID  DBC_Queue_Fields(VOID)
{
    /* Initialize the various output lines.  */
    /*sprintf(Line_Pointers[0],"Queue Name:         ");
    sprintf(Line_Pointers[1],"Start Address:      ");
    sprintf(Line_Pointers[2],"Queue Size:         ");
    sprintf(Line_Pointers[3],"Available:          ");
    sprintf(Line_Pointers[4],"Messages:           ");
    sprintf(Line_Pointers[5],"Message Type:       ");
    sprintf(Line_Pointers[6],"Message Size:       ");
    sprintf(Line_Pointers[7],"Suspend Type:       ");
    sprintf(Line_Pointers[8],"Tasks Waiting:      ");
    sprintf(Line_Pointers[9],"First Task Waiting: "); */
    strcpy(Line_Pointers[0],"Queue Name:         ");
    strcpy(Line_Pointers[1],"Start Address:      

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?