天嵌二次封装库使用手册  V2.1.2
modbus-tcp.h
浏览该文件的文档.
1 /*
2  * Copyright © 2001-2010 Stéphane Raimbault <stephane.raimbault@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1+
5  */
6 
7 #ifndef MODBUS_TCP_H
8 #define MODBUS_TCP_H
9 
10 #include "modbus.h"
11 
13 
14 #if defined(_WIN32) && !defined(__CYGWIN__)
15 /* Win32 with MinGW, supplement to <errno.h> */
16 #include <winsock2.h>
17 #if !defined(ECONNRESET)
18 #define ECONNRESET WSAECONNRESET
19 #endif
20 #if !defined(ECONNREFUSED)
21 #define ECONNREFUSED WSAECONNREFUSED
22 #endif
23 #if !defined(ETIMEDOUT)
24 #define ETIMEDOUT WSAETIMEDOUT
25 #endif
26 #if !defined(ENOPROTOOPT)
27 #define ENOPROTOOPT WSAENOPROTOOPT
28 #endif
29 #if !defined(EINPROGRESS)
30 #define EINPROGRESS WSAEINPROGRESS
31 #endif
32 #endif
33 
34 #define MODBUS_TCP_DEFAULT_PORT 502
35 #define MODBUS_TCP_SLAVE 0xFF
36 
37 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
38  * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes
39  */
40 #define MODBUS_TCP_MAX_ADU_LENGTH 260
41 
42 MODBUS_API modbus_t* modbus_new_tcp(const char *ip_address, int port);
43 MODBUS_API int modbus_tcp_listen(modbus_t *ctx, int nb_connection);
44 MODBUS_API int modbus_tcp_accept(modbus_t *ctx, int *s);
45 
46 MODBUS_API modbus_t* modbus_new_tcp_pi(const char *node, const char *service);
47 MODBUS_API int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection);
48 MODBUS_API int modbus_tcp_pi_accept(modbus_t *ctx, int *s);
49 
51 
52 #endif /* MODBUS_TCP_H */
MODBUS_API int modbus_tcp_listen(modbus_t *ctx, int nb_connection)
#define MODBUS_BEGIN_DECLS
Definition: modbus.h:38
MODBUS_API int modbus_tcp_accept(modbus_t *ctx, int *s)
MODBUS_API modbus_t * modbus_new_tcp(const char *ip_address, int port)
struct _modbus modbus_t
Definition: modbus.h:155
MODBUS_API int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
MODBUS_API int modbus_tcp_pi_accept(modbus_t *ctx, int *s)
#define MODBUS_END_DECLS
Definition: modbus.h:39
MODBUS_API modbus_t * modbus_new_tcp_pi(const char *node, const char *service)
#define MODBUS_API
Definition: modbus.h:31