mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

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