modbus-tcp-private.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright © 2001-2011 Stéphane Raimbault <stephane.raimbault@gmail.com>
  3. *
  4. * SPDX-License-Identifier: LGPL-2.1+
  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. int domain;
  25. } modbus_tcp_t;
  26. #define _MODBUS_TCP_PI_NODE_LENGTH 1025
  27. #define _MODBUS_TCP_PI_SERVICE_LENGTH 32
  28. typedef struct _modbus_tcp_pi {
  29. /* Transaction ID */
  30. uint16_t t_id;
  31. /* TCP port */
  32. int port;
  33. /* Node */
  34. char node[_MODBUS_TCP_PI_NODE_LENGTH];
  35. /* Service */
  36. char service[_MODBUS_TCP_PI_SERVICE_LENGTH];
  37. } modbus_tcp_pi_t;
  38. #endif /* MODBUS_TCP_PRIVATE_H */