modbus_set_slave.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. modbus_set_slave(3)
  2. ===================
  3. NAME
  4. ----
  5. modbus_set_slave - set slave number in the context
  6. SYNOPSIS
  7. --------
  8. *int modbus_set_slave(modbus_t *'ctx', int 'slave');*
  9. DESCRIPTION
  10. -----------
  11. The _modbus_set_slave()_ function shall set the slave number in the libmodbus
  12. context.
  13. The behavior depends of network and the role of the device:
  14. *RTU*::
  15. Define the slave ID of the remote device to talk in master mode or set the
  16. internal slave ID in slave mode. According to the protocol, a Modbus device must
  17. only accept message holing its slave number or the special broadcast number.
  18. *TCP*::
  19. The slave number is only required in TCP if the message must reach a device
  20. on a serial network. The special value 'MODBUS_TCP_SLAVE' (0xFF) can be used in TCP mode to restore
  21. the default value.
  22. The broadcast address is 'MODBUS_BROADCAST_ADDRESS'. This special value must be
  23. use when you want all Modbus devices of the network receive the request.
  24. RETURN VALUE
  25. ------------
  26. The _modbus_set_slave()_ function shall return 0 if successful. Otherwise it
  27. shall return -1 and set errno to one of the values defined below.
  28. ERRORS
  29. ------
  30. *EINVAL*::
  31. The slave number is invalid.
  32. AUTHORS
  33. -------
  34. The libmodbus documentation was written by Stéphane Raimbault
  35. <stephane.raimbault@gmail.com>