@@ -146,6 +146,9 @@ def _release(self):
146146 connector = self ._connector
147147 self ._connector = None
148148 if connector :
149+ # Lastly send init packet to stop all action in the controller
150+ self ._encode_init_packet ()
151+ self ._send (connector )
149152 connector .close ()
150153
151154 def _dispose (self ):
@@ -188,32 +191,32 @@ def _speed_to_gain(self, speed):
188191 elif speed < 1 : speed = 1
189192 return NeosocoNeobot ._SPEED_TO_GAIN [speed ]
190193 return 2
191-
192- def _encode_motoring_packet (self ):
194+
195+ def _encode_init_packet (self ):
193196 result = ""
194197 with self ._thread_lock :
195198 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
202205 result += self ._to_hex (0 ) # FND
203206 result += self ._to_hex (0 ) # Not Used
204207 result += self ._to_hex (self ._make_checksum (result )) # Checksum
205208 return result
206209
207- def _encode_init_packet (self ):
210+ def _encode_motoring_packet (self ):
208211 result = ""
209212 with self ._thread_lock :
210213 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
217220 result += self ._to_hex (0 ) # FND
218221 result += self ._to_hex (0 ) # Not Used
219222 result += self ._to_hex (self ._make_checksum (result )) # Checksum
0 commit comments