| 1 | /* |
| 2 | * Copyright © Stéphane Raimbault <[email protected]> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef MODBUS_TCP_PRIVATE_H |
| 8 | #define MODBUS_TCP_PRIVATE_H |
| 9 | |
| 10 | #define _MODBUS_TCP_HEADER_LENGTH 7 |
| 11 | #define _MODBUS_TCP_PRESET_REQ_LENGTH 12 |
| 12 | #define _MODBUS_TCP_PRESET_RSP_LENGTH 8 |
| 13 | |
| 14 | #define _MODBUS_TCP_CHECKSUM_LENGTH 0 |
| 15 | |
| 16 | /* In both structures, the transaction ID must be placed on first position |
| 17 | to have a quick access not dependent of the TCP backend */ |
| 18 | typedef struct _modbus_tcp { |
| 19 | /* Extract from MODBUS Messaging on TCP/IP Implementation Guide V1.0b |
| 20 | (page 23/46): |
| 21 | The transaction identifier is used to associate the future response |
| 22 | with the request. This identifier is unique on each TCP connection. */ |
| 23 | uint16_t t_id; |
| 24 | /* TCP port */ |
| 25 | int port; |
| 26 | /* IP address */ |
| 27 | char ip[16]; |
| 28 | } modbus_tcp_t; |
| 29 | |
| 30 | typedef struct _modbus_tcp_pi { |
| 31 | /* Transaction ID */ |
| 32 | uint16_t t_id; |
| 33 | /* TCP port */ |
| 34 | int port; |
| 35 | /* Node */ |
| 36 | char *node; |
| 37 | /* Service */ |
| 38 | char *service; |
| 39 | } modbus_tcp_pi_t; |
| 40 | |
| 41 | #endif /* MODBUS_TCP_PRIVATE_H */ |