modbus_report_slave_id.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 writes at most _max_dest_ bytes from the response to _dest_ so
  21. you must ensure that _dest_ is large enough.
  22. RETURN VALUE
  23. ------------
  24. The function shall return the number of read data if successful.
  25. If the output was truncated due to the _max_dest_ limit then the return value is
  26. the number of bytes which would have been written to _dest_ if enough space had
  27. been available. Thus, a return value greater than _max_dest_ means that the
  28. response data was truncated.
  29. Otherwise it shall return -1 and set errno.
  30. EXAMPLE
  31. -------
  32. [source,c]
  33. -------------------
  34. uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
  35. ...
  36. rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
  37. if (rc > 1) {
  38. printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
  39. }
  40. -------------------
  41. AUTHORS
  42. -------
  43. The libmodbus documentation was written by Stéphane Raimbault
  44. <stephane.raimbault@gmail.com>