1MODBUS_SET_SLAVE(3) Libmodbus Manual MODBUS_SET_SLAVE(3)
2
3
4
6 modbus_set_slave - set slave number in the context
7
9 int modbus_set_slave(modbus_t *ctx, int slave);
10
12 The modbus_set_slave() function shall set the slave number in the
13 libmodbus context.
14
15 The behavior depends of network and the role of the device:
16
17 RTU
18 Define the slave ID of the remote device to talk in master mode or
19 set the internal slave ID in slave mode. According to the protocol,
20 a Modbus device must only accept message holing its slave number or
21 the special broadcast number.
22
23 TCP
24 The slave number is only required in TCP if the message must reach
25 a device on a serial network. The special value MODBUS_TCP_SLAVE
26 (0xFF) can be used in TCP mode to restore the default value.
27
28 The broadcast address is MODBUS_BROADCAST_ADDRESS. This special value
29 must be use when you want all Modbus devices of the network receive the
30 request.
31
33 The modbus_set_slave() function shall return 0 if successful. Otherwise
34 it shall return -1 and set errno to one of the values defined below.
35
37 EINVAL
38 The slave number is invalid.
39
41 The libmodbus documentation was written by Stéphane Raimbault
42 <stephane.raimbault@gmail.com[1]>
43
45 1. stephane.raimbault@gmail.com
46 mailto:stephane.raimbault@gmail.com
47
48
49
50libmodbus 3.0.8 07/31/2019 MODBUS_SET_SLAVE(3)