MIGRATION 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 and it is only required
  5. in that function (eg. read_coil_status doesn't receive the slave ID in
  6. argument anymore). If you need to use different slaves with the same
  7. connection (eg. RS485), you can copy modbus_param_t, use modbus_set_slave()
  8. function or directly set modbus_param_t.slave to a different value when
  9. required.
  10. 2 - modbus_init_listen_tcp() has been renamed to modbus_slave_listen_tcp() and
  11. requires a new argument, the maximal number of connections:
  12. int modbus_slave_init_tcp(modbus_param_t *mb_param, int nb_connection);
  13. 3 - New function modbus_slave_accept_tcp() to etablish a new connection
  14. (previously in modbus_init_listen_tcp()):
  15. int modbus_slave_accept_tcp(modbus_param_t *mb_param, int *socket);
  16. 4 - modbus_listen() has been renamed to modbus_slave_receive() and requires a
  17. new argument, the socket file descriptor to listen on. If the sockfd is -1,
  18. the internal fd of modbus_param_t is used:
  19. int modbus_slave_receive(modbus_param_t *mb_param, int sockfd,
  20. uint8_t *query, int *query_length);
  21. 5 - If you use the HEADER_LENGTH_ defines, their values have been incremented by
  22. 1 to reflect the PDU and ADU of the Modbus protocol and to reduce the CPU
  23. consumption:
  24. - HEADER_LENGTH_RTU 0 -> 1
  25. - HEADER_LENGTH_TCP 6 -> 7
  26. 6 - modbus_mapping_new returns 0 on success and -1 on failure.
  27. =============================================
  28. Migration notes from the 1.2 series (for 2.0)
  29. =============================================
  30. Init
  31. ====
  32. modbus_init_tcp requires a third new argument, the port number.
  33. modbus_init_tcp(modbus_param_t *mb_param, char *ip_address, int port)
  34. Set the port to MODBUS_TCP_DEFAULT_PORT to use the default one
  35. (502). It's convenient to use a port number greater than or equal to
  36. 1024 because it's not necessary to be root to use this port number.
  37. Pointers of data
  38. ================
  39. The coil and input status are now stored in an array of type uint8_t
  40. (in 1.2.X series, array of type int was used). So now, you need to
  41. pass a pointer of type uint8_t to use read_coil_status(), for example.
  42. The holding and input registers are now stored in an array of type
  43. uint16_t.
  44. These changes reduce the memory consumption.
  45. New functions
  46. =============
  47. report_slave_id
  48. modbus_set_error_handling
  49. modbus_mapping_new
  50. modbus_mapping_free
  51. modbus_init_listen_tcp
  52. modbus_listen
  53. modbus_manage_query
  54. get_slave_query_tcp
  55. set_bits_from_byte
  56. set_bits_from_bytes
  57. get_byte_from_bits
  58. Read modbus.h for more informations.