@@ -138,32 +138,50 @@ def fake_execute(_self, _no_response_expected, request):
138138 ),
139139 (
140140 ModbusClientMixin .DATATYPE .BITS ,
141- [True ],
142- [256 ],
141+ [True ] + [ False ] * 15 ,
142+ [1 ], # 0x00 0x01
143143 None ,
144144 ),
145145 (
146146 ModbusClientMixin .DATATYPE .BITS ,
147- [True , False , True ],
148- [1280 ],
147+ [False ] * 8 + [ True ] + [ False ] * 7 ,
148+ [256 ], # 0x01 0x00
149149 None ,
150150 ),
151151 (
152152 ModbusClientMixin .DATATYPE .BITS ,
153- [True , False , True ] + [ False ] * 5 + [True ],
154- [1281 ],
153+ [False ] * 15 + [True ],
154+ [32768 ], # 0x80 0x00
155155 None ,
156156 ),
157157 (
158158 ModbusClientMixin .DATATYPE .BITS ,
159- [True , False , True ] + [False ] * 5 + [ True ] + [ False ] * 6 + [True ],
160- [1409 ],
159+ [True ] + [False ] * 14 + [True ],
160+ [32769 ], # 0x80 0x01
161161 None ,
162162 ),
163163 (
164164 ModbusClientMixin .DATATYPE .BITS ,
165- [True , False , True ] + [False ] * 5 + [True ] + [False ] * 6 + [True ] * 2 ,
166- [1409 , 256 ],
165+ [False ] * 8 + [True , False , True ] + [False ] * 5 ,
166+ [1280 ], # 0x05 0x00
167+ None ,
168+ ),
169+ (
170+ ModbusClientMixin .DATATYPE .BITS ,
171+ [True ] + [False ] * 7 + [True , False , True ] + [False ] * 5 ,
172+ [1281 ], # 0x05 0x01
173+ None ,
174+ ),
175+ (
176+ ModbusClientMixin .DATATYPE .BITS ,
177+ [True ] + [False ] * 6 + [True , True , False , True ] + [False ] * 5 ,
178+ [1409 ], # 0x05 0x81
179+ None ,
180+ ),
181+ (
182+ ModbusClientMixin .DATATYPE .BITS ,
183+ [False ] * 8 + [True ] + [False ] * 7 + [True ] + [False ] * 6 + [True , True , False , True ] + [False ] * 5 ,
184+ [1409 , 256 ], # 92340480 = 0x05 0x81 0x01 0x00
167185 None ,
168186 ),
169187 ],
@@ -181,9 +199,6 @@ def test_client_mixin_convert(self, datatype, word_order, registers, value, stri
181199 result = ModbusClientMixin .convert_from_registers (registers , datatype , ** kwargs )
182200 if datatype == ModbusClientMixin .DATATYPE .FLOAT32 :
183201 result = round (result , 6 )
184- if datatype == ModbusClientMixin .DATATYPE .BITS :
185- if (missing := len (value ) % 16 ):
186- value = value + [False ] * (16 - missing )
187202 assert result == value
188203
189204 @pytest .mark .parametrize (
0 commit comments