File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,16 @@ def validate_resp_data(data: bytes,
248
248
if function_code in [Const .WRITE_SINGLE_COIL , Const .WRITE_SINGLE_REGISTER ]:
249
249
resp_addr , resp_value = struct .unpack (fmt , data )
250
250
251
+ # if bool(True) or int(1) is used as "output_value" of
252
+ # "write_single_coil" it will be internally converted to int(0xFF00),
253
+ # see Modbus specification, which is actually int(65280).
254
+ # Due to the non binary, but real value comparison of "value" and
255
+ # "resp_value", it would never match without the next two lines
256
+ # see #21
257
+ if function_code == Const .WRITE_SINGLE_COIL :
258
+ resp_value = bool (resp_value )
259
+ value = bool (value )
260
+
251
261
if (address == resp_addr ) and (value == resp_value ):
252
262
return True
253
263
elif function_code in [Const .WRITE_MULTIPLE_COILS ,
You can’t perform that action at this time.
0 commit comments