@@ -331,10 +331,11 @@ export class Board {
331331 module . forceStop ( ) ;
332332 } catch ( e : any ) {
333333 if ( e . name !== "ExitStatus" ) {
334- console . error ( e ) ;
335- throw new Error ( "Expected status message" ) ;
334+ this . notifications . onInternalError ( e ) ;
336335 }
337336 }
337+ // Called by the HAL for normal shutdown but not in error scenarios.
338+ this . stopComponents ( ) ;
338339 this . modulePromise = undefined ;
339340
340341 if ( panicCode !== undefined ) {
@@ -530,15 +531,16 @@ export class Board {
530531 this . serialInputBuffer . length = 0 ;
531532 }
532533
533- dispose ( ) {
534- this . audio . dispose ( ) ;
535- this . buttons . forEach ( ( b ) => b . dispose ( ) ) ;
536- this . pins . forEach ( ( p ) => p . dispose ( ) ) ;
537- this . display . dispose ( ) ;
538- this . accelerometer . dispose ( ) ;
539- this . compass . dispose ( ) ;
540- this . microphone . dispose ( ) ;
541- this . radio . dispose ( ) ;
534+ stopComponents ( ) {
535+ this . audio . boardStopped ( ) ;
536+ this . buttons . forEach ( ( b ) => b . boardStopped ( ) ) ;
537+ this . pins . forEach ( ( p ) => p . boardStopped ( ) ) ;
538+ this . display . boardStopped ( ) ;
539+ this . accelerometer . boardStopped ( ) ;
540+ this . compass . boardStopped ( ) ;
541+ this . microphone . boardStopped ( ) ;
542+ this . radio . boardStopped ( ) ;
543+ this . dataLogging . boardStopped ( ) ;
542544 this . serialInputBuffer . length = 0 ;
543545
544546 // Nofify of the state resets.
0 commit comments