mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-09 12:26:34 +00:00
Use FQBN instead of Board
for the monitor ID.
Closes #1278 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
d93c9ba654
commit
d556ee95c0
@ -76,7 +76,7 @@ export class ArduinoFirmwareUploaderImpl implements ArduinoFirmwareUploader {
|
|||||||
fqbn: firmware.board_fqbn,
|
fqbn: firmware.board_fqbn,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await this.monitorManager.notifyUploadStarted(board, port);
|
await this.monitorManager.notifyUploadStarted(board.fqbn, port);
|
||||||
output = await this.runCommand([
|
output = await this.runCommand([
|
||||||
'firmware',
|
'firmware',
|
||||||
'flash',
|
'flash',
|
||||||
@ -90,7 +90,7 @@ export class ArduinoFirmwareUploaderImpl implements ArduinoFirmwareUploader {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
await this.monitorManager.notifyUploadFinished(board, port);
|
await this.monitorManager.notifyUploadFinished(board.fqbn, port);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
UploadUsingProgrammerResponse,
|
UploadUsingProgrammerResponse,
|
||||||
} from './cli-protocol/cc/arduino/cli/commands/v1/upload_pb';
|
} from './cli-protocol/cc/arduino/cli/commands/v1/upload_pb';
|
||||||
import { ResponseService } from '../common/protocol/response-service';
|
import { ResponseService } from '../common/protocol/response-service';
|
||||||
import { Board, OutputMessage, Port, Status } from '../common/protocol';
|
import { OutputMessage, Port, Status } from '../common/protocol';
|
||||||
import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb';
|
import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb';
|
||||||
import { Port as GrpcPort } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb';
|
import { Port as GrpcPort } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb';
|
||||||
import { ApplicationError, CommandService, Disposable, nls } from '@theia/core';
|
import { ApplicationError, CommandService, Disposable, nls } from '@theia/core';
|
||||||
@ -376,23 +376,23 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async notifyUploadWillStart({
|
private async notifyUploadWillStart({
|
||||||
board,
|
fqbn,
|
||||||
port,
|
port,
|
||||||
}: {
|
}: {
|
||||||
board?: Board | undefined;
|
fqbn?: string | undefined;
|
||||||
port?: Port | undefined;
|
port?: Port | undefined;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.monitorManager.notifyUploadStarted(board, port);
|
return this.monitorManager.notifyUploadStarted(fqbn, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async notifyUploadDidFinish({
|
private async notifyUploadDidFinish({
|
||||||
board,
|
fqbn,
|
||||||
port,
|
port,
|
||||||
}: {
|
}: {
|
||||||
board?: Board | undefined;
|
fqbn?: string | undefined;
|
||||||
port?: Port | undefined;
|
port?: Port | undefined;
|
||||||
}): Promise<Status> {
|
}): Promise<Status> {
|
||||||
return this.monitorManager.notifyUploadFinished(board, port);
|
return this.monitorManager.notifyUploadFinished(fqbn, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
private mergeSourceOverrides(
|
private mergeSourceOverrides(
|
||||||
|
@ -58,7 +58,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
* combination specified, false in all other cases.
|
* combination specified, false in all other cases.
|
||||||
*/
|
*/
|
||||||
isStarted(board: Board, port: Port): boolean {
|
isStarted(board: Board, port: Port): boolean {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
if (monitor) {
|
if (monitor) {
|
||||||
return monitor.isStarted();
|
return monitor.isStarted();
|
||||||
@ -106,7 +106,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
port: Port,
|
port: Port,
|
||||||
connectToClient: (status: Status) => void
|
connectToClient: (status: Status) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
|
|
||||||
let monitor = this.monitorServices.get(monitorID);
|
let monitor = this.monitorServices.get(monitorID);
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
@ -138,7 +138,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
* @param port port monitored
|
* @param port port monitored
|
||||||
*/
|
*/
|
||||||
async stopMonitor(board: Board, port: Port): Promise<void> {
|
async stopMonitor(board: Board, port: Port): Promise<void> {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
// There's no monitor to stop, bail
|
// There's no monitor to stop, bail
|
||||||
@ -155,7 +155,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
* @returns port of the MonitorService's WebSocket
|
* @returns port of the MonitorService's WebSocket
|
||||||
*/
|
*/
|
||||||
getWebsocketAddressPort(board: Board, port: Port): number {
|
getWebsocketAddressPort(board: Board, port: Port): number {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -168,17 +168,17 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
* that an upload process started on that exact board/port combination.
|
* that an upload process started on that exact board/port combination.
|
||||||
* This must be done so that we can stop the monitor for the time being
|
* This must be done so that we can stop the monitor for the time being
|
||||||
* until the upload process finished.
|
* until the upload process finished.
|
||||||
* @param board board connected to port
|
* @param fqbn the FQBN of the board connected to port
|
||||||
* @param port port to monitor
|
* @param port port to monitor
|
||||||
*/
|
*/
|
||||||
async notifyUploadStarted(board?: Board, port?: Port): Promise<void> {
|
async notifyUploadStarted(fqbn?: string, port?: Port): Promise<void> {
|
||||||
if (!board || !port) {
|
if (!fqbn || !port) {
|
||||||
// We have no way of knowing which monitor
|
// We have no way of knowing which monitor
|
||||||
// to retrieve if we don't have this information.
|
// to retrieve if we don't have this information.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(fqbn, port);
|
||||||
this.addToMonitorIDsByUploadState('uploadInProgress', monitorID);
|
this.addToMonitorIDsByUploadState('uploadInProgress', monitorID);
|
||||||
|
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
@ -194,19 +194,22 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
/**
|
/**
|
||||||
* Notifies the monitor service of that board/port combination
|
* Notifies the monitor service of that board/port combination
|
||||||
* that an upload process started on that exact board/port combination.
|
* that an upload process started on that exact board/port combination.
|
||||||
* @param board board connected to port
|
* @param fqbn the FQBN of the board connected to port
|
||||||
* @param port port to monitor
|
* @param port port to monitor
|
||||||
* @returns a Status object to know if the process has been
|
* @returns a Status object to know if the process has been
|
||||||
* started or if there have been errors.
|
* started or if there have been errors.
|
||||||
*/
|
*/
|
||||||
async notifyUploadFinished(board?: Board, port?: Port): Promise<Status> {
|
async notifyUploadFinished(
|
||||||
|
fqbn?: string | undefined,
|
||||||
|
port?: Port
|
||||||
|
): Promise<Status> {
|
||||||
let status: Status = Status.NOT_CONNECTED;
|
let status: Status = Status.NOT_CONNECTED;
|
||||||
let portDidChangeOnUpload = false;
|
let portDidChangeOnUpload = false;
|
||||||
|
|
||||||
// We have no way of knowing which monitor
|
// We have no way of knowing which monitor
|
||||||
// to retrieve if we don't have this information.
|
// to retrieve if we don't have this information.
|
||||||
if (board && port) {
|
if (fqbn && port) {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(fqbn, port);
|
||||||
this.removeFromMonitorIDsByUploadState('uploadInProgress', monitorID);
|
this.removeFromMonitorIDsByUploadState('uploadInProgress', monitorID);
|
||||||
|
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
@ -277,7 +280,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
port: Port,
|
port: Port,
|
||||||
settings: PluggableMonitorSettings
|
settings: PluggableMonitorSettings
|
||||||
) {
|
) {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
let monitor = this.monitorServices.get(monitorID);
|
let monitor = this.monitorServices.get(monitorID);
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
monitor = this.createMonitor(board, port);
|
monitor = this.createMonitor(board, port);
|
||||||
@ -296,7 +299,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
board: Board,
|
board: Board,
|
||||||
port: Port
|
port: Port
|
||||||
): Promise<MonitorSettings> {
|
): Promise<MonitorSettings> {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
const monitor = this.monitorServices.get(monitorID);
|
const monitor = this.monitorServices.get(monitorID);
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
return {};
|
return {};
|
||||||
@ -312,7 +315,7 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
* @returns a new instance of MonitorService ready to use.
|
* @returns a new instance of MonitorService ready to use.
|
||||||
*/
|
*/
|
||||||
private createMonitor(board: Board, port: Port): MonitorService {
|
private createMonitor(board: Board, port: Port): MonitorService {
|
||||||
const monitorID = this.monitorID(board, port);
|
const monitorID = this.monitorID(board.fqbn, port);
|
||||||
const monitor = this.monitorServiceFactory({
|
const monitor = this.monitorServiceFactory({
|
||||||
board,
|
board,
|
||||||
port,
|
port,
|
||||||
@ -341,12 +344,12 @@ export class MonitorManager extends CoreClientAware {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to create a unique ID for a monitor service.
|
* Utility function to create a unique ID for a monitor service.
|
||||||
* @param board
|
* @param fqbn
|
||||||
* @param port
|
* @param port
|
||||||
* @returns a unique monitor ID
|
* @returns a unique monitor ID
|
||||||
*/
|
*/
|
||||||
private monitorID(board: Board, port: Port): MonitorID {
|
private monitorID(fqbn: string | undefined, port: Port): MonitorID {
|
||||||
const splitFqbn = board?.fqbn?.split(':') || [];
|
const splitFqbn = fqbn?.split(':') || [];
|
||||||
const shortenedFqbn = splitFqbn.slice(0, 3).join(':') || '';
|
const shortenedFqbn = splitFqbn.slice(0, 3).join(':') || '';
|
||||||
return `${shortenedFqbn}-${port.address}-${port.protocol}`;
|
return `${shortenedFqbn}-${port.address}-${port.protocol}`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user