MIGRATION 2.1 KB

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