From b76e7f99f0d7c33f48097b27e3fb487cb9cc582e Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 17 Oct 2022 17:56:50 -0700 Subject: [PATCH] Allow uploads without port selection It is common for a "port" to be used in some way during the process of uploading to a board. However, the array of Arduino boards is very diverse. Some of these do not produce a port and their upload method has no need for one. For this reason, the IDE must allow the upload process to be initiated regardless of whether a port happens to be selected. During the addition of support for user provided fields, an unwarranted assumption was made that all boards require a port selection for upload and this resulted in a regression that broke uploading for these boards. This regression was especially user unfriendly in that there was no response whatsoever from the IDE when the user attempted to initiate an upload under these conditions. The bug is hereby fixed. The upload process will always be initiated by the IDE regardless of whether a port is selected. In cases where a port is required, the resulting error message returned by Arduino CLI or the upload tool will communicate the problem to the user. --- .../src/browser/boards/boards-service-provider.ts | 6 ++++-- .../src/browser/contributions/user-fields.ts | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts index e1951962e..65842eca3 100644 --- a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts +++ b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts @@ -409,14 +409,16 @@ export class BoardsServiceProvider } async selectedBoardUserFields(): Promise { - if (!this._boardsConfig.selectedBoard || !this._boardsConfig.selectedPort) { + if (!this._boardsConfig.selectedBoard) { return []; } const fqbn = this._boardsConfig.selectedBoard.fqbn; if (!fqbn) { return []; } - const protocol = this._boardsConfig.selectedPort.protocol; + // Protocol must be set to `default` when uploading without a port selected: + // https://arduino.github.io/arduino-cli/dev/platform-specification/#sketch-upload-configuration + const protocol = this._boardsConfig.selectedPort?.protocol || 'default'; return await this.boardsService.getBoardUserFields({ fqbn, protocol }); } diff --git a/arduino-ide-extension/src/browser/contributions/user-fields.ts b/arduino-ide-extension/src/browser/contributions/user-fields.ts index 445fdc480..195ab07da 100644 --- a/arduino-ide-extension/src/browser/contributions/user-fields.ts +++ b/arduino-ide-extension/src/browser/contributions/user-fields.ts @@ -66,10 +66,8 @@ export class UserFields extends Contribution { } const address = boardsConfig.selectedBoard?.port?.address || - boardsConfig.selectedPort?.address; - if (!address) { - return undefined; - } + boardsConfig.selectedPort?.address || + ''; return fqbn + '|' + address; }