Mistake on this page?
Report an issue in GitHub or email us
mbed_error_hist.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_ERROR_HIST_H
18 #define MBED_ERROR_HIST_H
19 
20 #ifndef MBED_CONF_PLATFORM_ERROR_HIST_SIZE
21 #define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 4
22 #else
23 #if MBED_CONF_PLATFORM_ERROR_HIST_SIZE == 0
24 #define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 1
25 #endif
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** \ingroup mbed-os-internal */
33 /** \addtogroup platform-internal-api */
34 /** @{*/
35 
36 /*
37  * Puts/Adds an error entry into the error history list
38  *
39  * @param error_ctx pointer to the mbed_error_ctx struct with the error context
40  * @return 0 or MBED_SUCCESS on success.
41  * MBED_ERROR_WRITE_FAILED if writing to file failed
42  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
43  *
44  *
45  */
46 mbed_error_status_t mbed_error_hist_put(mbed_error_ctx *error_ctx);
47 
48 /*
49  * Reads the error entry from the error list with the specified index
50  *
51  * @param index Index of the error context to be retrieved. It starts from 0 and 0 is the oldest.
52  * @param error_ctx pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
53  * @return 0 or MBED_SUCCESS on success.
54  * MBED_ERROR_WRITE_FAILED if writing to file failed
55  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
56  *
57  *
58  */
59 mbed_error_status_t mbed_error_hist_get(int index, mbed_error_ctx *error_ctx);
60 
61 /*
62  * Gets a reference to the next error entry in the error log where in the error ctx can be filled in.
63  * Its like reserving the next error entry to fill in the error info
64  *
65  * @return Returns the pointer to the next error ctx entry
66  *
67  *
68  */
69 mbed_error_ctx *mbed_error_hist_get_entry(void);
70 
71 /*
72  * Reads the last(latest) error entry from the error history
73  *
74  * @param error_ctx pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
75  * @return 0 or MBED_SUCCESS on success.
76  * MBED_ERROR_WRITE_FAILED if writing to file failed
77  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
78  *
79  *
80  */
81 mbed_error_status_t mbed_error_hist_get_last_error(mbed_error_ctx *error_ctx);
82 
83 /*
84  * Returns the number of error entries in the error history list
85  *
86  * @return Number of entries in the history list
87  *
88  *
89  */
90 int mbed_error_hist_get_count(void);
91 
92 /*
93  * Resets the error log by resetting the number of errors to 0 and clears all previous errors in the history list
94  *
95  * @return 0 or MBED_SUCCESS on success.
96  * MBED_ERROR_WRITE_FAILED if writing to file failed
97  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
98  *
99  *
100  */
101 mbed_error_status_t mbed_error_hist_reset(void);
102 
103 /*
104  * Saves the error log information to a file
105  *
106  * @param path path to the file in the filesystem
107  * @return 0 or MBED_SUCCESS on success.
108  * MBED_ERROR_WRITE_FAILED if writing to file failed
109  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
110  *
111  * @note Filesystem support is required in order for this function to work.
112  *
113  */
114 mbed_error_status_t mbed_save_error_hist(const char *path);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 /**@}*/
121 
122 #endif
int mbed_error_status_t
mbed_error_status_t description
Definition: mbed_error.h:110
mbed_error_status_t mbed_save_error_hist(const char *path)
Saves the error history information to a file.
mbed_error_ctx struct
Definition: mbed_error.h:834
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.