I'm new to pymodbus. I am trying to create a custom request to be sent to a TCP client, this specific request needs to have 3 exclamation marks at the beginning of the message. an example message request would be 21 21 21 01 7F 07 40 01 00 88 00 00 in hex, I've tried to follow the custom message example from the pymodbus documentation examples and change the encode function in the request class but I'm not getting any response back. is there any way I can send this specific message and then read the response from the modbus device? this specific function should return the date and time in the device. Thanks!
class CustomBSCRACRequest(ModbusRequest):
"""Custom modbus request."""
function_code = 127
_rtu_frame_size = 8
command = 136
flags = 64
dest_task = 0
def __init__(self, address=None, **kwargs):
"""Initialize."""
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.count = 7
def encode(self):
"""Encode."""
return struct.pack(">HHHHHHHHH", 33, 33, 33, self.address, self.count, self.flags, self.address, self.dest_task, self.command)