demntor / pymodbus

Modbus Python release (tools included)
0 stars 0 forks source link

Writing a single coil fails #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The execute() method of WriteSingleCoilRequest attempts to call the
setValues() method with a boolean as last argument instead of a list.
Since setValues() expects a list of booleans in this case, the call
fails.

Please have a look at the following patch, and fix this problem.

Thanks, 

Albert

Index: pymodbus/bit_write_message.py
===================================================================
--- pymodbus/bit_write_message.py   (Revision 137)
+++ pymodbus/bit_write_message.py   (Arbeitskopie)
@@ -78,7 +78,7 @@
         if not context.validate(self.function_code, self.address, 1):
             return self.doException(merror.IllegalAddress)

-        context.setValues(self.function_code, self.address, self.value)
+        context.setValues(self.function_code, self.address, [self.value])
         values = context.getValues(self.function_code, self.address, 1)
         return WriteSingleCoilResponse(self.address, values[0])

Original issue reported on code.google.com by albert.k...@gmail.com on 21 Mar 2011 at 3:31

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r138.

Original comment by Bashw...@gmail.com on 22 Mar 2011 at 1:35