-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmb_tcp_private.h
81 lines (61 loc) · 3.28 KB
/
mb_tcp_private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2002,2016 Mario de Sousa ([email protected])
*
* This file is part of the Modbus library for Beremiz and matiec.
*
* This Modbus library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this Modbus library. If not, see <http://www.gnu.org/licenses/>.
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
#ifndef MODBUS_TCP_PRIVATE_H
#define MODBUS_TCP_PRIVATE_H
#include "mb_util.h"
/* tcp port default configuration... */
#define DEF_SERVICE "502" /* port used by modbus */
#define DEF_PROTOCOL "tcp" /* protocol used by modbus tcp */
#define DEF_TYPE SOCK_STREAM /* Quality of service required of the socket... */
#define DEF_MAX_PENDING_CONNECTION_REQUESTS 5
/* maximum number of pending connection requests
* that have not yet been accept()'ed
*/
#define DEF_CLOSE_ON_SILENCE 1 /* Used only by master nodes.
* Flag indicating whether, by default, the connection
* to the slave device should be closed whenever the
* modbus_tcp_silence_init() function is called.
*
* 0 -> do not close connection
* >0 -> close connection
*
* The spec sugests that connections that will not
* be used for longer than 1 second should be closed.
* Even though we expect most connections to have
* silence intervals much shorted than 1 second, we
* decide to use the default of shuting down the
* connections because it is safer, and most other
* implementations seem to do the same.
* If we do not close we risk using up all the possible
* connections that the slave can simultaneouly handle,
* effectively locking out every other master that
* wishes to communicate with that same slave.
*/
/* Since the receive buffer is also re-used to store the frame header,
* we set it to the larger of the two.
*/
#if TCP_HEADER_LENGTH > MAX_L2_FRAME_LENGTH
#define RECV_BUFFER_SIZE TCP_HEADER_LENGTH
#else
#define RECV_BUFFER_SIZE MAX_L2_FRAME_LENGTH
#endif
#endif /* MODBUS_TCP_PRIVATE_H */