ConOpSys V2970  P004.07
ANVILEX control operating system
Protocol_IP_Over_ETHERNET.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Protocol_IP_Over_ETHERNET.h
3 //! @brief Communication protocol IP over Ethernet 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/Common/PRT_Sensor.h $
7 //! $Revision: 2075 $
8 //! $Date: 2020-09-12 14:00:31 +0500 (Sa, 12 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 #pragma once
41 
42 //------------------------------------------------------------------------------
43 // Include system files
44 //------------------------------------------------------------------------------
45 
46 #include "Protocol_Base.h"
47 
48 //------------------------------------------------------------------------------
49 //
50 //------------------------------------------------------------------------------
51 
52 #include "ip_addr.h"
53 #include "udp.h"
54 
55 //------------------------------------------------------------------------------
56 // Class definitions
57 //------------------------------------------------------------------------------
58 
59 //! @brief Communication protocol IP over ETHERNET class
61 {
62 
63  //----------------------------------------------------------------------------
64  // Public defines, methods and variables
65  //----------------------------------------------------------------------------
66 
67  public:
68 
69  //!-------------------------------------------------------------------------
70  //! @brief Class constructor method.
71  //! @note None
72  //! \par Override
73  //! Not allowed
74  //! @attention Don't call this method directly.
75  //--------------------------------------------------------------------------
76 
78 
79  //!-------------------------------------------------------------------------
80  //! @brief Class destructor method.
81  //! @note None
82  //! \par Override
83  //! Not allowed
84  //! @attention Don't call this method directly.
85  //--------------------------------------------------------------------------
86 
88 
89  // Initialisation and finalisation
90  VOID Init();
91  VOID Done();
92  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
93 
94  // Protocol status methods
95  virtual VOID Enter_Terminal_Mode();
96  virtual VOID Enter_Protocol_Mode();
97  virtual BOOL Is_Terminal_Mode();
98  virtual BOOL Is_Protocol_Mode();
99 
100  // Receive related methods
101 // virtual VOID Receive_Char( C8 c8_Character );
102  virtual VOID Receive_String( C8 *c8_String );
103  virtual VOID Receive_String( C8 *c8_String, U32 u32_Length );
104 
105  // Execute method
106  virtual VOID Execute();
107  virtual VOID Execute_1ms();
108 
109  //----------------------------------------------------------------------------
110  // Protected defines, methods and variables
111  //----------------------------------------------------------------------------
112 
113  protected:
114 
115  //----------------------------------------------------------------------------
116  // Private defines, methods and variables
117  //----------------------------------------------------------------------------
118 
119  private:
120 
122 
123  //! @brief Global network interface structure
124  struct netif gnetif;
125 
126  //! @brief IP address
127  uint8_t IP_ADDRESS[ 4 ];
128 
129  //! @brief Netmask address
130  uint8_t NETMASK_ADDRESS[ 4 ];
131 
132  //! @brief Gateway address
133  uint8_t GATEWAY_ADDRESS[ 4 ];
134  ip4_addr_t ipaddr;
135  ip4_addr_t netmask;
136  ip4_addr_t gw;
137 
138  //! @brief Pointer to PCB structure to use with UDP
139  udp_pcb *pcb_UDP;
140 
141 };
142 
143 //------------------------------------------------------------------------------
144 // End Of File
145 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
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
Communication protocol base class header file.
Definition: Protocol_Base.h:57
Communication protocol IP over ETHERNET class.
Definition: Protocol_IP_Over_ETHERNET.h:61
uint8_t GATEWAY_ADDRESS[4]
Gateway address.
Definition: Protocol_IP_Over_ETHERNET.h:133
virtual BOOL Is_Protocol_Mode()
Protocol mode operation status method.
Definition: Protocol_IP_Over_ETHERNET.cpp:862
uint8_t IP_ADDRESS[4]
IP address.
Definition: Protocol_IP_Over_ETHERNET.h:127
uint8_t NETMASK_ADDRESS[4]
Netmask address.
Definition: Protocol_IP_Over_ETHERNET.h:130
virtual VOID Enter_Terminal_Mode()
Enter terminal mode method.
Definition: Protocol_IP_Over_ETHERNET.cpp:828
virtual VOID Execute()
Background cyclic execution method.
Definition: Protocol_IP_Over_ETHERNET.cpp:883
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Send information about protocol method.
Definition: Protocol_IP_Over_ETHERNET.cpp:954
VOID Done()
Definition: Protocol_IP_Over_ETHERNET.cpp:813
struct netif gnetif
Global network interface structure.
Definition: Protocol_IP_Over_ETHERNET.h:124
virtual VOID Execute_1ms()
System task 1ms cyclic execution method.
Definition: Protocol_IP_Over_ETHERNET.cpp:909
ip4_addr_t gw
Definition: Protocol_IP_Over_ETHERNET.h:136
virtual VOID Receive_String(C8 *c8_String)
Receive string.
Definition: Protocol_IP_Over_ETHERNET.cpp:932
virtual VOID Enter_Protocol_Mode()
Enter protocol mode method.
Definition: Protocol_IP_Over_ETHERNET.cpp:839
virtual BOOL Is_Terminal_Mode()
Terminal mode operation status method.
Definition: Protocol_IP_Over_ETHERNET.cpp:850
VOID Process_UDP()
Definition: Protocol_IP_Over_ETHERNET.cpp:874
ip4_addr_t netmask
Definition: Protocol_IP_Over_ETHERNET.h:135
TProtocol_IP_Over_ETHERNET()
Class constructor method.
Definition: Protocol_IP_Over_ETHERNET.cpp:659
~TProtocol_IP_Over_ETHERNET()
Class destructor method.
Definition: Protocol_IP_Over_ETHERNET.cpp:686
VOID Init()
Definition: Protocol_IP_Over_ETHERNET.cpp:694
ip4_addr_t ipaddr
Definition: Protocol_IP_Over_ETHERNET.h:134
udp_pcb * pcb_UDP
Pointer to PCB structure to use with UDP.
Definition: Protocol_IP_Over_ETHERNET.h:139
Definition: netif.h:260