Skip to content

Commit

Permalink
Merge pull request #100 from inguin/master
Browse files Browse the repository at this point in the history
Implement mask_write_register method in client mixin
  • Loading branch information
bashwork committed Oct 13, 2015
2 parents 5801fa0 + 6949fbf commit 6903ef9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pymodbus/client/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#---------------------------------------------------------------------------#
Expand Down
2 changes: 2 additions & 0 deletions test/test_client_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down Expand Up @@ -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))

0 comments on commit 6903ef9

Please sign in to comment.