Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement mask_write_register method in client mixin #100

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))