ConOpSys V2970  P004.07
ANVILEX control operating system
Checksum_8.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Checksum_8.h
3 //! @brief Checksum 8 class header file.
4 //! @par Algorithm name
5 //! Checksum-8
6 //! @par Polynom
7 //! ???
8 //! @par Initial value
9 //! 0x00
10 //! @par Application
11 //! ???
12 //! @attention No special attention requered.
13 //! @copyright (C) 2015-2021
14 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/CRC_32.h $
15 //! $Revision: 2445 $
16 //! $Date: 2021-03-07 11:14:56 +0500 (So, 07 Mrz 2021) $
17 //! $Author: minch $
18 //------------------------------------------------------------------------------
19 //
20 // Redistribution and use in source and binary forms, with or without
21 // modification, are permitted provided that the following conditions are met:
22 //
23 // 1. Redistributions of source code must retain the above copyright notice,
24 // this list of conditions and the following disclaimer.
25 //
26 // 2. Redistributions in binary form must reproduce the above copyright notice,
27 // this list of conditions and the following disclaimer in the documentation
28 // and/or other materials provided with the distribution.
29 //
30 // 3. Neither the name of ANVILEX nor the names of its contributors may be
31 // used to endorse or promote products derived from this software without
32 // specific prior written permission.
33 //
34 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
38 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
43 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 // POSSIBILITY OF SUCH DAMAGE.
45 //
46 //------------------------------------------------------------------------------
47 
48 //------------------------------------------------------------------------------
49 // Protecting header files from mutual, recursive inclusion.
50 //------------------------------------------------------------------------------
51 
52 #pragma once
53 
54 //------------------------------------------------------------------------------
55 // Include standard libraries header files
56 //------------------------------------------------------------------------------
57 
58 //------------------------------------------------------------------------------
59 // Include thrid party header files
60 //------------------------------------------------------------------------------
61 
62 //------------------------------------------------------------------------------
63 // Include ConOpSys header files
64 //------------------------------------------------------------------------------
65 
66 #include "Defines.h"
67 
68 //------------------------------------------------------------------------------
69 // Include ConOpSys application header files
70 //------------------------------------------------------------------------------
71 
72 //------------------------------------------------------------------------------
73 // Global defines
74 //------------------------------------------------------------------------------
75 
76 //------------------------------------------------------------------------------
77 // Global macros
78 //------------------------------------------------------------------------------
79 
80 //------------------------------------------------------------------------------
81 // Class definitions
82 //------------------------------------------------------------------------------
83 
84 //! @brief Checksum 8 class
86 {
87 
88  //----------------------------------------------------------------------------
89  // Public defines, methods and variables
90  //----------------------------------------------------------------------------
91 
92  public:
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Class constructor method
96  //! @note None
97  //! \par Override
98  //! Not allowed
99  //! @attention Don't call this method directly.
100  //! @dotfile TChecksum_8__TChecksum_8.dt
101  //--------------------------------------------------------------------------
102 
103  TChecksum_8();
104 
105  //!-------------------------------------------------------------------------
106  //! @brief initialise internal CRC value to initial value
107  //! @note None
108  //! \par Override
109  //! Not allowed
110  //! @attention None
111  //! @dotfile TChecksum_8__Initialise.dt
112  //--------------------------------------------------------------------------
113 
114  VOID Initialise();
115 
116  //!-------------------------------------------------------------------------
117  //! @brief Check CRC of the data buffer
118  //! @note None
119  //! @param [in] *void_Data - Pointer to the data buffer
120  //! @param [in] u32_Size - Size of the data buffer
121  //! @param [in] u8_Expected_Checksum - Expected checksum of the data buffer
122  //! @return BOOL - Data buffer checksum 8 checking status
123  //! @retval false - Checksum of the buffer not match to expected CRC
124  //! @retval true - Checksum of the buffer match to expected CRC
125  //! \par Override
126  //! Not allowed
127  //! @attention None
128  //! @dotfile TChecksum_8__Check.dt
129  //--------------------------------------------------------------------------
130 
131  BOOL Check( VOID *void_Data, U32 u32_Size, U8 u8_Expected_Checksum );
132 
133  //!-------------------------------------------------------------------------
134  //! @brief Calculate CRC of the data buffer
135  //! @note None
136  //! @param [in] *void_Data - Pointer to the data buffer
137  //! @param [in] u32_Size - Size of the data buffer
138  //! @return U8 - Calculated checksum 8 of the data buffer
139  //! \par Override
140  //! Not allowed
141  //! @attention None
142  //! @dotfile TChecksum_8__Calculate.dt
143  //--------------------------------------------------------------------------
144 
145  U8 Calculate( VOID *void_Data, U32 u32_Size );
146 
147  //!-------------------------------------------------------------------------
148  //! @brief Update checksum with new data value
149  //! @note None
150  //! @param [in, out] &u8_Checksum - Actual checksum value
151  //! @param [in] u8_Data - Data value
152  //! @return None
153  //! \par Override
154  //! Not allowed
155  //! @attention None
156  //! @dotfile TChecksum_8__Update.dt
157  //--------------------------------------------------------------------------
158 
159  VOID Update( U8 &u8_Checksum, U8 u8_Data );
160 
161  //!-------------------------------------------------------------------------
162  //! @brief Update checksum with new data value
163  //! @note None
164  //! @param [in] u8_Data - Data value
165  //! @return None
166  //! \par Override
167  //! Not allowed
168  //! @attention None
169  //! @dotfile TChecksum_8__Update.dt
170  //--------------------------------------------------------------------------
171 
172  VOID Update( U8 u8_Data );
173 
174  //!-------------------------------------------------------------------------
175  //! @brief Update checksum with new data from data buffer
176  //! @note None
177  //! @param [in, out] &u8_Checksum - Actual checksum value
178  //! @param [in] *u8_Data - Pointer to the data buffer
179  //! @param [in] u32_Length - Data buffer length
180  //! @return None
181  //! \par Override
182  //! Not allowed
183  //! @attention None
184  //! @dotfile TChecksum_8__Update.dt
185  //--------------------------------------------------------------------------
186 
187  VOID Update( U8 &u8_Checksum, U8 *u8_Data, U32 u32_Length );
188 
189  //----------------------------------------------------------------------------
190  // Protected defines, methods and variables
191  //----------------------------------------------------------------------------
192 
193  protected:
194 
195  //----------------------------------------------------------------------------
196  // Private defines, methods and variables
197  //----------------------------------------------------------------------------
198 
199  private:
200 
201  //--------------------------------------------------------------------------
202  // Private variables
203  //--------------------------------------------------------------------------
204 
205  //! @brief Checksum internal storage variable
207 
208 };
209 
210 //------------------------------------------------------------------------------
211 // End of file
212 //------------------------------------------------------------------------------
ConOpSys data type definitions 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
Checksum 8 class.
Definition: Checksum_8.h:86
VOID Update(U8 &u8_Checksum, U8 u8_Data)
Update checksum with new data value.
Definition: Checksum_8.cpp:120
U8 u8_Checksum_Intern
Checksum internal storage variable.
Definition: Checksum_8.h:206
VOID Initialise()
initialise internal CRC value to initial value
Definition: Checksum_8.cpp:72
U8 Calculate(VOID *void_Data, U32 u32_Size)
Calculate CRC of the data buffer.
Definition: Checksum_8.cpp:96
TChecksum_8()
Class constructor method.
Definition: Checksum_8.cpp:64
BOOL Check(VOID *void_Data, U32 u32_Size, U8 u8_Expected_Checksum)
Check CRC of the data buffer.
Definition: Checksum_8.cpp:84