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  * Puts/Adds an error entry into the error history list
33  *
34  * @param error_ctx pointer to the mbed_error_ctx struct with the error context
35  * @return 0 or MBED_SUCCESS on success.
36  * MBED_ERROR_WRITE_FAILED if writing to file failed
37  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
38  *
39  *
40  */
41 mbed_error_status_t mbed_error_hist_put(mbed_error_ctx *error_ctx);
42 
43 /*
44  * Reads the error entry from the error list with the specified index
45  *
46  * @param index Index of the error context to be retrieved. It starts from 0 and 0 is the oldest.
47  * @param error_ctx pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
48  * @return 0 or MBED_SUCCESS on success.
49  * MBED_ERROR_WRITE_FAILED if writing to file failed
50  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
51  *
52  *
53  */
54 mbed_error_status_t mbed_error_hist_get(int index, mbed_error_ctx *error_ctx);
55 
56 /*
57  * Gets a reference to the next error entry in the error log where in the error ctx can be filled in.
58  * Its like reserving the next error entry to fill in the error info
59  *
60  * @return Returns the pointer to the next error ctx entry
61  *
62  *
63  */
64 mbed_error_ctx *mbed_error_hist_get_entry(void);
65 
66 /*
67  * Reads the last(latest) error entry from the error history
68  *
69  * @param error_ctx pointer to the mbed_error_ctx struct where the error context will be filled, this should be allocated by the caller
70  * @return 0 or MBED_SUCCESS on success.
71  * MBED_ERROR_WRITE_FAILED if writing to file failed
72  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
73  *
74  *
75  */
76 mbed_error_status_t mbed_error_hist_get_last_error(mbed_error_ctx *error_ctx);
77 
78 /*
79  * Returns the number of error entries in the error history list
80  *
81  * @return Number of entries in the history list
82  *
83  *
84  */
85 int mbed_error_hist_get_count(void);
86 
87 /*
88  * Resets the error log by resetting the number of errors to 0 and clears all previous errors in the history list
89  *
90  * @return 0 or MBED_SUCCESS on success.
91  * MBED_ERROR_WRITE_FAILED if writing to file failed
92  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
93  *
94  *
95  */
96 mbed_error_status_t mbed_error_hist_reset(void);
97 
98 /*
99  * Saves the error log information to a file
100  *
101  * @param path path to the file in the filesystem
102  * @return 0 or MBED_SUCCESS on success.
103  * MBED_ERROR_WRITE_FAILED if writing to file failed
104  * MBED_ERROR_INVALID_ARGUMENT if path is not valid
105  *
106  * @note Filesystem support is required in order for this function to work.
107  *
108  */
109 mbed_error_status_t mbed_save_error_hist(const char *path);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif
116 
117 
int mbed_error_status_t
mbed_error_status_t description
Definition: mbed_error.h:108
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:832
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.