0
|
1 |
/*
|
|
2 |
* Copyright (c) 2001,2016 Mario de Sousa (msousa@fe.up.pt)
|
|
3 |
*
|
|
4 |
* This file is part of the Modbus library for Beremiz and matiec.
|
|
5 |
*
|
|
6 |
* This Modbus library is free software: you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful, but
|
|
12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
|
14 |
* General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU Lesser General Public License
|
|
17 |
* along with this Modbus library. If not, see <http://www.gnu.org/licenses/>.
|
|
18 |
*
|
|
19 |
* This code is made available on the understanding that it will not be
|
|
20 |
* used in safety-critical situations without a full and competent review.
|
|
21 |
*/
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
#ifndef MODBUS_LAYER1_H
|
|
26 |
#define MODBUS_LAYER1_H
|
|
27 |
|
|
28 |
#include <time.h> /* struct timespec data type */
|
|
29 |
|
|
30 |
#include "mb_types.h" /* get the data types */
|
|
31 |
#include "mb_addr.h" /* get definitions of common variable types */
|
|
32 |
|
|
33 |
|
|
34 |
/* Define max registers and bits */
|
|
35 |
#define MAX_READ_BITS 2000 /* Functions 0x01 and 0x02 */
|
|
36 |
#define MAX_READ_REGS 125 /* Functions 0x03 and 0x04 */
|
|
37 |
#define MAX_WRITE_COILS 1968 /* Function 0x0F */
|
|
38 |
#define MAX_WRITE_REGS 123 /* Function 0x10 */
|
|
39 |
|
|
40 |
|
|
41 |
/* Declare TCP layer1 functions */
|
|
42 |
#define modbus_write modbus_tcp_write
|
|
43 |
#define modbus_read modbus_tcp_read
|
|
44 |
#define modbus_init modbus_tcp_init
|
|
45 |
#define modbus_done modbus_tcp_done
|
|
46 |
#define modbus_connect modbus_tcp_connect
|
|
47 |
#define modbus_listen modbus_tcp_listen
|
|
48 |
#define modbus_close modbus_tcp_close
|
|
49 |
#define modbus_silence_init modbus_tcp_silence_init
|
|
50 |
#define modbus_get_min_timeout modbus_tcp_get_min_timeout
|
|
51 |
|
|
52 |
#include "mb_layer1_prototypes.h"
|
|
53 |
|
|
54 |
#undef modbus_write
|
|
55 |
#undef modbus_read
|
|
56 |
#undef modbus_init
|
|
57 |
#undef modbus_done
|
|
58 |
#undef modbus_connect
|
|
59 |
#undef modbus_listen
|
|
60 |
#undef modbus_close
|
|
61 |
#undef modbus_silence_init
|
|
62 |
#undef modbus_get_min_timeout
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
/* Declare RTU layer1 functions */
|
|
69 |
#define modbus_write modbus_rtu_write
|
|
70 |
#define modbus_read modbus_rtu_read
|
|
71 |
#define modbus_init modbus_rtu_init
|
|
72 |
#define modbus_done modbus_rtu_done
|
|
73 |
#define modbus_connect modbus_rtu_connect
|
|
74 |
#define modbus_listen modbus_rtu_listen
|
|
75 |
#define modbus_close modbus_rtu_close
|
|
76 |
#define modbus_silence_init modbus_rtu_silence_init
|
|
77 |
#define modbus_get_min_timeout modbus_rtu_get_min_timeout
|
|
78 |
|
|
79 |
#include "mb_layer1_prototypes.h"
|
|
80 |
|
|
81 |
#undef modbus_write
|
|
82 |
#undef modbus_read
|
|
83 |
#undef modbus_init
|
|
84 |
#undef modbus_done
|
|
85 |
#undef modbus_connect
|
|
86 |
#undef modbus_listen
|
|
87 |
#undef modbus_close
|
|
88 |
#undef modbus_silence_init
|
|
89 |
#undef modbus_get_min_timeout
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
/* Declare ASCII layer1 functions */
|
|
96 |
#define modbus_write modbus_ascii_write
|
|
97 |
#define modbus_read modbus_ascii_read
|
|
98 |
#define modbus_init modbus_ascii_init
|
|
99 |
#define modbus_done modbus_ascii_done
|
|
100 |
#define modbus_connect modbus_ascii_connect
|
|
101 |
#define modbus_listen modbus_ascii_listen
|
|
102 |
#define modbus_close modbus_ascii_close
|
|
103 |
#define modbus_silence_init modbus_ascii_silence_init
|
|
104 |
#define modbus_get_min_timeout modbus_ascii_get_min_timeout
|
|
105 |
|
|
106 |
#include "mb_layer1_prototypes.h"
|
|
107 |
|
|
108 |
#undef modbus_write
|
|
109 |
#undef modbus_read
|
|
110 |
#undef modbus_init
|
|
111 |
#undef modbus_done
|
|
112 |
#undef modbus_connect
|
|
113 |
#undef modbus_listen
|
|
114 |
#undef modbus_close
|
|
115 |
#undef modbus_silence_init
|
|
116 |
#undef modbus_get_min_timeout
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
#define modbus_write (*modbus_write )
|
|
122 |
#define modbus_read (*modbus_read )
|
|
123 |
#define modbus_init (*modbus_init )
|
|
124 |
#define modbus_done (*modbus_done )
|
|
125 |
#define modbus_connect (*modbus_connect )
|
|
126 |
#define modbus_listen (*modbus_listen )
|
|
127 |
#define modbus_close (*modbus_close )
|
|
128 |
#define modbus_silence_init (*modbus_silence_init )
|
|
129 |
#define modbus_get_min_timeout (*modbus_get_min_timeout)
|
|
130 |
|
|
131 |
typedef struct {
|
|
132 |
#include "mb_layer1_prototypes.h"
|
|
133 |
} layer1_funct_ptr_t;
|
|
134 |
|
|
135 |
#undef modbus_write
|
|
136 |
#undef modbus_read
|
|
137 |
#undef modbus_init
|
|
138 |
#undef modbus_done
|
|
139 |
#undef modbus_connect
|
|
140 |
#undef modbus_listen
|
|
141 |
#undef modbus_close
|
|
142 |
#undef modbus_silence_init
|
|
143 |
#undef modbus_get_min_timeout
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
extern layer1_funct_ptr_t fptr_[4];
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
#endif /* MODBUS_LAYER1_H */
|
|
154 |
|
|
155 |
|