[Python-modules-commits] [pymodbus] 03/04: Implement mask_write_register method in client mixin

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Oct 13 21:35:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch upstream
in repository pymodbus.

commit e33d8d37bdcf22fabe9bc54518543dfacb9a217a
Author: Ingo van Lil <inguin at gmx.de>
Date:   Mon Oct 5 12:00:29 2015 +0200

    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 4b0caa1..4e2f4bd 100644
--- a/pymodbus/client/common.py
+++ b/pymodbus/client/common.py
@@ -132,6 +132,18 @@ class ModbusClientMixin(object):
         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 f8cf91b..f182aaf 100644
--- a/test/test_client_common.py
+++ b/test/test_client_common.py
@@ -3,6 +3,7 @@ import unittest
 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 @@ class ModbusCommonClientTests(unittest.TestCase):
         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))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pymodbus.git



More information about the Python-modules-commits mailing list