Skip to content

Commit

Permalink
Remove kwargs client.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Jul 19, 2024
1 parent 552c56e commit 481eca4
Showing 1 changed file with 13 additions and 37 deletions.
50 changes: 13 additions & 37 deletions pymodbus/client/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,91 +59,67 @@ def execute(self, _request: ModbusRequest) -> T:
.. tip::
Response is not interpreted.
"""
raise NotImplementedError(
"The execute method of ModbusClientMixin needs to be overridden and cannot be used directly"
)
raise NotImplementedError("execute of ModbusClientMixin needs to be overridden")

def read_coils(
self, address: int, count: int = 1, slave: int = 0) -> T:
def read_coils(self, address: int, count: int = 1, slave: int = 0) -> T:
"""Read coils (code 0x01).
:param address: Start address to read from
:param count: (optional) Number of coils to read
:param slave: (optional) Modbus slave ID
:raises ModbusException:
"""
return self.execute(
pdu_bit_read.ReadCoilsRequest(address, count, slave)
)
return self.execute(pdu_bit_read.ReadCoilsRequest(address, count, slave))

def read_discrete_inputs(
self, address: int, count: int = 1, slave: int = 0) -> T:
def read_discrete_inputs(self, address: int, count: int = 1, slave: int = 0) -> T:
"""Read discrete inputs (code 0x02).
:param address: Start address to read from
:param count: (optional) Number of coils to read
:param slave: (optional) Modbus slave ID
:raises ModbusException:
"""
return self.execute(
pdu_bit_read.ReadDiscreteInputsRequest(address, count, slave)
)
return self.execute(pdu_bit_read.ReadDiscreteInputsRequest(address, count, slave))

def read_holding_registers(
self, address: int, count: int = 1, slave: int = 0) -> T:
def read_holding_registers(self, address: int, count: int = 1, slave: int = 0) -> T:
"""Read holding registers (code 0x03).
:param address: Start address to read from
:param count: (optional) Number of coils to read
:param slave: (optional) Modbus slave ID
:raises ModbusException:
"""
return self.execute(
pdu_reg_read.ReadHoldingRegistersRequest(address, count, slave)
)
return self.execute(pdu_reg_read.ReadHoldingRegistersRequest(address, count, slave))

def read_input_registers(
self, address: int, count: int = 1, slave: int = 0, **kwargs: Any
) -> T:
def read_input_registers(self, address: int, count: int = 1, slave: int = 0) -> T:
"""Read input registers (code 0x04).
:param address: Start address to read from
:param count: (optional) Number of coils to read
:param slave: (optional) Modbus slave ID
:param kwargs: (optional) Experimental parameters.
:raises ModbusException:
"""
return self.execute(
pdu_reg_read.ReadInputRegistersRequest(address, count, slave, **kwargs)
)
return self.execute(pdu_reg_read.ReadInputRegistersRequest(address, count, slave))

def write_coil(self, address: int, value: bool, slave: int = 0, **kwargs: Any) -> T:
def write_coil(self, address: int, value: bool, slave: int = 0) -> T:
"""Write single coil (code 0x05).
:param address: Address to write to
:param value: Boolean to write
:param slave: (optional) Modbus slave ID
:param kwargs: (optional) Experimental parameters.
:raises ModbusException:
"""
return self.execute(
pdu_bit_write.WriteSingleCoilRequest(address, value, slave, **kwargs)
)
return self.execute(pdu_bit_write.WriteSingleCoilRequest(address, value, slave))

def write_register(
self, address: int, value: int, slave: int = 0, **kwargs: Any
) -> T:
def write_register(self, address: int, value: int, slave: int = 0) -> T:
"""Write register (code 0x06).
:param address: Address to write to
:param value: Value to write
:param slave: (optional) Modbus slave ID
:param kwargs: (optional) Experimental parameters.
:raises ModbusException:
"""
return self.execute(
pdu_req_write.WriteSingleRegisterRequest(address, value, slave, **kwargs)
)
return self.execute(pdu_req_write.WriteSingleRegisterRequest(address, value, slave))

def read_exception_status(self, slave: int = 0, **kwargs: Any) -> T:
"""Read Exception Status (code 0x07).
Expand Down

0 comments on commit 481eca4

Please sign in to comment.