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