@@ -146,6 +146,9 @@ def _release(self):
146
146
connector = self ._connector
147
147
self ._connector = None
148
148
if connector :
149
+ # Lastly send init packet to stop all action in the controller
150
+ self ._encode_init_packet ()
151
+ self ._send (connector )
149
152
connector .close ()
150
153
151
154
def _dispose (self ):
@@ -188,32 +191,32 @@ def _speed_to_gain(self, speed):
188
191
elif speed < 1 : speed = 1
189
192
return NeosocoNeobot ._SPEED_TO_GAIN [speed ]
190
193
return 2
191
-
192
- def _encode_motoring_packet (self ):
194
+
195
+ def _encode_init_packet (self ):
193
196
result = ""
194
197
with self ._thread_lock :
195
198
result += START_BYTES
196
- result += self ._to_hex (self . _output_1 ) # OUT1
197
- result += self ._to_hex (self . _output_2 ) # OUT2
198
- result += self ._to_hex (self . _output_3 ) # OUT3
199
- result += self ._to_hex (self . _left_motor ) # MLA
200
- result += self ._to_hex (self . _right_motor ) # MRA
201
- result += self ._to_hex (self . _note ) # BUZZER
199
+ result += self ._to_hex (0 ) # OUT1
200
+ result += self ._to_hex (0 ) # OUT2
201
+ result += self ._to_hex (0 ) # OUT3
202
+ result += self ._to_hex (0 ) # MLA
203
+ result += self ._to_hex (0 ) # MRA
204
+ result += self ._to_hex (0 ) # BUZZER
202
205
result += self ._to_hex (0 ) # FND
203
206
result += self ._to_hex (0 ) # Not Used
204
207
result += self ._to_hex (self ._make_checksum (result )) # Checksum
205
208
return result
206
209
207
- def _encode_init_packet (self ):
210
+ def _encode_motoring_packet (self ):
208
211
result = ""
209
212
with self ._thread_lock :
210
213
result += START_BYTES
211
- result += self ._to_hex (0 ) # OUT1
212
- result += self ._to_hex (0 ) # OUT2
213
- result += self ._to_hex (0 ) # OUT3
214
- result += self ._to_hex (0 ) # MLA
215
- result += self ._to_hex (0 ) # MRA
216
- result += self ._to_hex (0 ) # BUZZER
214
+ result += self ._to_hex (self . _output_1 ) # OUT1
215
+ result += self ._to_hex (self . _output_2 ) # OUT2
216
+ result += self ._to_hex (self . _output_3 ) # OUT3
217
+ result += self ._to_hex (self . _left_motor ) # MLA
218
+ result += self ._to_hex (self . _right_motor ) # MRA
219
+ result += self ._to_hex (self . _note ) # BUZZER
217
220
result += self ._to_hex (0 ) # FND
218
221
result += self ._to_hex (0 ) # Not Used
219
222
result += self ._to_hex (self ._make_checksum (result )) # Checksum
0 commit comments