/************************************************************************* $Archive: /PACS/OnBoard/error.c $ $Revision: 1.11 $ $Date: 2009/04/23 13:51:12 $ $Author: amazy $ $Log: error.c,v $ Revision 1.11 2009/04/23 13:51:12 amazy 6.029 * * 14 3/14/06 4:31p Pacs Egse * Version 6.001 * Cleaned and commented *************************************************************************/ #ifdef SIMULATOR #include "virtuosoSim.h" #else // SIMULATOR #include "v_macro.h" #include "node1.h" #include "k_struct.h" #endif #include "error.h" #include "params.h" #include "u_res.h" #define SIZE_OF_LAST_ERRORS_BUFFER 16 //array containing the last 16 errors that have occured in the software int gaLastErrorsBuffer[SIZE_OF_LAST_ERRORS_BUFFER] = { NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE }; int gLastErrorsBufferIndex = 0; /* FUNCTION : int AddErrorInBuffer(void* p_lastError) ************************************************** AUTHOR : AMazy USE : Store errors in a circular buffer so we can have an history of errors generation. This function is called in the macros "SetError" of each task PARAM : int* p_lastError : a pointer on an error code (only 16 bits are used) NOTE : This function shall always be called inside a critical section. */ int AddErrorInBuffer(void* p_lastError) { // copy the error code at the right location gaLastErrorsBuffer[gLastErrorsBufferIndex] = *(int*)p_lastError; gLastErrorsBufferIndex = (gLastErrorsBufferIndex+1) % SIZE_OF_LAST_ERRORS_BUFFER; LOCK_WRITE_RES_PARAMS; SET_BITS(gParameters.GlobalStatus, K_BMASK_TASK_STATUS_ERROR_STATUS | K_BMASK_TASK_STATUS_ERROR_CODE, *(int*)p_lastError | K_BMASK_OBS_STATUS_ANY_ERROR_IN_OBS); UNLOCK_WRITE_RES_PARAMS; return gLastErrorsBufferIndex; };