2 * Copyright © 2001-2010 Stéphane Raimbault <stephane.raimbault@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #if defined(_WIN32) && !defined(__CYGWIN__)
27 /* Win32 with MinGW, supplement to <errno.h> */
29 #if !defined(ECONNRESET)
30 #define ECONNRESET WSAECONNRESET
32 #if !defined(ECONNREFUSED)
33 #define ECONNREFUSED WSAECONNREFUSED
35 #if !defined(ETIMEDOUT)
36 #define ETIMEDOUT WSAETIMEDOUT
38 #if !defined(ENOPROTOOPT)
39 #define ENOPROTOOPT WSAENOPROTOOPT
41 #if !defined(EINPROGRESS)
42 #define EINPROGRESS WSAEINPROGRESS
46 #define MODBUS_TCP_DEFAULT_PORT 502
47 #define MODBUS_TCP_SLAVE 0xFF
49 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
50 * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes
52 #define MODBUS_TCP_MAX_ADU_LENGTH 260
54 MODBUS_API modbus_t
* modbus_new_tcp(const char *ip_address
, int port
);
55 MODBUS_API
int modbus_tcp_listen(modbus_t
*ctx
, int nb_connection
);
56 MODBUS_API
int modbus_tcp_accept(modbus_t
*ctx
, int *s
);
58 MODBUS_API modbus_t
* modbus_new_tcp_pi(const char *node
, const char *service
);
59 MODBUS_API
int modbus_tcp_pi_listen(modbus_t
*ctx
, int nb_connection
);
60 MODBUS_API
int modbus_tcp_pi_accept(modbus_t
*ctx
, int *s
);
64 #endif /* MODBUS_TCP_H */