📄 nerrs.c
字号:
/*************************************************************************
*
* Copyright (c) 1993 - 2001 Accelerated Technology, Inc.
*
* PROPRIETARY RIGHTS of Accelerated Technology are involved in
* the subject matter of this material. All manufacturing, reproduction,
* use, and sales rights pertaining to this subject matter are governed
* by the license agreement. The recipient of this software inplicitly
* accepts the terms of the license.
*
*************************************************************************/
/*************************************************************************
*
* FILE NAME VERSION
*
* NERRS.C 4.4
*
* COMPONENT
*
* Nucleus NET error handling component.
*
* DESCRIPTION
*
* This file will hold all the Nucleus routines for the logging
* Nucleus NET errors. Other protocols/modules may also use these
* routines.
*
* DATA STRUCTURES
*
* NERRS_ERROR Holds the error information.
*
* FUNCTIONS
*
* NERRS_Log_Error
* NERRS_Clear_All_Errors
*
* DEPENDENCIES
*
* nucleus.h
* target.h
* nerrs.h
* externs.h
*
*************************************************************************/
#include "plus/nucleus.h"
#include "net/target.h"
#include "net/inc/nerrs.h"
#include "net/inc/externs.h"
/*
* This define will be used to specifie the maximum number of errorS allowed
* in the system before they roll over.
*/
#define NERRS_MAX_ERRORS 50
/* Max number of chars allowed for filename storage */
#define NERRS_MAX_FILENAME 52
/*
* This structure is used to hold the error information provided. Errors will
* be stored into any unused location, in the array. The first field in the
* structure tells us if that location is currently being used, and if not set
* will then be set and store the information into that location.
*/
typedef struct NERRS_ERROR_STRUCT
{
NU_TASK *tie_task_id;
UNSIGNED tie_err_time; /* current time which the error happend */
INT tie_line_num; /* number of the line in the file */
INT tie_err_stat; /* current status of the error, fatal, recoverable */
UINT8 tie_file [NERRS_MAX_FILENAME];/* filename in which the error was generated */
} NERRS_ERROR;
/* Index into array of errors. Points to where the next error will be stored. */
INT NERRS_Avail_Index;
/* Allocate the space for the error array */
NERRS_ERROR NERRS_Error_List [NERRS_MAX_ERRORS];
/*************************************************************************
*
* FUNCTION
*
* NERRS_Log_Error
*
* DESCRIPTION
*
* This routine will handle storing the current error number into the
* error structure. The current system time will also be stored into
* the structure. This routine will handle searching for the next
* available location, set the next location to avail, and then set
* its own location to TRUE for being used. The data will then be
* stored into the structure.
*
* INPUTS
*
* stat Status flag to store for error severity.
* *file : Pointer to the current filename in which the error
* happened.
* line : Line number in the file where the error happened.
*
* OUTPUTS
*
* Load passed in and calculated information into the
* NERRS_Error_List array, and also will update the value of the
* NERRS_Avail_Index.
*
*************************************************************************/
VOID NERRS_Log_Error (INT stat, INT8 *file, INT line)
{
INT i;
NERRS_ERROR *err_list_ptr;
#ifdef PRINT_ERROR_MSG
printf("ERROR - number: %d status: %d file: %s line: %d\n\r", err_num,
stat, file, line);
#endif
/* load the needed information into the current array location */
err_list_ptr = &NERRS_Error_List [NERRS_Avail_Index];
/* get the currently running task id */
err_list_ptr->tie_task_id = NU_Current_Task_Pointer ();
/* store the passed in status for this error */
err_list_ptr->tie_err_stat = stat;
/* store the current system time */
err_list_ptr->tie_err_time = NU_Retrieve_Clock();
/* store the passed in filename where the error occurred */
for (i = 0; ((i < NERRS_MAX_FILENAME) && (file != (INT8 *)NU_NULL)); i++)
{
err_list_ptr->tie_file [i] = (UINT8)*file++;
}
/* store the passed in line number where the error occured */
err_list_ptr->tie_line_num = line;
/* increment the global index forward and handle the wrap */
NERRS_Avail_Index = (NERRS_Avail_Index + 1) % NERRS_MAX_ERRORS;
} /* NERRS_Log_Error */
/*************************************************************************
*
* FUNCTION
*
* NERRS_Clear_All_Errors
*
* DESCRIPTION
*
* This routine will reset the NERRS_Avail_Index value back to 0,
* which will in effect, clear all the current errors from the
* NERRS_Error_List array.
*
* INPUTS
*
* None
*
* OUTPUTS
*
* Will update the value to the NERRS_Avail_Index variable.
*
*************************************************************************/
VOID NERRS_Clear_All_Errors (VOID)
{
STATUS status;
/* allocate the TCP/IP resource for blocking during this time */
status = NU_Obtain_Semaphore(&TCP_Resource, NU_SUSPEND);
if (status != NU_SUCCESS)
{
return;
}
/* clear all the error by reseting the index value */
NERRS_Avail_Index = 0;
/* deallocate the TCP/IP resource */
status = NU_Release_Semaphore(&TCP_Resource);
if (status != NU_SUCCESS)
{
return;
}
} /* NERRS_Clear_All_Errors */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -