|
| 1 | +/************************************************************************ |
| 2 | + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” |
| 3 | + * |
| 4 | + * Copyright (c) 2020 United States Government as represented by the |
| 5 | + * Administrator of the National Aeronautics and Space Administration. |
| 6 | + * All Rights Reserved. |
| 7 | + * |
| 8 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | + * not use this file except in compliance with the License. You may obtain |
| 10 | + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + ************************************************************************/ |
| 18 | +#ifndef CFE_PSP_ERROR_H |
| 19 | +#define CFE_PSP_ERROR_H |
| 20 | + |
| 21 | +/** |
| 22 | + * \file |
| 23 | + * \brief cFE PSP Error header |
| 24 | + */ |
| 25 | + |
| 26 | +#include "common_types.h" |
| 27 | + |
| 28 | +/** |
| 29 | + * \brief PSP Status type for readability and potentially type safety |
| 30 | + */ |
| 31 | +typedef int32 CFE_PSP_Status_t; |
| 32 | + |
| 33 | +/** |
| 34 | + * \brief PSP Status macro for literal |
| 35 | + */ |
| 36 | +#define CFE_PSP_STATUS_C(X) ((CFE_PSP_Status_t)(X)) |
| 37 | + |
| 38 | +/** |
| 39 | + * \brief PSP Status converted to string length limit |
| 40 | + * |
| 41 | + * Used for sizing CFE_PSP_StatusString_t intended for use in printing CFE_PSP_Status_t values |
| 42 | + * Sized for %ld (LONG_MIN) including NULL |
| 43 | + */ |
| 44 | +#define CFE_PSP_STATUS_STRING_LENGTH 12 |
| 45 | + |
| 46 | +/** |
| 47 | + * @brief For the @ref CFE_PSP_StatusToString() function, to ensure |
| 48 | + * everyone is making an array of the same length. |
| 49 | + */ |
| 50 | +typedef char CFE_PSP_StatusString_t[CFE_PSP_STATUS_STRING_LENGTH]; |
| 51 | + |
| 52 | +/** |
| 53 | + * @brief Convert status to a string |
| 54 | + * |
| 55 | + * @param[in] status Status value to convert |
| 56 | + * @param[out] status_string Buffer to store status converted to string |
| 57 | + * |
| 58 | + * @return Passed in string pointer |
| 59 | + */ |
| 60 | +char *CFE_PSP_StatusToString(CFE_PSP_Status_t status, CFE_PSP_StatusString_t *status_string); |
| 61 | + |
| 62 | +/* |
| 63 | + * Error and return codes |
| 64 | + */ |
| 65 | +#define CFE_PSP_SUCCESS (CFE_PSP_STATUS_C(0)) |
| 66 | +#define CFE_PSP_ERROR (CFE_PSP_STATUS_C(-1)) |
| 67 | +#define CFE_PSP_INVALID_POINTER (CFE_PSP_STATUS_C(-2)) |
| 68 | +#define CFE_PSP_ERROR_ADDRESS_MISALIGNED (CFE_PSP_STATUS_C(-3)) |
| 69 | +#define CFE_PSP_ERROR_TIMEOUT (CFE_PSP_STATUS_C(-4)) |
| 70 | +#define CFE_PSP_INVALID_INT_NUM (CFE_PSP_STATUS_C(-5)) |
| 71 | +#define CFE_PSP_INVALID_MEM_ADDR (CFE_PSP_STATUS_C(-21)) |
| 72 | +#define CFE_PSP_INVALID_MEM_TYPE (CFE_PSP_STATUS_C(-22)) |
| 73 | +#define CFE_PSP_INVALID_MEM_RANGE (CFE_PSP_STATUS_C(-23)) |
| 74 | +#define CFE_PSP_INVALID_MEM_WORDSIZE (CFE_PSP_STATUS_C(-24)) |
| 75 | +#define CFE_PSP_INVALID_MEM_SIZE (CFE_PSP_STATUS_C(-25)) |
| 76 | +#define CFE_PSP_INVALID_MEM_ATTR (CFE_PSP_STATUS_C(-26)) |
| 77 | +#define CFE_PSP_ERROR_NOT_IMPLEMENTED (CFE_PSP_STATUS_C(-27)) |
| 78 | +#define CFE_PSP_INVALID_MODULE_NAME (CFE_PSP_STATUS_C(-28)) |
| 79 | +#define CFE_PSP_INVALID_MODULE_ID (CFE_PSP_STATUS_C(-29)) |
| 80 | +#define CFE_PSP_NO_EXCEPTION_DATA (CFE_PSP_STATUS_C(-30)) |
| 81 | + |
| 82 | +#endif /* CFE_PSP_ERROR_H */ |
0 commit comments