HomeAut
GlobalVarHandler.h
1 /*
2  * GlobalVarHandler.h
3  *
4  * Created on: 2016.09.05
5  * Author: Vizi Gábor
6  * E-mail: vizi.gabor90@gmail.com
7  * Function: Global Variable Handler: Handle set-get variable from uart or other
8  * Target: STM32Fx
9  * Version: v4
10  * Last modified: 2016.09.28
11  */
12 
13 #ifndef GLOBALVARHANDLER_H_
14 #define GLOBALVARHANDLER_H_
15 
16 
17 #include "include.h"
18 
19 
20 /*------------------------------------------------------------------------------
21  * Macros & definitions
22  *----------------------------------------------------------------------------*/
23 
24 #define GLOBALVARHANDLER_UNIT_ENABLE
25 #define GLOBALVARHANDLER_DESCRIPTION_ENABLE
26 
27 #define GLOBALVARHANDLER_NAME_MAX_LENGTH (20)
28 
29 
30 
31 /*------------------------------------------------------------------------------
32  * Type definitions
33  *----------------------------------------------------------------------------*/
34 
35 typedef uint8_t VarID_t;
36 
37 
40 typedef enum
41 {
42  Type_Unknown = 0,
43  Type_Bool,
44  Type_Uint8,
45  Type_Int8,
46  Type_Uint16,
47  Type_Int16,
48  Type_Uint32,
49  Type_Int32,
50  Type_Float,
51  Type_Bits,
52  Type_String,
53  Type_Enumerator,
54  Type_Count
55 } VarType_t;
56 
57 
59 typedef enum
60 {
61  Process_Unknown = 0,
62  Process_GlobalVariableNameNotFind,
63  Process_SourceNotEnabled,
64  Process_IsReadOnly,
65  Process_FailType,
66  Process_FailParam,
67  Process_FailParamTooLongString,
68  Process_FailParamIsNotNumber,
69  Process_FailParamIsNotHexNumber,
70  Process_FailParamIsNotHexStart,
71  Process_FailParamIsNotBinary,
72  Process_FailParamTooLongBinary,
73  Process_InvalidValue_TooMuch,
74  Process_InvalidValue_TooSmall,
75  Process_InvalidValue_NotBool,
76  Process_InvalidValue_NotEnumString,
77  Process_Settings_EmptyEnumList,
78  Process_Ok_Answered,
79  Process_Ok_SetSuccessful_SendOk
80 } ProcessResult_t;
81 
82 
84 typedef enum
85 {
86  SetGet_Unknown = 0,
87  SetGet_Get,
88  SetGet_Set,
89  SetGet_Help
90 } SetGetType_t;
91 
92 
94 typedef struct
95 {
96 
97  const char * const name;
98  const VarType_t type;
99 
100  void * const varPointer;
101  const bool isReadOnly;
102 
103  const uint32_t maxValue;
104  const uint32_t minValue;
105 
106  const CommProtocol_t sourceEnable;
107 
108  const bool isHex;
109 
110  const char * const *enumList;
111 
112 #ifdef GLOBALVARHANDLER_UNIT_ENABLE
113  const char * const unit;
114 #endif
115 #ifdef GLOBALVARHANDLER_DESCRIPTION_ENABLE
116  const char * const description;
117 #endif
118 
120 
121 
122 
123 /*------------------------------------------------------------------------------
124  * Global function declarations
125  *----------------------------------------------------------------------------*/
126 
127 bool GlobalVarHandler_CheckCommandStructAreValid(void);
128 void GlobalVarHandler_ProcessCommand(
129  const char *commandName, const char *param,
130  SetGetType_t setGetType, CommProtocol_t source,
131  char *resultBuffer, uint8_t resultBufferLength);
132 
133 void GlobalVarHandler_ListAllVariableParameters(void);
134 void GlobalVarHandler_PrintAllVariableValues(void);
135 
136 
137 
138 #endif /* GLOBALVARHANDLER_H_ */
GlobalVarCommand structure for set-get global variables.
Definition: GlobalVarHandler.h:94
void *const varPointer
Pointer of variable.
Definition: GlobalVarHandler.h:100
const bool isHex
Set-get in hexadecimal?
Definition: GlobalVarHandler.h:108
const char *const name
Name of global variable [string].
Definition: GlobalVarHandler.h:97
const uint32_t minValue
Min value.
Definition: GlobalVarHandler.h:104
const uint32_t maxValue
Max value.
Definition: GlobalVarHandler.h:103
const bool isReadOnly
Is read only?
Definition: GlobalVarHandler.h:101
const char *const unit
units [string], example: [cm]
Definition: GlobalVarHandler.h:113
const CommProtocol_t sourceEnable
Enabled sources (for set-get)
Definition: GlobalVarHandler.h:106
const char *const description
descriptions of global variable [string]
Definition: GlobalVarHandler.h:116
const VarType_t type
Type of global variable.
Definition: GlobalVarHandler.h:98
const char *const * enumList
Enum list, if it is enumerator.
Definition: GlobalVarHandler.h:110