mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-27 05:06:42 +00:00
fix upload when monitor is open
This commit is contained in:
parent
62eaeb1c74
commit
1982609c87
@ -84,4 +84,7 @@ export namespace Status {
|
|||||||
export const CONFIG_MISSING: ErrorStatus = {
|
export const CONFIG_MISSING: ErrorStatus = {
|
||||||
message: 'Serial Config missing.',
|
message: 'Serial Config missing.',
|
||||||
};
|
};
|
||||||
|
export const UPLOAD_IN_PROGRESS: ErrorStatus = {
|
||||||
|
message: 'Upload in progress.',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ export const MonitorManagerName = 'monitor-manager';
|
|||||||
export class MonitorManager extends CoreClientAware {
|
export class MonitorManager extends CoreClientAware {
|
||||||
// Map of monitor services that manage the running pluggable monitors.
|
// Map of monitor services that manage the running pluggable monitors.
|
||||||
// Each service handles the lifetime of one, and only one, monitor.
|
// Each service handles the lifetime of one, and only one, monitor.
|
||||||
// If either the board or port managed changes a new service must
|
// If either the board or port managed changes, a new service must
|
||||||
// be started.
|
// be started.
|
||||||
private monitorServices = new Map<MonitorID, MonitorService>();
|
private monitorServices = new Map<MonitorID, MonitorService>();
|
||||||
|
|
||||||
@ -109,6 +109,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
// There's no monitor running there, bail
|
// There's no monitor running there, bail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
monitor.setUploadInProgress(true);
|
||||||
return await monitor.pause();
|
return await monitor.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +133,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
// There's no monitor running there, bail
|
// There's no monitor running there, bail
|
||||||
return Status.NOT_CONNECTED;
|
return Status.NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
monitor.setUploadInProgress(false);
|
||||||
return await monitor.start();
|
return await monitor.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ export class MonitorService extends CoreClientAware implements Disposable {
|
|||||||
protected readonly webSocketProvider: WebSocketProvider =
|
protected readonly webSocketProvider: WebSocketProvider =
|
||||||
new WebSocketProviderImpl();
|
new WebSocketProviderImpl();
|
||||||
|
|
||||||
|
protected uploadInProgress = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject(ILogger)
|
@inject(ILogger)
|
||||||
@named(MonitorServiceName)
|
@named(MonitorServiceName)
|
||||||
@ -80,6 +82,10 @@ export class MonitorService extends CoreClientAware implements Disposable {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUploadInProgress(status: boolean): void {
|
||||||
|
this.uploadInProgress = status;
|
||||||
|
}
|
||||||
|
|
||||||
getWebsocketAddressPort(): number {
|
getWebsocketAddressPort(): number {
|
||||||
return this.webSocketProvider.getAddress().port;
|
return this.webSocketProvider.getAddress().port;
|
||||||
}
|
}
|
||||||
@ -113,11 +119,14 @@ export class MonitorService extends CoreClientAware implements Disposable {
|
|||||||
return Status.CONFIG_MISSING;
|
return Status.CONFIG_MISSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.uploadInProgress) {
|
||||||
|
return Status.UPLOAD_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.info('starting monitor');
|
this.logger.info('starting monitor');
|
||||||
await this.coreClientProvider.initialized;
|
await this.coreClientProvider.initialized;
|
||||||
const coreClient = await this.coreClient();
|
const coreClient = await this.coreClient();
|
||||||
const { client, instance } = coreClient;
|
const { client, instance } = coreClient;
|
||||||
|
|
||||||
this.duplex = client.monitor();
|
this.duplex = client.monitor();
|
||||||
this.duplex
|
this.duplex
|
||||||
.on('close', () => {
|
.on('close', () => {
|
||||||
@ -205,7 +214,7 @@ export class MonitorService extends CoreClientAware implements Disposable {
|
|||||||
* Pauses the currently running monitor, it still closes the gRPC connection
|
* Pauses the currently running monitor, it still closes the gRPC connection
|
||||||
* with the underlying monitor process but it doesn't stop the message handlers
|
* with the underlying monitor process but it doesn't stop the message handlers
|
||||||
* currently running.
|
* currently running.
|
||||||
* This is mainly used to handle upload when to the board/port combination
|
* This is mainly used to handle upload with the board/port combination
|
||||||
* the monitor is listening to.
|
* the monitor is listening to.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
@ -223,7 +232,8 @@ export class MonitorService extends CoreClientAware implements Disposable {
|
|||||||
this.logger.info(
|
this.logger.info(
|
||||||
`stopped monitor to ${this.port?.address} using ${this.port?.protocol}`
|
`stopped monitor to ${this.port?.address} using ${this.port?.protocol}`
|
||||||
);
|
);
|
||||||
resolve();
|
|
||||||
|
this.duplex.on('end', resolve);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user