Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_error_hist.h Source File

mbed_error_hist.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_ERROR_HIST_H
00017 #define MBED_ERROR_HIST_H
00018 
00019 #ifndef MBED_CONF_ERROR_HIST_SIZE
00020     #define MBED_CONF_ERROR_HIST_SIZE  4
00021 #else
00022     #if MBED_CONF_ERROR_HIST_SIZE == 0
00023         #define MBED_CONF_ERROR_HIST_SIZE  1
00024     #endif    
00025 #endif
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 /*
00031  * Puts/Adds an error entry into the error history list
00032  * 
00033  * @param  error_ctx            pointer to the mbed_error_ctx struct with the error context
00034  * @return                      0 or MBED_SUCCESS on success.
00035  *                              MBED_ERROR_WRITE_FAILED if writing to file failed
00036  *                              MBED_ERROR_INVALID_ARGUMENT if path is not valid 
00037  *
00038  *
00039  */
00040 mbed_error_status_t mbed_error_hist_put(mbed_error_ctx *error_ctx);
00041     
00042 /*
00043  * Reads the error entry from the error list with the specified index
00044  * 
00045  * @param  index                Index of the error context to be retrieved. It starts from 0 and 0 is the oldest.
00046  * @param  error_ctx            pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
00047  * @return                      0 or MBED_SUCCESS on success.
00048  *                              MBED_ERROR_WRITE_FAILED if writing to file failed
00049  *                              MBED_ERROR_INVALID_ARGUMENT if path is not valid 
00050  *
00051  *
00052  */
00053 mbed_error_status_t mbed_error_hist_get(int index, mbed_error_ctx *error_ctx);
00054 
00055 /*
00056  * Gets a reference to the next error entry in the error log where in the error ctx can be filled in.
00057  * Its like reserving the next error entry to fill in the error info
00058  * 
00059  * @return                      Returns the pointer to the next error ctx entry     
00060  *
00061  *
00062  */
00063 mbed_error_ctx *mbed_error_hist_get_entry(void);
00064 
00065 /*
00066  * Reads the last(latest) error entry from the error history
00067  * 
00068  * @param  error_ctx            pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
00069  * @return                      0 or MBED_SUCCESS on success.
00070  *                              MBED_ERROR_WRITE_FAILED if writing to file failed
00071  *                              MBED_ERROR_INVALID_ARGUMENT if path is not valid 
00072  *
00073  *
00074  */
00075 mbed_error_status_t mbed_error_hist_get_last_error(mbed_error_ctx *error_ctx);
00076 
00077 /*
00078  * Returns the number of error entries in the error history list
00079  * 
00080  * @return                      Number of entries in the history list 
00081  *
00082  *
00083  */
00084 int mbed_error_hist_get_count(void);
00085 
00086 /*
00087  * Resets the error log by resetting the number of errors to 0 and clears all previous errors in the history list
00088  * 
00089  * @return                      0 or MBED_SUCCESS on success.
00090  *                              MBED_ERROR_WRITE_FAILED if writing to file failed
00091  *                              MBED_ERROR_INVALID_ARGUMENT if path is not valid 
00092  *
00093  *
00094  */
00095 mbed_error_status_t mbed_error_hist_reset(void);
00096 
00097 /*
00098  * Saves the error log information to a file
00099  * 
00100  * @param  path                 path to the file in the filesystem
00101  * @return                      0 or MBED_SUCCESS on success.
00102  *                              MBED_ERROR_WRITE_FAILED if writing to file failed
00103  *                              MBED_ERROR_INVALID_ARGUMENT if path is not valid 
00104  *
00105  * @note                        Filesystem support is required in order for this function to work.
00106  *
00107  */
00108 mbed_error_status_t mbed_save_error_hist(const char *path);    
00109     
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113 
00114 #endif
00115 
00116