modbus-tcp-private.h 1.2 KB

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