ConOpSys V2970  P004.07
ANVILEX control operating system
CRC_16_MODBUS.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file CRC_16_MODBUS.h
3 //! @brief Cyclic reduncancy check (CRC-16-MODBUS) class header file.
4 //! @par Algorithm name
5 //! CRC-16-MODBUS
6 //! @par Polynom
7 //! 0xA001
8 //! x16 + x15 + x2 + 1
9 //! @par Initial value
10 //! 0xFFFF
11 //! @par Application
12 //! MODBUS
13 //! @attention No special attention requered.
14 //! @copyright (C) 2015-2020 ANVILEX LLC
15 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/CRC_16_MODBUS.h $
16 //! $Revision: 2797 $
17 //! $Date: 2021-07-12 16:13:33 +0500 (Mo, 12 Jul 2021) $
18 //! $Author: minch $
19 //------------------------------------------------------------------------------
20 //
21 // Redistribution and use in source and binary forms, with or without
22 // modification, are permitted provided that the following conditions are met:
23 //
24 // 1. Redistributions of source code must retain the above copyright notice,
25 // this list of conditions and the following disclaimer.
26 //
27 // 2. Redistributions in binary form must reproduce the above copyright notice,
28 // this list of conditions and the following disclaimer in the documentation
29 // and/or other materials provided with the distribution.
30 //
31 // 3. Neither the name of ANVILEX nor the names of its contributors may be
32 // used to endorse or promote products derived from this software without
33 // specific prior written permission.
34 //
35 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
39 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 // POSSIBILITY OF SUCH DAMAGE.
46 //
47 //------------------------------------------------------------------------------
48 
49 //------------------------------------------------------------------------------
50 // Protecting header files from mutual, recursive inclusion.
51 //------------------------------------------------------------------------------
52 
53 #pragma once
54 
55 //------------------------------------------------------------------------------
56 // Include standard libraries header files
57 //------------------------------------------------------------------------------
58 
59 //------------------------------------------------------------------------------
60 // Include thrid party header files
61 //------------------------------------------------------------------------------
62 
63 //------------------------------------------------------------------------------
64 // Include ConOpSys header files
65 //------------------------------------------------------------------------------
66 
67 #include "CRC_16_Base.h"
68 
69 //------------------------------------------------------------------------------
70 // Include ConOpSys application header files
71 //------------------------------------------------------------------------------
72 
73 //------------------------------------------------------------------------------
74 // Global defines
75 //------------------------------------------------------------------------------
76 
77 //------------------------------------------------------------------------------
78 // Global macros
79 //------------------------------------------------------------------------------
80 
81 //------------------------------------------------------------------------------
82 // Class definitions
83 //------------------------------------------------------------------------------
84 
85 //! @brief Cyclic redundancy check (CRC-16-MODBUS) class
87 {
88 
89  //----------------------------------------------------------------------------
90  // Public defines, methods and variables
91  //----------------------------------------------------------------------------
92 
93  public:
94 
95  //--------------------------------------------------------------------------
96  // Public methods
97  //--------------------------------------------------------------------------
98 
99  //!-------------------------------------------------------------------------
100  //! @brief Get initial value of CRC method
101  //! @note None
102  //! @return U16 - CRC initial value
103  //! \par Override
104  //! Not allowed
105  //! @attention None
106  //! \par UML diagram
107  //! @dotfile TCRC_16_MODBUS__Init.dt
108  //--------------------------------------------------------------------------
109 
110  virtual U16 Init();
111 
112  //!-------------------------------------------------------------------------
113  //! @brief Update CRC with new data value method
114  //! @note None
115  //! @param [in, out] &u16_CRC - Actual CRC value
116  //! @param [in] u8_Data - Data value
117  //! @return None
118  //! \par Override
119  //! Not allowed
120  //! @attention None
121  //! \par UML diagram
122  //! @dotfile TCRC_16_MODBUS__Update.dt
123  //--------------------------------------------------------------------------
124 
125  virtual VOID Update( U16 &u16_CRC, U8 u8_Data );
126 
127  //!-------------------------------------------------------------------------
128  //! @brief Test CRC calulation method
129  //! @note None
130  //! @return TRIL - Test CRC calculation status
131  //! @retval unset - Test method not implemented
132  //! @retval false - Test CRC calculation failed
133  //! @retval true - Test CRC calculation successed
134  //! \par Override
135  //! Not allowed
136  //! @attention Don't call this method directly
137  //! \par UML diagram
138  //! @dotfile TCRC_16_MODBUS__Test.dt
139  //--------------------------------------------------------------------------
140 
141  virtual TRIL Test();
142 
143  //----------------------------------------------------------------------------
144  // Protected defines, methods and variables
145  //----------------------------------------------------------------------------
146 
147  protected:
148 
149  //----------------------------------------------------------------------------
150  // Private defines, methods and variables
151  //----------------------------------------------------------------------------
152 
153  private:
154 
155 };
156 
157 //------------------------------------------------------------------------------
158 // End of file
159 //------------------------------------------------------------------------------
Cyclic reduncancy check (CRC-16) base class header file.
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 short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
Cyclic redundancy check (CRC-16) base class.
Definition: CRC_16_Base.h:78
Cyclic redundancy check (CRC-16-MODBUS) class.
Definition: CRC_16_MODBUS.h:87
virtual U16 Init()
Get initial value of CRC method.
Definition: CRC_16_MODBUS.cpp:59
virtual TRIL Test()
Test CRC calulation method.
Definition: CRC_16_MODBUS.cpp:200
virtual VOID Update(U16 &u16_CRC, U8 u8_Data)
Update CRC with new data value method.
Definition: CRC_16_MODBUS.cpp:157