@@ -138,32 +138,50 @@ def fake_execute(_self, _no_response_expected, request):
138
138
),
139
139
(
140
140
ModbusClientMixin .DATATYPE .BITS ,
141
- [True ],
142
- [256 ],
141
+ [True ] + [ False ] * 15 ,
142
+ [1 ], # 0x00 0x01
143
143
None ,
144
144
),
145
145
(
146
146
ModbusClientMixin .DATATYPE .BITS ,
147
- [True , False , True ],
148
- [1280 ],
147
+ [False ] * 8 + [ True ] + [ False ] * 7 ,
148
+ [256 ], # 0x01 0x00
149
149
None ,
150
150
),
151
151
(
152
152
ModbusClientMixin .DATATYPE .BITS ,
153
- [True , False , True ] + [ False ] * 5 + [True ],
154
- [1281 ],
153
+ [False ] * 15 + [True ],
154
+ [32768 ], # 0x80 0x00
155
155
None ,
156
156
),
157
157
(
158
158
ModbusClientMixin .DATATYPE .BITS ,
159
- [True , False , True ] + [False ] * 5 + [ True ] + [ False ] * 6 + [True ],
160
- [1409 ],
159
+ [True ] + [False ] * 14 + [True ],
160
+ [32769 ], # 0x80 0x01
161
161
None ,
162
162
),
163
163
(
164
164
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
167
185
None ,
168
186
),
169
187
],
@@ -181,9 +199,6 @@ def test_client_mixin_convert(self, datatype, word_order, registers, value, stri
181
199
result = ModbusClientMixin .convert_from_registers (registers , datatype , ** kwargs )
182
200
if datatype == ModbusClientMixin .DATATYPE .FLOAT32 :
183
201
result = round (result , 6 )
184
- if datatype == ModbusClientMixin .DATATYPE .BITS :
185
- if (missing := len (value ) % 16 ):
186
- value = value + [False ] * (16 - missing )
187
202
assert result == value
188
203
189
204
@pytest .mark .parametrize (
0 commit comments