ConOpSys V2970  P004.07
ANVILEX control operating system
Checksum_8_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Checksum_8_Base.h
3 //! @brief Checksum 8 base class header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2015-2021 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/Checksum_8_Base.h $
7 //! $Revision: 2059 $
8 //! $Date: 2020-09-06 00:43:45 +0200 (So, 06 Sep 2020) $
9 //! $Author: minch $
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 //------------------------------------------------------------------------------
41 // Protecting header files from mutual, recursive inclusion.
42 //------------------------------------------------------------------------------
43 
44 #pragma once
45 
46 //------------------------------------------------------------------------------
47 // Include standard libraries header files
48 //------------------------------------------------------------------------------
49 
50 //------------------------------------------------------------------------------
51 // Include thrid party header files
52 //------------------------------------------------------------------------------
53 
54 //------------------------------------------------------------------------------
55 // Include ConOpSys header files
56 //------------------------------------------------------------------------------
57 
58 #include "Defines.h"
59 
60 //------------------------------------------------------------------------------
61 // Include ConOpSys application header files
62 //------------------------------------------------------------------------------
63 
64 //------------------------------------------------------------------------------
65 // Global defines
66 //------------------------------------------------------------------------------
67 
68 //------------------------------------------------------------------------------
69 // Global macros
70 //------------------------------------------------------------------------------
71 
72 //------------------------------------------------------------------------------
73 // Class definitions
74 //------------------------------------------------------------------------------
75 
76 //! @brief Checksum 8 base class
78 {
79 
80  //----------------------------------------------------------------------------
81  // Public defines, methods and variables
82  //----------------------------------------------------------------------------
83 
84  public:
85 
86  //!-------------------------------------------------------------------------
87  //! @brief Get initial value of checksum
88  //! @note None
89  //! @return U16 - CRC initial value
90  //! \par Override
91  //! Requered
92  //! @attention None
93  //--------------------------------------------------------------------------
94 
95  virtual U8 Init() = 0;
96 
97  //!-------------------------------------------------------------------------
98  //! @brief Check checksum of the data buffer
99  //! @note None
100  //! @param [in] *void_Data - Pointer to the data buffer
101  //! @param [in] u32_Size - Size of the data buffer
102  //! @param [in] u8_Expected_Checksum - Expected checksum of the data buffer
103  //! @return BOOL - Data buffer checksum checking status
104  //! @retval false - CRC of the buffer not match to expected checksum
105  //! @retval true - CRC of the buffer match to expected checksum
106  //! \par Override
107  //! Not allowed
108  //! @attention None
109  //! @dotfile TChecksum_8_Base__Check.dt
110  //--------------------------------------------------------------------------
111 
112  BOOL Check( VOID *void_Data, U32 u32_Size, U8 u8_Expected_Checksum );
113 
114  //!-------------------------------------------------------------------------
115  //! @brief Calculate checkdum of the data buffer
116  //! @note None
117  //! @param [in] *void_Data - Pointer to the data buffer
118  //! @param [in] u32_Size - Size of the data buffer
119  //! @return U8 - Calculated checksum of the data buffer
120  //! \par Override
121  //! Not allowed
122  //! @attention None
123  //! @dotfile TChecksum_8_Base__Calculate.dt
124  //--------------------------------------------------------------------------
125 
126  virtual U8 Calculate( VOID *void_Data, U32 u32_Size );
127 
128  //!-------------------------------------------------------------------------
129  //! @brief Update checksum with new data value
130  //! @note None
131  //! @param [in,out] &u8_Checksum - Actual checksum value
132  //! @param [in] u8_Data - Data value
133  //! @return None
134  //! \par Override
135  //! Not allowed
136  //! @attention None
137  //--------------------------------------------------------------------------
138 
139  virtual VOID Update( U8 &u8_Checksum, U8 u8_Data ) = 0;
140 
141  //!-------------------------------------------------------------------------
142  //! @brief Test checksum calulation
143  //! @note None
144  //! @return TRIL - Test checksum calculation status
145  //! @retval unset - Test method not implemented
146  //! @retval false - Test checksum calculation failed
147  //! @retval true - Test checksum calculation successed
148  //! \par Override
149  //! Not allowed
150  //! @attention Don't call this method directly
151  //! @dotfile TChecksum_8_Base__Test.dt
152  //--------------------------------------------------------------------------
153 
154  virtual TRIL Test();
155 
156  //----------------------------------------------------------------------------
157  // Protected defines, methods and variables
158  //----------------------------------------------------------------------------
159 
160  protected:
161 
162  //----------------------------------------------------------------------------
163  // Private defines, methods and variables
164  //----------------------------------------------------------------------------
165 
166  private:
167 
168 };
169 
170 //------------------------------------------------------------------------------
171 // End of file
172 //------------------------------------------------------------------------------
ConOpSys data type definitions header file.
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
int TRIL
Thrilean datatype defenition.
Definition: Defines.h:143
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
Checksum 8 base class.
Definition: Checksum_8_Base.h:78
virtual U8 Calculate(VOID *void_Data, U32 u32_Size)
Calculate checkdum of the data buffer.
Definition: Checksum_8_Base.cpp:62
BOOL Check(VOID *void_Data, U32 u32_Size, U8 u8_Expected_Checksum)
Check checksum of the data buffer.
Definition: Checksum_8_Base.cpp:50
virtual U8 Init()=0
Get initial value of checksum.
virtual VOID Update(U8 &u8_Checksum, U8 u8_Data)=0
Update checksum with new data value.
virtual TRIL Test()
Test checksum calulation.
Definition: Checksum_8_Base.cpp:86