From 6949fbf3f6e7236de7f8e154d2828603cb197f19 Mon Sep 17 00:00:00 2001 From: Ingo van Lil Date: Mon, 5 Oct 2015 12:00:29 +0200 Subject: [PATCH] Implement mask_write_register method in client mixin --- pymodbus/client/common.py | 12 ++++++++++++ test/test_client_common.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/pymodbus/client/common.py b/pymodbus/client/common.py index 4b0caa143..4e2f4bde3 100644 --- a/pymodbus/client/common.py +++ b/pymodbus/client/common.py @@ -132,6 +132,18 @@ def readwrite_registers(self, *args, **kwargs): request = ReadWriteMultipleRegistersRequest(*args, **kwargs) return self.execute(request) + def mask_write_register(self, *args, **kwargs): + ''' + + :param address: The address of the register to write + :param and_mask: The and bitmask to apply to the register address + :param or_mask: The or bitmask to apply to the register address + :param unit: The slave unit this request is targeting + :returns: A deferred response handle + ''' + request = MaskWriteRegisterRequest(*args, **kwargs) + return self.execute(request) + #---------------------------------------------------------------------------# # Exported symbols #---------------------------------------------------------------------------# diff --git a/test/test_client_common.py b/test/test_client_common.py index f8cf91b94..f182aafb1 100644 --- a/test/test_client_common.py +++ b/test/test_client_common.py @@ -3,6 +3,7 @@ from pymodbus.client.common import ModbusClientMixin from pymodbus.bit_read_message import * from pymodbus.bit_write_message import * +from pymodbus.file_message import * from pymodbus.register_read_message import * from pymodbus.register_write_message import * @@ -51,3 +52,4 @@ def testModbusClientMixinMethods(self): self.assertTrue(isinstance(self.client.read_holding_registers(1,1), ReadHoldingRegistersRequest)) self.assertTrue(isinstance(self.client.read_input_registers(1,1), ReadInputRegistersRequest)) self.assertTrue(isinstance(self.client.readwrite_registers(**arguments), ReadWriteMultipleRegistersRequest)) + self.assertTrue(isinstance(self.client.mask_write_register(1,0,0), MaskWriteRegisterRequest))