modbus_send_custom_command(IP, slave_number, function_code, data)
Sends a command specified by the user to the modbus unit located on the specified IP address. Cannot be used to request data, since the response will not be received. The user is responsible for supplying data which is meaningful to the supplied function code. The builtin function takes care of constructing the modbus frame, so the user should not be concerned with the length of the command.
>>> modbus_send_custom_command("172.140.17.11",103,6,
>>> [17,32,2,88])
The above example sets the watchdog timeout on a Beckhoff BK9050 to 600 ms. That is done using the modbus function code 6 (preset single register) and then supplying the register address in the first two bytes of the data array ([17,32] = [0x1120]) and the desired register content in the last two bytes ([2,88] = [0x0258] = dec 600).
Parameters
IP: A string specifying the IP address locating the modbus unit to which the custom command should be send. Can not be empty.
slave_number: An integer specifying the slave number to use for the custom command. Must be between [0-255].
function_code: An integer specifying the function code for the custom command.
data: An array of integers in which each entry must be a valid byte (0-255) value.
Example command: modbus_send_custom_command("172.140.17.11", 103, 6, [17,32,2,88])
- Example Parameters:
- IP address = 172.140.17.11
- Slave number = 103
- Function code = 6
- Data = [17,32,2,88]
- Function code and data are specified by the manufacturer of the slave Modbus device connected to the UR controller