Commit 876eee50 authored by Yves Watier's avatar Yves Watier Committed by Sebastien Petitdemange

The minimum to write float values to a eurotherm.

parent a708ede4
Pipeline #7166 passed with stages
in 20 minutes and 26 seconds
......@@ -385,6 +385,37 @@ class ModbusTcp:
self._write(0x06, address, struct_format, value, timeout_errmsg, timeout)
def write_float(self, address, value, timeout=None):
timeout_errmsg = "timeout on write_registers modbus tcp (%s, %d)" % (
func_code = 0x10
with self.Transaction(self) as trans:
with gevent.Timeout(
timeout or self._timeout, ModbusTimeout(timeout_errmsg)
quantityOfRegisters = 2
byteCount = 2 * quantityOfRegisters
msg = struct.pack(
">HHBf", address, quantityOfRegisters, byteCount, value
self._raw_write(trans.tid(), func_code, msg)
read_values = trans.get()
if isinstance(read_values, socket.error):
raise read_values
uid, func_code_answer, msg = read_values
if func_code != func_code_answer: # Error
raise ModbusError(
"Error expecting func code %s intead of %s"
% (func_code, _error_code(msg))
# in this case received msg should contain starting address and qty of registers
def read_input_registers(self, address, struct_format, timeout=None):
timeout_errmsg = "timeout on read_input_registers modbus tcp (%s, %d)" % (
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment