0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002,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_TCP_PRIVATE_H
|
|
26 |
#define MODBUS_TCP_PRIVATE_H
|
|
27 |
|
|
28 |
|
|
29 |
#include "mb_util.h"
|
|
30 |
|
|
31 |
|
|
32 |
/* tcp port default configuration... */
|
|
33 |
#define DEF_SERVICE "502" /* port used by modbus */
|
|
34 |
#define DEF_PROTOCOL "tcp" /* protocol used by modbus tcp */
|
|
35 |
#define DEF_TYPE SOCK_STREAM /* Quality of service required of the socket... */
|
|
36 |
#define DEF_MAX_PENDING_CONNECTION_REQUESTS 5
|
|
37 |
/* maximum number of pending connection requests
|
|
38 |
* that have not yet been accept()'ed
|
|
39 |
*/
|
|
40 |
#define DEF_CLOSE_ON_SILENCE 1 /* Used only by master nodes.
|
|
41 |
* Flag indicating whether, by default, the connection
|
|
42 |
* to the slave device should be closed whenever the
|
|
43 |
* modbus_tcp_silence_init() function is called.
|
|
44 |
*
|
|
45 |
* 0 -> do not close connection
|
|
46 |
* >0 -> close connection
|
|
47 |
*
|
|
48 |
* The spec sugests that connections that will not
|
|
49 |
* be used for longer than 1 second should be closed.
|
|
50 |
* Even though we expect most connections to have
|
|
51 |
* silence intervals much shorted than 1 second, we
|
|
52 |
* decide to use the default of shuting down the
|
|
53 |
* connections because it is safer, and most other
|
|
54 |
* implementations seem to do the same.
|
|
55 |
* If we do not close we risk using up all the possible
|
|
56 |
* connections that the slave can simultaneouly handle,
|
|
57 |
* effectively locking out every other master that
|
|
58 |
* wishes to communicate with that same slave.
|
|
59 |
*/
|
|
60 |
|
|
61 |
/* Since the receive buffer is also re-used to store the frame header,
|
|
62 |
* we set it to the larger of the two.
|
|
63 |
*/
|
|
64 |
#if TCP_HEADER_LENGTH > MAX_L2_FRAME_LENGTH
|
|
65 |
#define RECV_BUFFER_SIZE TCP_HEADER_LENGTH
|
|
66 |
#else
|
|
67 |
#define RECV_BUFFER_SIZE MAX_L2_FRAME_LENGTH
|
|
68 |
#endif
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
#endif /* MODBUS_TCP_PRIVATE_H */
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|