ConOpSys V2970  P004.07
ANVILEX control operating system
Protocol_MODBUS_Over_UART.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Protocol_MODBUS_Over_UART.h
3 //! @brief Communication protocol MODBUS RTU 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_MODBUS_Over_UART.h $
7 //! $Revision: 2826 $
8 //! $Date: 2021-07-28 13:46:37 +0500 (Mi, 28 Jul 2021) $
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 standard libraries header files
44 //------------------------------------------------------------------------------
45 
46 //------------------------------------------------------------------------------
47 // Include thrid party header files
48 //------------------------------------------------------------------------------
49 
50 //------------------------------------------------------------------------------
51 // Include ConOpSys header files
52 //------------------------------------------------------------------------------
53 
54 #include "Protocol_Base.h"
55 #include "MODBUS_Request_FIFO.h"
56 #include "MODBUS_Request_PDU.h"
57 #include "MODBUS_Response_PDU.h"
58 #include "MODBUS_PDU.h"
59 
60 //------------------------------------------------------------------------------
61 // Global defines
62 //------------------------------------------------------------------------------
63 
64 //! @brief MODBUS RTU 150ms turnaround timeout
65 #define MODBUS_PROTOCOL_TURNAROUND_TIMEOUT ( (F32)0.15f )
66 
67 //! @brief MODBUS RTU symbol time
68 #define MODBUS_SYMBOL_TIME ( (F32)11.0f / (F32)9600.0f )
69 
70 //! @brief MODBUS RTU 3.5 charachter frame timeout
71 #define MODBUS_PROTOCOL_FRAME_TIMEOUT ( ( (F32)3.5f * (F32)11.0f ) / (F32)9600.0f )
72 
73 //! @brief MODBUS RTU 1.5 character symbol timeout
74 #define MODBUS_PROTOCOL_SYMBOL_TIMEOUT ( ( (F32)1.5f * (F32)11.0f ) / (F32)9600.0f )
75 
76 //------------------------------------------------------------------------------
77 // Class definitions
78 //------------------------------------------------------------------------------
79 
80 //! @brief Communication protocol MODBUS RTU over UART class
82 {
83 
84  //----------------------------------------------------------------------------
85  // Public defines, methods and variables
86  //----------------------------------------------------------------------------
87 
88  public:
89 
90  //--------------------------------------------------------------------------
91  // Public defines
92  //--------------------------------------------------------------------------
93 
94  //! @brief MODBUS RTU register mapping entry struct
95  typedef struct
96  {
97 
98  //! @brief ConOpSys parameter ID
100 
101  //! @brief MODBUS RTU address
103 
105 
106  //! @brief MODBUS RTU coil mapping entry struct
107  typedef struct
108  {
109 
110  //! @brief ConOpSys parameter ID
112 
113  //! @brief MODBUS RTU address
115 
117 
118  //! @brief MODBUS RTU input mapping entry struct
119  typedef struct
120  {
121 
122  //! @brief ConOpSys parameter ID
124 
125  //! @brief MODBUS RTU address
127 
129 
130  //! @brief MODBUS FSM state definition
131  typedef enum
132  {
133 
134  //! @brief Init state
135  enum_Init = 0,
136 
137  //! @brief Idle state
138  enum_Idle = 1,
139 
140  //! @brief Frame receiving state
142 
143  //! @brief Frame processing state
145 
146  //! @brief Frame transmitting state
147  enum_Transmitting = 4
148 
150 
151  //--------------------------------------------------------------------------
152  // Public methods
153  //--------------------------------------------------------------------------
154 
155  //!-------------------------------------------------------------------------
156  //! @brief Class constructor method
157  //! @note None
158  //! \par Override
159  //! Not allowed
160  //! @attention Don't call this method directly.
161  //--------------------------------------------------------------------------
162 
164 
165  //!-------------------------------------------------------------------------
166  //! @brief Class destructor method
167  //! @note None
168  //! \par Override
169  //! Not allowed
170  //! @attention Don't call this method directly.
171  //--------------------------------------------------------------------------
172 
174 
175  //!-------------------------------------------------------------------------
176  //! @brief MODBUS initialisation method
177  //! @note None
178  //! @return None
179  //! \par Override
180  //! Not allowed
181  //! @attention None
182  //--------------------------------------------------------------------------
183 
184  VOID Init();
185 
186  //!-------------------------------------------------------------------------
187  //! @brief MODBUS finalisation method
188  //! @note None
189  //! @return None
190  //! \par Override
191  //! Not allowed
192  //! @attention None
193  //--------------------------------------------------------------------------
194 
195  VOID Done();
196 
197  //!-------------------------------------------------------------------------
198  //! @brief MODBUS 1ms cyclic processing method.
199  //! @note None
200  //! @return None
201  //! \par Override
202  //! Not allowed
203  //! @attention None
204  //--------------------------------------------------------------------------
205 
206  virtual VOID Execute_1ms();
207 
208  //!-------------------------------------------------------------------------
209  //! @brief MODBUS cyclic processing method.
210  //! @note None
211  //! @return None
212  //! \par Override
213  //! Not allowed
214  //! @attention None
215  //--------------------------------------------------------------------------
216 
217  virtual VOID Execute();
218 
219  //!-------------------------------------------------------------------------
220  //! @brief Method sends default driver information over specified communication channel.
221  //! @note None
222  //! @param [in] *object_Protocol - Pointer to the connunication channel
223  //! @return None
224  //! \par Override
225  //! Not requered
226  //! @attention None
227  //--------------------------------------------------------------------------
228 
229  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
230 
231  //!-------------------------------------------------------------------------
232  //! @brief Enter in terminal operation mode method.
233  //! @note None
234  //! @return None
235  //! \par Override
236  //! Not allowed
237  //! @attention None
238  //--------------------------------------------------------------------------
239 
240  virtual VOID Enter_Terminal_Mode();
241 
242  //!-------------------------------------------------------------------------
243  //! @brief Enter in protocol operation mode method.
244  //! @note None
245  //! @return None
246  //! \par Override
247  //! Not allowed
248  //! @attention None
249  //--------------------------------------------------------------------------
250 
251  virtual VOID Enter_Protocol_Mode();
252 
253  //!-------------------------------------------------------------------------
254  //! @brief Return terminal operation mode status method.
255  //! @note None
256  //! @return BOOL - Protocol operatuin mode status
257  //! @retval false - Non-terminal mode selected
258  //! @retval true - Terminal mode selected
259  //! \par Override
260  //! Not allowed
261  //! @attention None
262  //--------------------------------------------------------------------------
263 
264  virtual BOOL Is_Terminal_Mode();
265 
266  //!-------------------------------------------------------------------------
267  //! @brief Return protocol operatuin mode status method.
268  //! @note None
269  //! @return BOOL - Protocol operatuin mode status
270  //! @retval false - Non-protocol mode selected
271  //! @retval true - Protocol mode selected
272  //! \par Override
273  //! Not allowed
274  //! @attention None
275  //--------------------------------------------------------------------------
276 
277  virtual BOOL Is_Protocol_Mode();
278 
279  //!-------------------------------------------------------------------------
280  //! @brief Enable show system welcome message method.
281  //! @note None
282  //! @return None
283  //! \par Override
284  //! Not allowed
285  //! @attention None
286  //--------------------------------------------------------------------------
287 
289 
290  //!-------------------------------------------------------------------------
291  //! @brief Disable show system welcome message method.
292  //! @note None
293  //! @return None
294  //! \par Override
295  //! Not allowed
296  //! @attention None
297  //--------------------------------------------------------------------------
298 
300 
301  //!-------------------------------------------------------------------------
302  //! @brief Enable system ready message method.
303  //! @note None
304  //! @return None
305  //! \par Override
306  //! Not allowed
307  //! @attention None
308  //--------------------------------------------------------------------------
309 
311 
312  //!-------------------------------------------------------------------------
313  //! @brief Disable system ready message method.
314  //! @note None
315  //! @return None
316  //! \par Override
317  //! Not allowed
318  //! @attention None
319  //--------------------------------------------------------------------------
320 
322 
323  //!-------------------------------------------------------------------------
324  //! @brief Communication data receive method
325  //! @note None
326  //! @param [in] u8_Receive_Value - Received value
327  //! @return None
328  //! \par Override
329  //! Requered
330  //! @attention None
331  //--------------------------------------------------------------------------
332 
333  virtual VOID Communication_Data_Receive( U8 u8_Receive_Value );
334 
335  //!-------------------------------------------------------------------------
336  //! @brief Communication data receive method
337  //! @note None
338  //! @param [in] void_Receive_Data - Pointer on received data
339  //! @return None
340  //! \par Override
341  //! Requered
342  //! @attention None
343  //--------------------------------------------------------------------------
344 
345  virtual VOID Communication_Data_Receive( VOID *void_Receive_Data );
346 
347  //!-------------------------------------------------------------------------
348  //! @brief Receiveed string processing method
349  //! @note None
350  //! @param [in] *c8_String - Pointer to the null terminated string
351  //! @return None
352  //! \par Override
353  //! Not allowed
354  //! @attention This method called from interrupt
355  //--------------------------------------------------------------------------
356 
357  virtual VOID Receive_String( C8 *c8_String );
358 
359  //!-------------------------------------------------------------------------
360  //! @brief Receiveed string processing method
361  //! @note This method is not used in this object.
362  //! @param [in] *c8_String - Pointer to the null terminated string
363  //! @param [in] u32_Length - Length of the string
364  //! @return None
365  //! \par Override
366  //! Not allowed
367  //! @attention This method called from interrupt
368  //--------------------------------------------------------------------------
369 
370  virtual VOID Receive_String( C8 *c8_String, U32 u32_Length );
371 
372  //!-------------------------------------------------------------------------
373  //! @brief Set node address method
374  //! @note None
375  //! @param [in] u8_Address - New node address
376  //! @return BOOL - operation status
377  //! @retval false - The address assignment is unsuccessful
378  //! @retval true - The address assignment is successful
379  //! \par Override
380  //! Not allowed
381  //! @attention This method called from interrupt
382  //--------------------------------------------------------------------------
383 
384  virtual BOOL Set_Address( U8 u8_Address );
385 
386  //!-------------------------------------------------------------------------
387  //! @brief Transmit boot welcome message method.
388  //! @note None
389  //! @return None
390  //! \par Override
391  //! Not allowed
392  //! @attention None
393  //--------------------------------------------------------------------------
394 
396 
397  //!-------------------------------------------------------------------------
398  //! @brief Transmit boot ready message method.
399  //! @note None
400  //! @return None
401  //! \par Override
402  //! Not allowed
403  //! @attention None
404  //--------------------------------------------------------------------------
405 
407 
408  //----------------------------------------------------------------------------
409  // Protected defines, methods and variables
410  //----------------------------------------------------------------------------
411 
412  protected:
413 
414  //----------------------------------------------------------------------------
415  // Private defines, methods and variables
416  //----------------------------------------------------------------------------
417 
418  private:
419 
420  //--------------------------------------------------------------------------
421  // Protected defines
422  //--------------------------------------------------------------------------
423 
424  typedef struct
425  {
426 
427  //! @brief Log event empty flag
429 
430  //! @brief Log event code
432 
434 
435  //--------------------------------------------------------------------------
436  // Protected methods
437  //--------------------------------------------------------------------------
438 
439 // BOOL Protocol_Parameter_Read_Request(); //!< Parameter read request method.
440 // BOOL Protocol_Parameter_Write_Request(); //!< Parameter write request method.
441 
442  //!-------------------------------------------------------------------------
443  //! @brief The method returns the conOpSys parameter index by modbus register
444  //! @note None
445  //! @param [in] u16_Modbus_Address - Modbus register address
446  //! @param [out] *u32_Parameter_ID - Pointer to the conOpSys parameter index
447  //! @return BOOL - Operation status
448  //! @retval false - Parameter not found
449  //! @retval true - Parameter found successfully
450  //! \par Override
451  //! Not allowed
452  //! @attention This method called from interrupt
453  //--------------------------------------------------------------------------
454 
455  BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Register( U16 u16_Modbus_Address, U32 *u32_Parameter_ID );
456 
457  //!-------------------------------------------------------------------------
458  //! @brief The method returns the conOpSys parameter index by modbus coil
459  //! @note None
460  //! @param [in] u16_MODBUS_RTU_Coil - Modbus coil address
461  //! @param [out] *u32_Parameter_ID - Pointer to the conOpSys parameter index
462  //! @return BOOL - Operation status
463  //! @retval false - Parameter not found
464  //! @retval true - Parameter found successfully
465  //! \par Override
466  //! Not allowed
467  //! @attention This method called from interrupt
468  //--------------------------------------------------------------------------
469 
470  BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Coil( U16 u16_MODBUS_RTU_Coil, U32 *u32_Parameter_ID );
471 
472  //!-------------------------------------------------------------------------
473  //! @brief The method returns the conOpSys parameter index by modbus coil
474  //! @note None
475  //! @param [in] u16_MODBUS_RTU_Input - Modbus input address
476  //! @param [out] *u32_Parameter_ID - Pointer to the conOpSys parameter index
477  //! @return BOOL - Operation status
478  //! @retval false - Parameter not found
479  //! @retval true - Parameter found successfully
480  //! \par Override
481  //! Not allowed
482  //! @attention This method called from interrupt
483  //--------------------------------------------------------------------------
484 
485  BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Input( U16 u16_MODBUS_RTU_Input, U32 *u32_Parameter_ID );
486 
487  //!-------------------------------------------------------------------------
488  //! @brief Read coils request processing method.
489  //! @note None
490  //! @return BOOL - Operation status
491  //! @retval false - Read error
492  //! @retval true - Reading was successful
493  //! \par Override
494  //! Not allowed
495  //! @attention This method called from interrupt
496  //--------------------------------------------------------------------------
497 
498  BOOL Read_Coils();
499 
500  //!-------------------------------------------------------------------------
501  //! @brief Read discrete inputs request processing method.
502  //! @note None
503  //! @return BOOL - Operation status
504  //! @retval false - Read error
505  //! @retval true - Reading was successful
506  //! \par Override
507  //! Not allowed
508  //! @attention This method called from interrupt
509  //--------------------------------------------------------------------------
510 
512 
513  //!-------------------------------------------------------------------------
514  //! @brief Read holding registers inputs request processing method.
515  //! @note None
516  //! @return BOOL - Operation status
517  //! @retval false - Read error
518  //! @retval true - Reading was successful
519  //! \par Override
520  //! Not allowed
521  //! @attention This method called from interrupt
522  //--------------------------------------------------------------------------
523 
525 
526  //!-------------------------------------------------------------------------
527  //! @brief Read input register request processing method.
528  //! @note This method is not used in this object.
529  //! @return BOOL - Operation status
530  //! @retval false - Read error
531  //! @retval true - Reading was successful
532  //! \par Override
533  //! Not allowed
534  //! @attention This method called from interrupt
535  //--------------------------------------------------------------------------
536 
538 
539  //!-------------------------------------------------------------------------
540  //! @brief Write single coil request processing method.
541  //! @note None
542  //! @return BOOL - Operation status
543  //! @retval false - Read error
544  //! @retval true - Reading was successful
545  //! \par Override
546  //! Not allowed
547  //! @attention This method called from interrupt
548  //--------------------------------------------------------------------------
549 
551 
552  //!-------------------------------------------------------------------------
553  //! @brief Write single register request processing method.
554  //! @note None
555  //! @return BOOL - Operation status
556  //! @retval false - Read error
557  //! @retval true - Reading was successful
558  //! \par Override
559  //! Not allowed
560  //! @attention This method called from interrupt
561  //--------------------------------------------------------------------------
562 
564 
565  //!-------------------------------------------------------------------------
566  //! @brief Read exception status request method.
567  //! @note This method is not used in this object.
568  //! @return BOOL - Operation status
569  //! @retval false - Read error
570  //! @retval true - Reading was successful
571  //! \par Override
572  //! Not allowed
573  //! @attention This method called from interrupt
574  //--------------------------------------------------------------------------
575 
577 
578  //!-------------------------------------------------------------------------
579  //! @brief Diagnostics request processing method.
580  //! @note This method is not used in this object.
581  //! @return BOOL - Operation status
582  //! @retval false - Method not implemented
583  //! \par Override
584  //! Not allowed
585  //! @attention This method called from interrupt
586  //--------------------------------------------------------------------------
587 
588  BOOL Diagnostic();
589 
590  //!-------------------------------------------------------------------------
591  //! @brief Get communication event counter request processing method.
592  //! @note None
593  //! @return BOOL - Operation status
594  //! @retval false - Operation faild
595  //! @retval true - Operation done
596  //! \par Override
597  //! Not allowed
598  //! @attention This method called from interrupt
599  //--------------------------------------------------------------------------
600 
602 
603  //!-------------------------------------------------------------------------
604  //! @brief Get communication log request processing method.
605  //! @note None
606  //! @return BOOL - Operation status
607  //! @retval false - Operation faild
608  //! @retval true - Operation done
609  //! \par Override
610  //! Not allowed
611  //! @attention This method called from interrupt
612  //--------------------------------------------------------------------------
613 
615 
616  //!-------------------------------------------------------------------------
617  //! @brief Write multiple coils request processing method.
618  //! @note None
619  //! @return BOOL - Operation status
620  //! @retval false - Writing faild
621  //! @retval true - Writing done
622  //! \par Override
623  //! Not allowed
624  //! @attention This method called from interrupt
625  //--------------------------------------------------------------------------
626 
628 
629  //!-------------------------------------------------------------------------
630  //! @brief Write multiple registers processing method.
631  //! @note None
632  //! @return BOOL - Operation status
633  //! @retval false - Operation faild
634  //! @retval true - Operation done
635  //! \par Override
636  //! Not allowed
637  //! @attention This method called from interrupt
638  //--------------------------------------------------------------------------
639 
641 
642  //!-------------------------------------------------------------------------
643  //! @brief Report server ID processing method.
644  //! @note This method is not used in this object.
645  //! @return BOOL - Operation status
646  //! @retval false - Operation faild
647  //! @retval true - Operation done
648  //! \par Override
649  //! Not allowed
650  //! @attention This method called from interrupt
651  //--------------------------------------------------------------------------
652 
654 
655  //!-------------------------------------------------------------------------
656  //! @brief Read file record processing method.
657  //! @note This method is not used in this object.
658  //! @return BOOL - Operation status
659  //! @retval false - Operation faild
660  //! @retval true - Operation done
661  //! \par Override
662  //! Not allowed
663  //! @attention This method called from interrupt
664  //--------------------------------------------------------------------------
665 
667 
668  //!-------------------------------------------------------------------------
669  //! @brief Write file record processing method.
670  //! @note This method is not used in this object.
671  //! @return BOOL - Operation status
672  //! @retval false - Operation faild
673  //! @retval true - Operation done
674  //! \par Override
675  //! Not allowed
676  //! @attention This method called from interrupt
677  //--------------------------------------------------------------------------
678 
680 
681  //!-------------------------------------------------------------------------
682  //! @brief Mask write register processing method.
683  //! @note This method is not used in this object.
684  //! @return BOOL - Operation status
685  //! @retval false - Operation faild
686  //! @retval true - Operation done
687  //! \par Override
688  //! Not allowed
689  //! @attention This method called from interrupt
690  //--------------------------------------------------------------------------
691 
693 
694  //!-------------------------------------------------------------------------
695  //! @brief Read mask register processing method.
696  //! @note None
697  //! @return BOOL - Operation status
698  //! @retval false - Operation faild
699  //! @retval true - Operation done
700  //! \par Override
701  //! Not allowed
702  //! @attention This method called from interrupt
703  //--------------------------------------------------------------------------
704 
706 
707  //!-------------------------------------------------------------------------
708  //! @brief Read FIFO queue processing method.
709  //! @note This method is not used in this object.
710  //! @return BOOL - Operation status
711  //! @retval false - Operation faild
712  //! @retval true - Operation done
713  //! \par Override
714  //! Not allowed
715  //! @attention This method called from interrupt
716  //--------------------------------------------------------------------------
717 
719 
720  //!-------------------------------------------------------------------------
721  //! @brief Encapsulated interface transport processing method.
722  //! @note None
723  //! @return BOOL - Processing status
724  //! @retval false - Processing faild
725  //! @retval true - Processing done
726  //! \par Override
727  //! Not allowed
728  //! @attention This method called from interrupt
729  //--------------------------------------------------------------------------
730 
732 
733  //!-------------------------------------------------------------------------
734  //! @brief CANopen generala reference processing method.
735  //! @note None
736  //! @return BOOL - Processing status
737  //! @retval false - Processing faild
738  //! @retval true - Processing done
739  //! \par Override
740  //! Not allowed
741  //! @attention This method called from interrupt
742  //--------------------------------------------------------------------------
743 
745 
746  //!-------------------------------------------------------------------------
747  //! @brief Read device identification processing method.
748  //! @note This method is not used in this object.
749  //! @return BOOL - Reading status
750  //! @retval false - Reading faild
751  //! @retval true - Reading done
752  //! \par Override
753  //! Not allowed
754  //! @attention This method called from interrupt
755  //--------------------------------------------------------------------------
756 
758 
759  //!-------------------------------------------------------------------------
760  //! @brief Log slave read input registers error processing method.
761  //! @note This method is not used in this object.
762  //! @return BOOL - Reading status
763  //! @retval false - Reading faild
764  //! @retval true - Reading done
765  //! \par Override
766  //! Not allowed
767  //! @attention This method called from interrupt
768  //--------------------------------------------------------------------------
769 
771 
772 // VOID Protocol_Transmit_Error_Code( TProtocol_Return_Code enum_Return_Code ); //!< Transmit error code
773 // VOID Protocol_Transmit_String( C8 *c8_String ); //!< Transmit string
774 
775  //--------------------------------------------------------------------------
776  // Private variables
777  //--------------------------------------------------------------------------
778 
779  //! @brief RX buffer
780  U8 u8_RX_Buffer[ 256 ] = { (U8)0x00 };
781 
782  //! @brief RX buffer index
784 
785 // TMODBUS_Request_FIFO struct_Request_FIFO;
786 
787  //! @brief Request PDU object
789 
790  //! @brief Responce PDU object
792 
793  //! @brief Actual MODBUS address
795 
796  //! @brief Actual MODBUS baudrate
798 
800 
801  //! @brief Modbus FSM state
803 
804  //! @brief Event log buffer
806 
807  //--------------------------------------------------------------------------
808  // PDU frame counters
809  //--------------------------------------------------------------------------
810 
811  //! @brief Communication event counter
813 
814  //! @brief Slave read input register error counter
816 
817  //! @brief Functional code 0x01 request counter
819 
820  //! @brief Functional code 0x02 request counter
822 
823  //! @brief Functional code 0x03 request counter
825 
826  //! @brief Functional code 0x04 request counter
828 
829  //! @brief Functional code 0x05 request counter
831 
832  //! @brief Functional code 0x06 request counter
834 
835  //! @brief Functional code 0x07 request counter
837 
838  //! @brief Functional code 0x08 request counter
840 
841  //! @brief Functional code 0x08 0x00 request counter
843 
844  //! @brief Functional code 0x08 0x01 request counter
846 
847  //! @brief Functional code 0x08 0x02 request counter
849 
850  //! @brief Functional code 0x08 0x03 request counter
852 
853  //! @brief Functional code 0x08 0x04 request counter
855 
856  //! @brief Functional code 0x08 0x05 request counter
858 
859  //! @brief Functional code 0x08 0x06 request counter
861 
862  //! @brief Functional code 0x08 0x07 request counter
864 
865  //! @brief Functional code 0x08 0x08 request counter
867 
868  //! @brief Functional code 0x08 0x09 request counter
870 
871  //! @brief Functional code 0x08 0x0A request counter
873 
874  //! @brief Functional code 0x08 0x0B request counter
876 
877  //! @brief Functional code 0x08 0x0C request counter
879 
880  //! @brief Functional code 0x08 0x0D request counter
882 
883  //! @brief Functional code 0x08 0x0E request counter
885 
886  //! @brief Functional code 0x08 0x0F request counter
888 
889  //! @brief Functional code 0x08 0x10 request counter
891 
892  //! @brief Functional code 0x08 0x11 request counter
894 
895  //! @brief Functional code 0x08 0x12 request counter
897 
898  //! @brief Functional code 0x08 0x13 request counter
900 
901  //! @brief Functional code 0x0B request counter
903 
904  //! @brief Functional code 0x0C request counter
906 
907  //! @brief Functional code 0x0F request counter
909 
910  //! @brief Functional code 0x10 request counter
912 
913  //! @brief Functional code 0x11 request counter
915 
916  //! @brief Functional code 0x14 request counter
918 
919  //! @brief Functional code 0x15 request counter
921 
922  //! @brief Functional code 0x16 request counter
924 
925  //! @brief Functional code 0x17 request counter
927 
928  //! @brief Functional code 0x18 request counter
930 
931  //! @brief Functional code 0x2B request counter
933 
934  //! @brief Functional code 0x2B 0x0C request counter
936 
937  //! @brief Functional code 0x2B 0x0D request counter
939 
940 };
941 
942 //------------------------------------------------------------------------------
943 // End of file
944 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
unsigned long long U64
Binary 64-Bit unsigned integer datatype defenition.
Definition: Defines.h:213
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
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
char C8
ASCII 8-Bit char datatype defenition.
Definition: Defines.h:156
Communication protocol MODBUS over UART class header file.
MODBUS request FIFO class header file.
MODBUS request PDU class header file.
MODBUS response PDU class header file.
Communication protocol base class header file.
MODBUS request PDU class.
Definition: MODBUS_Request_PDU.h:54
MODBUS responce PDU class.
Definition: MODBUS_Response_PDU.h:54
Definition: Protocol_Base.h:57
Communication protocol MODBUS RTU over UART class.
Definition: Protocol_MODBUS_Over_UART.h:82
VOID Show_System_Ready_Message_Disable()
Disable system ready message method.
Definition: Protocol_MODBUS_Over_UART.cpp:209
U64 u64_Last_Symbol_Timestamp
Definition: Protocol_MODBUS_Over_UART.h:799
VOID Done()
MODBUS finalisation method.
Definition: Protocol_MODBUS_Over_UART.cpp:122
TProtocol_MODBUS_Over_UART()
Class constructor method.
Definition: Protocol_MODBUS_Over_UART.cpp:83
U32 u32_Functional_Code_0x15_Request_Counter
Functional code 0x15 request counter.
Definition: Protocol_MODBUS_Over_UART.h:920
virtual BOOL Set_Address(U8 u8_Address)
Set node address method.
Definition: Protocol_MODBUS_Over_UART.cpp:4822
U32 u32_Functional_Code_0x08_0x06_Request_Counter
Functional code 0x08 0x06 request counter.
Definition: Protocol_MODBUS_Over_UART.h:860
U32 u32_Functional_Code_0x2B_Request_Counter
Functional code 0x2B request counter.
Definition: Protocol_MODBUS_Over_UART.h:932
BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Register(U16 u16_Modbus_Address, U32 *u32_Parameter_ID)
The method returns the conOpSys parameter index by modbus register.
Definition: Protocol_MODBUS_Over_UART.cpp:1268
BOOL Write_Single_Register()
Write single register request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3271
BOOL Diagnostic()
Diagnostics request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3309
U32 u32_Functional_Code_0x03_Request_Counter
Functional code 0x03 request counter.
Definition: Protocol_MODBUS_Over_UART.h:824
U8 u8_MODBUS_Address
Actual MODBUS address.
Definition: Protocol_MODBUS_Over_UART.h:794
TMODBUS_State fsm_MODBUS_State
Modbus FSM state.
Definition: Protocol_MODBUS_Over_UART.h:802
U32 u32_Functional_Code_0x08_0x03_Request_Counter
Functional code 0x08 0x03 request counter.
Definition: Protocol_MODBUS_Over_UART.h:851
U32 u32_Functional_Code_0x08_0x00_Request_Counter
Functional code 0x08 0x00 request counter.
Definition: Protocol_MODBUS_Over_UART.h:842
U32 u32_Functional_Code_0x06_Request_Counter
Functional code 0x06 request counter.
Definition: Protocol_MODBUS_Over_UART.h:833
U32 u32_Functional_Code_0x08_0x01_Request_Counter
Functional code 0x08 0x01 request counter.
Definition: Protocol_MODBUS_Over_UART.h:845
TMODBUS_Response_PDU object_Response_PDU
Responce PDU object.
Definition: Protocol_MODBUS_Over_UART.h:791
U32 u32_Functional_Code_0x08_0x09_Request_Counter
Functional code 0x08 0x09 request counter.
Definition: Protocol_MODBUS_Over_UART.h:869
U32 u32_Functional_Code_0x08_0x0C_Request_Counter
Functional code 0x08 0x0C request counter.
Definition: Protocol_MODBUS_Over_UART.h:878
U32 u32_Functional_Code_0x08_0x0B_Request_Counter
Functional code 0x08 0x0B request counter.
Definition: Protocol_MODBUS_Over_UART.h:875
BOOL Read_Holding_Registers()
Read holding registers inputs request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:1926
VOID Transmit_System_Ready_Message()
Transmit boot ready message method.
Definition: Protocol_MODBUS_Over_UART.cpp:313
BOOL Report_Server_ID()
Report server ID processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4012
BOOL Read_FIFO_Queue()
Read FIFO queue processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4318
U32 u32_Functional_Code_0x04_Request_Counter
Functional code 0x04 request counter.
Definition: Protocol_MODBUS_Over_UART.h:827
virtual VOID Enter_Terminal_Mode()
Enter in terminal operation mode method.
Definition: Protocol_MODBUS_Over_UART.cpp:130
BOOL Write_File_Record()
Write file record processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4052
U32 u32_Functional_Code_0x2B_0x0C_Request_Counter
Functional code 0x2B 0x0C request counter.
Definition: Protocol_MODBUS_Over_UART.h:935
U32 u32_Functional_Code_0x05_Request_Counter
Functional code 0x05 request counter.
Definition: Protocol_MODBUS_Over_UART.h:830
U32 u32_Functional_Code_0x18_Request_Counter
Functional code 0x18 request counter.
Definition: Protocol_MODBUS_Over_UART.h:929
BOOL Encapsulated_Interface_Transport()
Encapsulated interface transport processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4337
U32 u32_Functional_Code_0x08_0x11_Request_Counter
Functional code 0x08 0x11 request counter.
Definition: Protocol_MODBUS_Over_UART.h:893
virtual VOID Enter_Protocol_Mode()
Enter in protocol operation mode method.
Definition: Protocol_MODBUS_Over_UART.cpp:141
U32 u32_Functional_Code_0x0F_Request_Counter
Functional code 0x0F request counter.
Definition: Protocol_MODBUS_Over_UART.h:908
BOOL Write_Single_Coil()
Write single coil request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3154
BOOL Read_Discrete_Inputs()
Read discrete inputs request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:1710
U32 u32_Functional_Code_0x02_Request_Counter
Functional code 0x02 request counter.
Definition: Protocol_MODBUS_Over_UART.h:821
virtual VOID Execute()
MODBUS cyclic processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:509
U32 u32_Functional_Code_0x08_0x02_Request_Counter
Functional code 0x08 0x02 request counter.
Definition: Protocol_MODBUS_Over_UART.h:848
~TProtocol_MODBUS_Over_UART()
Class destructor method.
Definition: Protocol_MODBUS_Over_UART.cpp:102
VOID Init()
MODBUS initialisation method.
Definition: Protocol_MODBUS_Over_UART.cpp:110
U32 u32_Functional_Code_0x0B_Request_Counter
Functional code 0x0B request counter.
Definition: Protocol_MODBUS_Over_UART.h:902
U32 u32_Functional_Code_0x10_Request_Counter
Functional code 0x10 request counter.
Definition: Protocol_MODBUS_Over_UART.h:911
U32 u32_RX_Buffer_Index
RX buffer index.
Definition: Protocol_MODBUS_Over_UART.h:783
TMODBUS_Event_Log_Record struct_Event_Log[64]
Event log buffer.
Definition: Protocol_MODBUS_Over_UART.h:805
U32 u32_Functional_Code_0x17_Request_Counter
Functional code 0x17 request counter.
Definition: Protocol_MODBUS_Over_UART.h:926
virtual BOOL Is_Protocol_Mode()
Return protocol operatuin mode status method.
Definition: Protocol_MODBUS_Over_UART.cpp:164
BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Input(U16 u16_MODBUS_RTU_Input, U32 *u32_Parameter_ID)
The method returns the conOpSys parameter index by modbus coil.
Definition: Protocol_MODBUS_Over_UART.cpp:1427
VOID Show_System_Ready_Message_Enable()
Enable system ready message method.
Definition: Protocol_MODBUS_Over_UART.cpp:198
virtual VOID Communication_Data_Receive(U8 u8_Receive_Value)
Communication data receive method.
Definition: Protocol_MODBUS_Over_UART.cpp:221
VOID Show_System_Welcome_Message_Disable()
Disable show system welcome message method.
Definition: Protocol_MODBUS_Over_UART.cpp:187
U8 u8_RX_Buffer[256]
RX buffer.
Definition: Protocol_MODBUS_Over_UART.h:780
BOOL CANopen_General_Reference()
CANopen generala reference processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4406
U32 u32_Functional_Code_0x08_0x13_Request_Counter
Functional code 0x08 0x13 request counter.
Definition: Protocol_MODBUS_Over_UART.h:899
U32 u32_MODBUS_Baudrate
Actual MODBUS baudrate.
Definition: Protocol_MODBUS_Over_UART.h:797
BOOL Write_Multiple_Registers()
Write multiple registers processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3599
virtual VOID Receive_String(C8 *c8_String)
Receiveed string processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:280
U32 u32_Functional_Code_0x16_Request_Counter
Functional code 0x16 request counter.
Definition: Protocol_MODBUS_Over_UART.h:923
U32 u32_Functional_Code_0x08_0x04_Request_Counter
Functional code 0x08 0x04 request counter.
Definition: Protocol_MODBUS_Over_UART.h:854
BOOL Read_Device_Identefication()
Read device identification processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4425
U32 u32_Slave_Read_Input_Register_Error_Counter
Slave read input register error counter.
Definition: Protocol_MODBUS_Over_UART.h:815
BOOL Get_Communication_Event_Log()
Get communication log request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3364
BOOL Read_Coils()
Read coils request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:1506
BOOL Read_File_Record()
Read file record processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4033
U32 u32_Functional_Code_0x08_Request_Counter
Functional code 0x08 request counter.
Definition: Protocol_MODBUS_Over_UART.h:839
virtual BOOL Is_Terminal_Mode()
Return terminal operation mode status method.
Definition: Protocol_MODBUS_Over_UART.cpp:152
U32 u32_Functional_Code_0x08_0x07_Request_Counter
Functional code 0x08 0x07 request counter.
Definition: Protocol_MODBUS_Over_UART.h:863
U32 u32_Functional_Code_0x08_0x05_Request_Counter
Functional code 0x08 0x05 request counter.
Definition: Protocol_MODBUS_Over_UART.h:857
BOOL Get_Communication_Event_Counter()
Get communication event counter request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3330
U32 u32_Functional_Code_0x11_Request_Counter
Functional code 0x11 request counter.
Definition: Protocol_MODBUS_Over_UART.h:914
TMODBUS_State
MODBUS FSM state definition.
Definition: Protocol_MODBUS_Over_UART.h:132
@ enum_Processing
Frame processing state.
Definition: Protocol_MODBUS_Over_UART.h:144
@ enum_Idle
Idle state.
Definition: Protocol_MODBUS_Over_UART.h:138
@ enum_Init
Init state.
Definition: Protocol_MODBUS_Over_UART.h:135
@ enum_Transmitting
Frame transmitting state.
Definition: Protocol_MODBUS_Over_UART.h:147
@ enum_Receiving
Frame receiving state.
Definition: Protocol_MODBUS_Over_UART.h:141
BOOL Write_Multiple_Coils()
Write multiple coils request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:3441
BOOL Read_Input_Register()
Read input register request processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:2439
VOID Log_Slave_Read_Input_Register_Error()
Log slave read input registers error processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4444
TMODBUS_Request_PDU object_Request_PDU
Request PDU object.
Definition: Protocol_MODBUS_Over_UART.h:788
U32 u32_Functional_Code_0x2B_0x0D_Request_Counter
Functional code 0x2B 0x0D request counter.
Definition: Protocol_MODBUS_Over_UART.h:938
U32 u32_Functional_Code_0x08_0x10_Request_Counter
Functional code 0x08 0x10 request counter.
Definition: Protocol_MODBUS_Over_UART.h:890
U32 u32_Functional_Code_0x08_0x0A_Request_Counter
Functional code 0x08 0x0A request counter.
Definition: Protocol_MODBUS_Over_UART.h:872
U32 u32_Functional_Code_0x08_0x12_Request_Counter
Functional code 0x08 0x12 request counter.
Definition: Protocol_MODBUS_Over_UART.h:896
VOID Show_System_Welcome_Message_Enable()
Enable show system welcome message method.
Definition: Protocol_MODBUS_Over_UART.cpp:176
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Method sends default driver information over specified communication channel.
Definition: Protocol_MODBUS_Over_UART.cpp:4556
U32 u32_Communication_Event_Counter
Communication event counter.
Definition: Protocol_MODBUS_Over_UART.h:812
U32 u32_Functional_Code_0x08_0x08_Request_Counter
Functional code 0x08 0x08 request counter.
Definition: Protocol_MODBUS_Over_UART.h:866
VOID Transmit_Boot_Welcome_Message()
Transmit boot welcome message method.
Definition: Protocol_MODBUS_Over_UART.cpp:302
BOOL Mask_Write_Register()
Mask write register processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4071
BOOL Read_Write_Multiple_Registers()
Read mask register processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:4090
U32 u32_Functional_Code_0x14_Request_Counter
Functional code 0x14 request counter.
Definition: Protocol_MODBUS_Over_UART.h:917
U32 u32_Functional_Code_0x08_0x0E_Request_Counter
Functional code 0x08 0x0E request counter.
Definition: Protocol_MODBUS_Over_UART.h:884
BOOL Read_Exception_Status()
Read exception status request method.
Definition: Protocol_MODBUS_Over_UART.cpp:3290
U32 u32_Functional_Code_0x01_Request_Counter
Functional code 0x01 request counter.
Definition: Protocol_MODBUS_Over_UART.h:818
U32 u32_Functional_Code_0x07_Request_Counter
Functional code 0x07 request counter.
Definition: Protocol_MODBUS_Over_UART.h:836
U32 u32_Functional_Code_0x0C_Request_Counter
Functional code 0x0C request counter.
Definition: Protocol_MODBUS_Over_UART.h:905
BOOL Get_ConOpSys_Parameter_Index_By_MODBUS_Coil(U16 u16_MODBUS_RTU_Coil, U32 *u32_Parameter_ID)
The method returns the conOpSys parameter index by modbus coil.
Definition: Protocol_MODBUS_Over_UART.cpp:1347
virtual VOID Execute_1ms()
MODBUS 1ms cyclic processing method.
Definition: Protocol_MODBUS_Over_UART.cpp:324
U32 u32_Functional_Code_0x08_0x0D_Request_Counter
Functional code 0x08 0x0D request counter.
Definition: Protocol_MODBUS_Over_UART.h:881
U32 u32_Functional_Code_0x08_0x0F_Request_Counter
Functional code 0x08 0x0F request counter.
Definition: Protocol_MODBUS_Over_UART.h:887
Definition: Protocol_MODBUS_Over_UART.h:425
BOOL bool_Empty
Log event empty flag.
Definition: Protocol_MODBUS_Over_UART.h:428
U8 u8_Event_Field
Log event code.
Definition: Protocol_MODBUS_Over_UART.h:431
MODBUS RTU coil mapping entry struct.
Definition: Protocol_MODBUS_Over_UART.h:108
U16 u16_MODBUS_RTU_Coil_Address
MODBUS RTU address.
Definition: Protocol_MODBUS_Over_UART.h:114
U32 u32_Parameter_ID
ConOpSys parameter ID.
Definition: Protocol_MODBUS_Over_UART.h:111
MODBUS RTU input mapping entry struct.
Definition: Protocol_MODBUS_Over_UART.h:120
U32 u32_Parameter_ID
ConOpSys parameter ID.
Definition: Protocol_MODBUS_Over_UART.h:123
U16 u16_MODBUS_RTU_Input_Address
MODBUS RTU address.
Definition: Protocol_MODBUS_Over_UART.h:126
MODBUS RTU register mapping entry struct.
Definition: Protocol_MODBUS_Over_UART.h:96
U16 u16_MODBUS_RTU_Address
MODBUS RTU address.
Definition: Protocol_MODBUS_Over_UART.h:102
U32 u32_Parameter_ID
ConOpSys parameter ID.
Definition: Protocol_MODBUS_Over_UART.h:99