MIGRATION 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. =============================================
  2. Migration notes from the 2.0 series (for 2.2)
  3. =============================================
  4. 1 - modbus_init_rtu/tcp takes a new argument, the slave number of the device
  5. which established the connection.
  6. 2 - modbus_init_listen_tcp() has been renamed to modbus_slave_listen_tcp() and
  7. requires a new argument, the maximal number of connections:
  8. int modbus_slave_init_tcp(modbus_param_t *mb_param, int nb_connection);
  9. 3 - New function modbus_slave_accept_tcp() to etablish a new connection
  10. (previously in modbus_init_listen_tcp()):
  11. int modbus_slave_accept_tcp(modbus_param_t *mb_param, int *socket);
  12. 4 - modbus_listen() has been renamed to modbus_slave_receive() and requires a
  13. new argument, the socket file descriptor to listen on. If the sockfd is -1,
  14. the internal fd of modbus_param_t is used:
  15. int modbus_slave_receive(modbus_param_t *mb_param, int sockfd,
  16. uint8_t *query, int *query_length);
  17. 5 - If you use the HEADER_LENGTH_ defines, their values have been incremented by
  18. 1 to reflect the PDU and ADU of the Modbus protocol and to reduce the CPU
  19. consumption:
  20. - HEADER_LENGTH_RTU 0 -> 1
  21. - HEADER_LENGTH_TCP 6 -> 7
  22. 6 - modbus_mapping_new returns 0 on success and -1 on failure.
  23. =============================================
  24. Migration notes from the 1.2 series (for 2.0)
  25. =============================================
  26. Init
  27. ====
  28. modbus_init_tcp requires a third new argument, the port number.
  29. modbus_init_tcp(modbus_param_t *mb_param, char *ip_address, int port)
  30. Set the port to MODBUS_TCP_DEFAULT_PORT to use the default one
  31. (502). It's convenient to use a port number greater than or equal to
  32. 1024 because it's not necessary to be root to use this port number.
  33. Pointers of data
  34. ================
  35. The coil and input status are now stored in an array of type uint8_t
  36. (in 1.2.X series, array of type int was used). So now, you need to
  37. pass a pointer of type uint8_t to use read_coil_status(), for example.
  38. The holding and input registers are now stored in an array of type
  39. uint16_t.
  40. These changes reduce the memory consumption.