modbus_report_slave_id.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. modbus_report_slave_id(3)
  2. =========================
  3. NAME
  4. ----
  5. modbus_report_slave_id - returns a description of the controller
  6. SYNOPSIS
  7. --------
  8. *int modbus_report_slave_id(modbus_t *'ctx', int 'max_dest', uint8_t *'dest');*
  9. DESCRIPTION
  10. -----------
  11. The *modbus_report_slave_id()* function shall send a request to the controller
  12. to obtain a description of the controller.
  13. The response stored in _dest_ contains:
  14. * the slave ID, this unique ID is in reality not unique at all so it's not
  15. possible to depend on it to know how the information are packed in the
  16. response.
  17. * the run indicator status (0x00 = OFF, 0xFF = ON)
  18. * additional data specific to each controller. For example, libmodbus returns
  19. the version of the library as a string.
  20. The function write at most _max_dest_ bytes from the response to _dest_.
  21. RETURN VALUE
  22. ------------
  23. The function shall return the number of read data if successful.
  24. If the output was truncated due to the _max_dest_ limit then the return value is
  25. the number of bytes which would have been written to _dest_ if enough space had
  26. been available. Thus, a return value greater than _max_dest_ means that the
  27. response data was truncated.
  28. Otherwise it shall return -1 and set errno.
  29. EXAMPLE
  30. -------
  31. [source,c]
  32. -------------------
  33. uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
  34. ...
  35. rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
  36. if (rc > 1) {
  37. printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
  38. }
  39. -------------------
  40. AUTHORS
  41. -------
  42. The libmodbus documentation was written by Stéphane Raimbault
  43. <stephane.raimbault@gmail.com>