Update references to README.md
[libmodbus.git] / src / modbus-tcp.h
blobd672b8bfa5bafdec6e8a5c2b46887d03cd6537d5
1 /*
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
19 #ifndef _MODBUS_TCP_H_
20 #define _MODBUS_TCP_H_
22 #include "modbus.h"
24 MODBUS_BEGIN_DECLS
26 #if defined(_WIN32) && !defined(__CYGWIN__)
27 /* Win32 with MinGW, supplement to <errno.h> */
28 #include <winsock2.h>
29 #if !defined(ECONNRESET)
30 #define ECONNRESET WSAECONNRESET
31 #endif
32 #if !defined(ECONNREFUSED)
33 #define ECONNREFUSED WSAECONNREFUSED
34 #endif
35 #if !defined(ETIMEDOUT)
36 #define ETIMEDOUT WSAETIMEDOUT
37 #endif
38 #if !defined(ENOPROTOOPT)
39 #define ENOPROTOOPT WSAENOPROTOOPT
40 #endif
41 #if !defined(EINPROGRESS)
42 #define EINPROGRESS WSAEINPROGRESS
43 #endif
44 #endif
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 EXPORT modbus_t* modbus_new_tcp(const char *ip_address, int port);
55 EXPORT int modbus_tcp_listen(modbus_t *ctx, int nb_connection);
56 EXPORT int modbus_tcp_accept(modbus_t *ctx, int *socket);
58 EXPORT modbus_t* modbus_new_tcp_pi(const char *node, const char *service);
59 EXPORT int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection);
60 EXPORT int modbus_tcp_pi_accept(modbus_t *ctx, int *socket);
62 MODBUS_END_DECLS
64 #endif /* _MODBUS_TCP_H_ */