ConOpSys V2970  P004.07
ANVILEX control operating system
Protocol_ANVILEX_Master_Over_UART.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Protocol_ANVILEX_Master_Over_UART.h
3 //! @brief Communication protocol ANVILEX master over UART class header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2015-2020 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Engine/Protocol_ANVILEX_Over_UART.h $
7 //! $Revision: 2359 $
8 //! $Date: 2021-02-08 19:48:43 +0500 (Mo, 08 Feb 2021) $
9 //! $Author: ggavrituhin $
10 //------------------------------------------------------------------------------
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // 1. Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright notice,
19 // this list of conditions and the following disclaimer in the documentation
20 // and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of ANVILEX nor the names of its contributors may be
23 // used to endorse or promote products derived from this software without
24 // specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 //------------------------------------------------------------------------------
39 
40 #pragma once
41 
42 //------------------------------------------------------------------------------
43 // Include system files
44 //------------------------------------------------------------------------------
45 
46 #include "Protocol_Base.h"
47 #include "ConOpSys_Variant.h"
48 
49 //------------------------------------------------------------------------------
50 
51 #define ANVILEX_MASTER_PROTOCOL_RX_BUFFER_SIZE ( (U32)0x080 )
52 #define ANVILEX_MASTER_PROTOCOL_TX_BUFFER_SIZE ( (U32)0x100 )
53 #define ANVILEX_MASTER_FRAME_SIZE ( (U32)20 )
54 #define ANVILEX_MASTER_FRAME_NUMBER ( (U32)5 )
55 
56 //------------------------------------------------------------------------------
57 // Class definitions
58 //------------------------------------------------------------------------------
59 
60 //! @brief Communication protocol ANVILEX master over UART class
62 {
63 
64  //----------------------------------------------------------------------------
65  // Public defines, methods and variables
66  //----------------------------------------------------------------------------
67 
68  public:
69 /*
70  // Parameter property index definitions
71  typedef enum
72  {
73 
74  enum_ID = 1,
75  enum_Properties = 2,
76  enum_Element_Count = 3,
77  enum_Minimum_Value = 4,
78  enum_Maximum_Value = 5,
79  enum_Default_Value = 6,
80  enum_Name = 7,
81  enum_Group = 8,
82  enum_Description = 9,
83  enum_Unit = 10
84 
85  }TParameter_Property_Index;
86 
87  // Event property index definitions
88  typedef enum
89  {
90 
91  enum_Event_Description = 1
92 
93  }TEvent_Property_Index;
94 */
95  // ANVILEX protocol return values definition
96  typedef enum
97  {
98 
99  // Sucess related code
100  enum_Ok = 0x00000000,
101 
102  //
105  enum_Not_Implemented = 0x00000003,
106  enum_Unknown_Error = 0x00000004,
107 
108  // Parameter related return codes
116 
117  // Event related return codes
118  enum_Event_Not_Found = 0x0000000C,
119  enum_Event_Property_Not_Found = 0x0000000D
120 
122 
123  //!-------------------------------------------------------------------------
124  //! @brief Class constructor method.
125  //! @note None
126  //! \par Override
127  //! Not allowed
128  //! @attention Don't call this method directly.
129  //--------------------------------------------------------------------------
130 
132 
133  //!-------------------------------------------------------------------------
134  //! @brief Class destructor method.
135  //! @note None
136  //! \par Override
137  //! Not allowed
138  //! @attention Don't call this method directly.
139  //--------------------------------------------------------------------------
140 
141  virtual ~TProtocol_ANVILEX_Master_Over_UART(); //!< Class destructor method
142 
143  //!-------------------------------------------------------------------------
144  //! @brief Protocol initialisation method.
145  //! @note None
146  //! \par Override
147  //! Not allowed
148  //! @attention None
149  //--------------------------------------------------------------------------
150 
151  VOID Init();
152 
153  // Receive related methods
154 // virtual VOID Receive_Char( C8 c8_Character );
155  virtual VOID Communication_Data_Receive( U8 u8_Receive_Value );
156  virtual VOID Communication_Data_Receive( VOID *void_Receive_Data );
157 
158  virtual VOID Receive_String( C8 *c8_String );
159  virtual VOID Receive_String( C8 *c8_String, U32 u32_Length );
160 
161 
162  //!-------------------------------------------------------------------------
163  //! @brief Cyclic execution method.
164  //! @note None
165  //! \par Override
166  //! Not allowed
167  //! @attention None
168  //--------------------------------------------------------------------------
169 
170  virtual VOID Execute();
171 
172  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
173 
174  // Operation mode related methods
175  virtual VOID Enter_Terminal_Mode();
176  virtual VOID Enter_Protocol_Mode();
177  virtual BOOL Is_Terminal_Mode();
178  virtual BOOL Is_Protocol_Mode();
179 
180  //!-------------------------------------------------------------------------
181  //! @brief Transmit prompt in terminal mode method
182  //! @note None
183  //! @return None
184  //! \par Override
185  //! Not allowed
186  //! @attention This method called from interrupt
187  //--------------------------------------------------------------------------
188 
190 
191  //!-------------------------------------------------------------------------
192  //! @brief Enable show system welcome message method.
193  //! @note None
194  //! @return None
195  //! \par Override
196  //! Not allowed
197  //! @attention None
198  //--------------------------------------------------------------------------
199 
201 
202  //!-------------------------------------------------------------------------
203  //! @brief Disable show system welcome message method.
204  //! @note None
205  //! @return None
206  //! \par Override
207  //! Not allowed
208  //! @attention None
209  //--------------------------------------------------------------------------
210 
212 
213  //!-------------------------------------------------------------------------
214  //! @brief Enable system ready message method.
215  //! @note None
216  //! @return None
217  //! \par Override
218  //! Not allowed
219  //! @attention None
220  //--------------------------------------------------------------------------
221 
223 
224  //!-------------------------------------------------------------------------
225  //! @brief Disable system ready message method.
226  //! @note None
227  //! @return None
228  //! \par Override
229  //! Not allowed
230  //! @attention None
231  //--------------------------------------------------------------------------
232 
234 
235  //!-------------------------------------------------------------------------
236  //! @brief Transmit boot welcome message method
237  //! @note None
238  //! @return None
239  //! \par Override
240  //! Not allowed
241  //! @attention This method called from interrupt
242  //--------------------------------------------------------------------------
243 
245 
246  //!-------------------------------------------------------------------------
247  //! @brief Transmit boot ready message method.
248  //! @note None
249  //! @return None
250  //! \par Override
251  //! Not allowed
252  //! @attention None
253  //--------------------------------------------------------------------------
254 
256 
257  //! @brief Terminal operation mode status
259 
260  //! @brief Show system welcome message status
262 
263  //! @brief Show system ready message status
265 
266  // Diverse methods
267 
268  //----------------------------------------------------------------------------
269  // Protected defines, methods and variables
270  //----------------------------------------------------------------------------
271 
272  protected:
273 
274  //----------------------------------------------------------------------------
275  // Private defines, methods and variables
276  //----------------------------------------------------------------------------
277 
278  private:
279 
280  //--------------------------------------------------------------------------
281  // Private defines
282  //--------------------------------------------------------------------------
283 
284  //! @brief Master finite state mashine states definition
285  typedef enum
286  {
287 
288  //! @brief Initialisation state
290 
291  //! @brief Idle state
293 
294  //! @brief Send request state
296 
297  //! @brief Wait for write access response
299 
300  //! @brief Wait for read access response
302 
304 
305  //--------------------------------------------------------------------------
306  // Parameter related methods
307  //--------------------------------------------------------------------------
308 
309 // VOID New_Data_Processing(); //!< New data processing
310 
311  //--------------------------------------------------------------------------
312  // Remote parameters methods
313  //--------------------------------------------------------------------------
314 
316 
317  BOOL Protocol_Remote_Parameter_Read_Response(); //!< Protocol remote parameter response processing
318 
319 // BOOL Protocol_Remote_Parameter_Write_Response( TConOpSys_Variant* object_Value ); //!< Protocol write parameter response processing
320 
322 
324 
326 
327  BOOL Get_Frame( C8 *c8_Return_Value, U8 u8_Frame_Number);
328 
329  //--------------------------------------------------------------------------
330  // Common data transmision methods
331  //--------------------------------------------------------------------------
332 
333 // VOID Protocol_Transmit_Error_Code( TProtocol_Return_Code enum_Return_Code ); //!< Transmit error code
334 // VOID Protocol_Transmit_Variant_Value( TConOpSys_Variant *object_Value ); //!< Transmit variant value
335 // VOID Protocol_Transmit_U32_Value( U32 u32_Value ); //!< Transmit U32 value
336 // VOID Protocol_Transmit_String( C8 *c8_String ); //!< Transmit null terminated string
337 
338  //--------------------------------------------------------------------------
339  // Private variables
340  //--------------------------------------------------------------------------
341 
342  //! @brief Bin to hex table
343  const C8 Bin2HexTable[ 16 ] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
344 
345  //! @brief Data receive buffer
347 
348  //! @brief Receive buffer index
350 
351  //! @brief Data transmit buffer
353 
354  //! @brief New data buffer
356 
357  //! @brief Remote parameter value as string
358  C8 c8_Remote_Parameter_Value[ 64 ] = { 0x00 };
359 
360  //! @brief Master finite state mashine
361  TMaster_State enum_Master_FSM = TMaster_State::enum_Init;
362 
363  //! @brief Remote node address
365 
366  //! @brief Remote parameter index
368 
369  //! @brief Timestamp for remote writing
371 
372  //! @brief Timeout for remote writing
374 
375  //! @brief Timestamp for remote reading
377 
378  //! @brief Timeout for remote reading
380 
381  //! @brief Package ID
383 
384  //! @brief Package ID
386 
387  //! @brief Node address
389 
390  //! @brief Frame counter
392 
393  //! @brief Frames list
395 
396 };
397 
398 //------------------------------------------------------------------------------
399 // End of file
400 //------------------------------------------------------------------------------
ConOpSys variant class header file.
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
unsigned char U8
Binary 8-Bit unsigned integer datatype defenition.
Definition: Defines.h:183
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
char C8
ASCII 8-Bit char datatype defenition.
Definition: Defines.h:156
#define ANVILEX_MASTER_FRAME_SIZE
Definition: Protocol_ANVILEX_Master_Over_UART.h:53
#define ANVILEX_MASTER_PROTOCOL_TX_BUFFER_SIZE
Definition: Protocol_ANVILEX_Master_Over_UART.h:52
#define ANVILEX_MASTER_PROTOCOL_RX_BUFFER_SIZE
Definition: Protocol_ANVILEX_Master_Over_UART.h:51
#define ANVILEX_MASTER_FRAME_NUMBER
Definition: Protocol_ANVILEX_Master_Over_UART.h:54
Communication protocol base class header file.
Communication protocol ANVILEX master over UART class.
Definition: Protocol_ANVILEX_Master_Over_UART.h:62
virtual VOID Enter_Terminal_Mode()
Enter terminal mode method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:525
U32 u32_Remote_Node_Address
Remote node address.
Definition: Protocol_ANVILEX_Master_Over_UART.h:364
const C8 Bin2HexTable[16]
Bin to hex table.
Definition: Protocol_ANVILEX_Master_Over_UART.h:343
VOID Remote_Parameter_Index_Processing()
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:2124
U8 u8_Frame_Counter
Frame counter.
Definition: Protocol_ANVILEX_Master_Over_UART.h:391
VOID Transmit_System_Ready_Message()
Transmit boot ready message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:205
virtual BOOL Is_Protocol_Mode()
Protocol mode operation status method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:547
BOOL bool_Show_System_Ready_Message_Enabled
Show system ready message status.
Definition: Protocol_ANVILEX_Master_Over_UART.h:264
VOID Show_System_Ready_Message_Disable()
Disable system ready message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:148
VOID Show_System_Welcome_Message_Enable()
Enable show system welcome message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:112
U32 u32_Node_Address
Node address.
Definition: Protocol_ANVILEX_Master_Over_UART.h:388
BOOL Parse_Frames_Into_Message()
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:2166
TMaster_State
Master finite state mashine states definition.
Definition: Protocol_ANVILEX_Master_Over_UART.h:286
@ enum_Idle
Idle state.
Definition: Protocol_ANVILEX_Master_Over_UART.h:292
@ enum_Wait_Read_Response
Wait for read access response.
Definition: Protocol_ANVILEX_Master_Over_UART.h:301
@ enum_Wait_Write_Response
Wait for write access response.
Definition: Protocol_ANVILEX_Master_Over_UART.h:298
@ enum_Send_Request
Send request state.
Definition: Protocol_ANVILEX_Master_Over_UART.h:295
@ enum_Init
Initialisation state.
Definition: Protocol_ANVILEX_Master_Over_UART.h:289
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Send information about protocol method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:519
virtual VOID Communication_Data_Receive(U8 u8_Receive_Value)
Communication data receive method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:257
C8 c8_Receive_Buffer[ANVILEX_MASTER_PROTOCOL_RX_BUFFER_SIZE]
Data receive buffer.
Definition: Protocol_ANVILEX_Master_Over_UART.h:346
virtual VOID Enter_Protocol_Mode()
Enter protocol mode method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:531
virtual ~TProtocol_ANVILEX_Master_Over_UART()
Class destructor method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:80
virtual VOID Receive_String(C8 *c8_String)
Receive string.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:432
U32 u32_Remote_Read_Timeout
Timeout for remote reading.
Definition: Protocol_ANVILEX_Master_Over_UART.h:379
TProtocol_Return_Code
Definition: Protocol_ANVILEX_Master_Over_UART.h:97
@ enum_Unknown_Error
Definition: Protocol_ANVILEX_Master_Over_UART.h:106
@ enum_Parameter_Access_Denied
Definition: Protocol_ANVILEX_Master_Over_UART.h:113
@ enum_Parameter_Write_Failure
Definition: Protocol_ANVILEX_Master_Over_UART.h:115
@ enum_Parameter_Property_Not_Found
Definition: Protocol_ANVILEX_Master_Over_UART.h:110
@ enum_Invalid_Frame_CRC
Definition: Protocol_ANVILEX_Master_Over_UART.h:104
@ enum_Parameter_Non_Readable
Definition: Protocol_ANVILEX_Master_Over_UART.h:111
@ enum_Parameter_Value_Out_Of_Bounds
Definition: Protocol_ANVILEX_Master_Over_UART.h:114
@ enum_Parameter_Non_Writable
Definition: Protocol_ANVILEX_Master_Over_UART.h:112
@ enum_Parameter_Not_Found
Definition: Protocol_ANVILEX_Master_Over_UART.h:109
@ enum_Ok
Definition: Protocol_ANVILEX_Master_Over_UART.h:100
@ enum_Event_Property_Not_Found
Definition: Protocol_ANVILEX_Master_Over_UART.h:119
@ enum_Not_Implemented
Definition: Protocol_ANVILEX_Master_Over_UART.h:105
@ enum_Invalid_Frame_Format
Definition: Protocol_ANVILEX_Master_Over_UART.h:103
@ enum_Event_Not_Found
Definition: Protocol_ANVILEX_Master_Over_UART.h:118
C8 c8_Frame_List[ANVILEX_MASTER_FRAME_NUMBER][ANVILEX_MASTER_FRAME_SIZE]
Frames list.
Definition: Protocol_ANVILEX_Master_Over_UART.h:394
U32 u32_Remote_Write_Start_Timestamp
Timestamp for remote writing.
Definition: Protocol_ANVILEX_Master_Over_UART.h:370
VOID Show_System_Ready_Message_Enable()
Enable system ready message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:136
TProtocol_ANVILEX_Master_Over_UART()
Class constructor method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:72
BOOL Get_Frame(C8 *c8_Return_Value, U8 u8_Frame_Number)
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:2266
U32 u32_Remote_Write_Timeout
Timeout for remote writing.
Definition: Protocol_ANVILEX_Master_Over_UART.h:373
virtual VOID Execute()
Cyclic execution method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:559
U8 u8_Package_ID
Package ID.
Definition: Protocol_ANVILEX_Master_Over_UART.h:382
U32 u32_Remote_Read_Start_Timestamp
Timestamp for remote reading.
Definition: Protocol_ANVILEX_Master_Over_UART.h:376
BOOL Protocol_Remote_Parameter_Read_Response()
Protocol remote parameter response processing.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:1940
U32 u32_Receive_Buffer_Index
Receive buffer index.
Definition: Protocol_ANVILEX_Master_Over_UART.h:349
BOOL Is_Remote_Parameter_List_Empty()
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:2135
C8 c8_Remote_Parameter_Value[64]
Remote parameter value as string.
Definition: Protocol_ANVILEX_Master_Over_UART.h:358
BOOL bool_Terminal_Mode
Terminal operation mode status.
Definition: Protocol_ANVILEX_Master_Over_UART.h:258
VOID Init()
Protocol initialisation method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:88
C8 c8_New_Data_Buffer[ANVILEX_MASTER_PROTOCOL_RX_BUFFER_SIZE]
New data buffer.
Definition: Protocol_ANVILEX_Master_Over_UART.h:355
VOID Transmit_Boot_Welcome_Message()
Transmit boot welcome message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:160
virtual BOOL Is_Terminal_Mode()
Terminal mode operation status method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:537
VOID Show_System_Welcome_Message_Disable()
Disable show system welcome message method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:124
VOID Transmit_Prompt()
Transmit prompt in terminal mode method.
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:100
TMaster_State enum_Master_FSM
Master finite state mashine.
Definition: Protocol_ANVILEX_Master_Over_UART.h:361
U32 Get_Responce_Data_Length()
Definition: Protocol_ANVILEX_Master_Over_UART.cpp:480
U8 u8_Ref_Package_ID
Package ID.
Definition: Protocol_ANVILEX_Master_Over_UART.h:385
U32 u32_Remote_Parameter_Index
Remote parameter index.
Definition: Protocol_ANVILEX_Master_Over_UART.h:367
C8 c8_Transmit_Buffer[ANVILEX_MASTER_PROTOCOL_TX_BUFFER_SIZE]
Data transmit buffer.
Definition: Protocol_ANVILEX_Master_Over_UART.h:352
BOOL bool_Show_System_Welcome_Message_Enabled
Show system welcome message status.
Definition: Protocol_ANVILEX_Master_Over_UART.h:261
Definition: Protocol_Base.h:57