File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { BaseKernel } from '@jupyterlite/kernel';
2
2
import { KernelMessage } from '@jupyterlab/services' ;
3
3
import { ServiceContainer } from './services/ServiceContainer' ;
4
4
5
+ const reconnectString : string = "%connect%"
6
+
5
7
export class EmbeddedKernel extends BaseKernel {
6
8
7
9
constructor ( options : any , private serviceContainer : ServiceContainer ) {
@@ -58,6 +60,17 @@ export class EmbeddedKernel extends BaseKernel {
58
60
console . log ( "GOT CODE AT KERNEL LEVEL: " , code ) ;
59
61
console . log ( "Type of CODE AT KERNEL LEVEL: " , typeof code ) ;
60
62
63
+ console . log ( 'Before reconnect check' ) ;
64
+ if ( code . includes ( reconnectString ) ) {
65
+ // Reconnect the device or connect for the first time
66
+ console . log ( 'Reconnect command detected, reconnecting device...' ) ;
67
+ await this . serviceContainer . deviceService . disconnect ( ) ;
68
+ console . log ( 'Device disconnected' ) ;
69
+ await this . serviceContainer . deviceService . connect ( ) ;
70
+ console . log ( 'Device connected' ) ;
71
+ }
72
+ console . log ( 'After reconnect check' ) ;
73
+
61
74
try {
62
75
console . log ( "[Kernel] executeRequest - Checking transport" ) ;
63
76
const transport = this . serviceContainer . deviceService . getTransport ( ) ;
Original file line number Diff line number Diff line change 1
1
import { Transport } from 'esptool-js' ;
2
2
3
- const reconnectString : string = "%connect%"
4
-
5
3
export class DeviceService {
6
4
private port : SerialPort | null = null ;
7
5
private transport : Transport | null = null ;
@@ -124,17 +122,6 @@ export class DeviceService {
124
122
}
125
123
126
124
async sendCommand ( code : string ) : Promise < boolean > {
127
- console . log ( 'Before reconnect check' ) ;
128
- if ( code . includes ( reconnectString ) ) {
129
- // Reconnect the device or connect for the first time
130
- console . log ( 'Reconnect command detected, reconnecting device...' ) ;
131
- await this . disconnect ( ) ;
132
- console . log ( 'Device disconnected' ) ;
133
- await this . connect ( ) ;
134
- console . log ( 'Device connected' ) ;
135
- }
136
- console . log ( 'After reconnect check' ) ;
137
-
138
125
if ( ! this . transport || ! this . transport . device . writable ) {
139
126
return false ;
140
127
}
You can’t perform that action at this time.
0 commit comments