mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-15 15:26:32 +00:00
ATL-530: No checks before upload/verify/burn
Made the port/fqbn/programmer optional for upload, verify, and burn bootloader. From now on, the IDE does not warn the user before performing the desired CLI command. Closes arduino/arduino-pro-ide#364 Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
acbb7d32b2
commit
2831acc5b5
@ -58,17 +58,25 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async appendConfigToFqbn(
|
async appendConfigToFqbn(
|
||||||
fqbn: string,
|
fqbn: string | undefined,
|
||||||
boardsPackageVersion: MaybePromise<Installable.Version | undefined> = this.getBoardsPackageVersion(fqbn)): Promise<string> {
|
boardsPackageVersion: MaybePromise<Installable.Version | undefined> = this.getBoardsPackageVersion(fqbn)): Promise<string | undefined> {
|
||||||
|
|
||||||
|
if (!fqbn) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const { configOptions } = await this.getData(fqbn, boardsPackageVersion);
|
const { configOptions } = await this.getData(fqbn, boardsPackageVersion);
|
||||||
return ConfigOption.decorate(fqbn, configOptions);
|
return ConfigOption.decorate(fqbn, configOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(
|
async getData(
|
||||||
fqbn: string,
|
fqbn: string | undefined,
|
||||||
boardsPackageVersion: MaybePromise<Installable.Version | undefined> = this.getBoardsPackageVersion(fqbn)): Promise<BoardsDataStore.Data> {
|
boardsPackageVersion: MaybePromise<Installable.Version | undefined> = this.getBoardsPackageVersion(fqbn)): Promise<BoardsDataStore.Data> {
|
||||||
|
|
||||||
|
if (!fqbn) {
|
||||||
|
return BoardsDataStore.Data.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
const version = await boardsPackageVersion;
|
const version = await boardsPackageVersion;
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return BoardsDataStore.Data.EMPTY;
|
return BoardsDataStore.Data.EMPTY;
|
||||||
@ -76,10 +84,7 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
const key = this.getStorageKey(fqbn, version);
|
const key = this.getStorageKey(fqbn, version);
|
||||||
let data = await this.storageService.getData<BoardsDataStore.Data | undefined>(key, undefined);
|
let data = await this.storageService.getData<BoardsDataStore.Data | undefined>(key, undefined);
|
||||||
if (data) {
|
if (data) {
|
||||||
// If `configOptions` is empty we rather reload the data. See arduino/arduino-cli#954 and arduino/arduino-cli#955.
|
return data;
|
||||||
if (data.configOptions.length && data.programmers !== undefined) { // to be backward compatible. We did not save the `programmers` into the `localStorage`.
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const boardDetails = await this.getBoardDetailsSafe(fqbn);
|
const boardDetails = await this.getBoardDetailsSafe(fqbn);
|
||||||
@ -173,7 +178,7 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
this.onChangedEmitter.fire();
|
this.onChangedEmitter.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getBoardsPackageVersion(fqbn: string): Promise<Installable.Version | undefined> {
|
protected async getBoardsPackageVersion(fqbn: string | undefined): Promise<Installable.Version | undefined> {
|
||||||
if (!fqbn) {
|
if (!fqbn) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -46,27 +46,11 @@ export class BurnBootloader extends SketchContribution {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { boardsConfig } = this.boardsServiceClientImpl;
|
const { boardsConfig } = this.boardsServiceClientImpl;
|
||||||
if (!boardsConfig || !boardsConfig.selectedBoard) {
|
const port = boardsConfig.selectedPort?.address;
|
||||||
throw new Error('No boards selected. Please select a board.');
|
|
||||||
}
|
|
||||||
if (!boardsConfig.selectedBoard.fqbn) {
|
|
||||||
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`);
|
|
||||||
}
|
|
||||||
const { selectedPort } = boardsConfig;
|
|
||||||
if (!selectedPort) {
|
|
||||||
throw new Error('No ports selected. Please select a port.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const port = selectedPort.address;
|
|
||||||
const [fqbn, { selectedProgrammer: programmer }] = await Promise.all([
|
const [fqbn, { selectedProgrammer: programmer }] = await Promise.all([
|
||||||
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn),
|
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn),
|
||||||
this.boardsDataStore.getData(boardsConfig.selectedBoard.fqbn)
|
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!programmer) {
|
|
||||||
throw new Error('Programmer is not selected. Please select a programmer from the `Tools` > `Programmer` menu.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.outputChannelManager.getChannel('Arduino: bootloader').clear();
|
this.outputChannelManager.getChannel('Arduino: bootloader').clear();
|
||||||
await this.coreService.burnBootloader({
|
await this.coreService.burnBootloader({
|
||||||
fqbn,
|
fqbn,
|
||||||
|
@ -83,34 +83,19 @@ export class UploadSketch extends SketchContribution {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { boardsConfig } = this.boardsServiceClientImpl;
|
const { boardsConfig } = this.boardsServiceClientImpl;
|
||||||
if (!boardsConfig || !boardsConfig.selectedBoard) {
|
|
||||||
throw new Error('No boards selected. Please select a board.');
|
|
||||||
}
|
|
||||||
if (!boardsConfig.selectedBoard.fqbn) {
|
|
||||||
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [fqbn, { selectedProgrammer }] = await Promise.all([
|
const [fqbn, { selectedProgrammer }] = await Promise.all([
|
||||||
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn),
|
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn),
|
||||||
this.boardsDataStore.getData(boardsConfig.selectedBoard.fqbn)
|
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let options: CoreService.Upload.Options | undefined = undefined;
|
let options: CoreService.Upload.Options | undefined = undefined;
|
||||||
const sketchUri = uri;
|
const sketchUri = uri;
|
||||||
const optimizeForDebug = this.editorMode.compileForDebug;
|
const optimizeForDebug = this.editorMode.compileForDebug;
|
||||||
const { selectedPort } = boardsConfig;
|
const { selectedPort } = boardsConfig;
|
||||||
|
const port = selectedPort?.address;
|
||||||
|
|
||||||
if (usingProgrammer) {
|
if (usingProgrammer) {
|
||||||
const programmer = selectedProgrammer;
|
const programmer = selectedProgrammer;
|
||||||
if (!programmer) {
|
|
||||||
throw new Error('Programmer is not selected. Please select a programmer from the `Tools` > `Programmer` menu.');
|
|
||||||
}
|
|
||||||
let port: undefined | string = undefined;
|
|
||||||
// If the port is set by the user, we pass it to the CLI as it might be required.
|
|
||||||
// If it is not set but the CLI requires it, we let the CLI to complain.
|
|
||||||
if (selectedPort) {
|
|
||||||
port = selectedPort.address;
|
|
||||||
}
|
|
||||||
options = {
|
options = {
|
||||||
sketchUri,
|
sketchUri,
|
||||||
fqbn,
|
fqbn,
|
||||||
@ -119,10 +104,6 @@ export class UploadSketch extends SketchContribution {
|
|||||||
port
|
port
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if (!selectedPort) {
|
|
||||||
throw new Error('No ports selected. Please select a port.');
|
|
||||||
}
|
|
||||||
const port = selectedPort.address;
|
|
||||||
options = {
|
options = {
|
||||||
sketchUri,
|
sketchUri,
|
||||||
fqbn,
|
fqbn,
|
||||||
@ -131,7 +112,11 @@ export class UploadSketch extends SketchContribution {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.outputChannelManager.getChannel('Arduino: upload').clear();
|
this.outputChannelManager.getChannel('Arduino: upload').clear();
|
||||||
await this.coreService.upload(options);
|
if (usingProgrammer) {
|
||||||
|
await this.coreService.uploadUsingProgrammer(options);
|
||||||
|
} else {
|
||||||
|
await this.coreService.upload(options);
|
||||||
|
}
|
||||||
this.messageService.info('Done uploading.', { timeout: 1000 });
|
this.messageService.info('Done uploading.', { timeout: 1000 });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.messageService.error(e.toString());
|
this.messageService.error(e.toString());
|
||||||
|
@ -63,13 +63,7 @@ export class VerifySketch extends SketchContribution {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { boardsConfig } = this.boardsServiceClientImpl;
|
const { boardsConfig } = this.boardsServiceClientImpl;
|
||||||
if (!boardsConfig || !boardsConfig.selectedBoard) {
|
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn);
|
||||||
throw new Error('No boards selected. Please select a board.');
|
|
||||||
}
|
|
||||||
if (!boardsConfig.selectedBoard.fqbn) {
|
|
||||||
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`);
|
|
||||||
}
|
|
||||||
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn);
|
|
||||||
this.outputChannelManager.getChannel('Arduino: compile').clear();
|
this.outputChannelManager.getChannel('Arduino: compile').clear();
|
||||||
await this.coreService.compile({
|
await this.coreService.compile({
|
||||||
sketchUri: uri,
|
sketchUri: uri,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from 'inversify';
|
||||||
import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
|
import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
|
||||||
import { OutputChannelManager, OutputChannelSeverity } from '@theia/output/lib/common/output-channel';
|
import { OutputChannelManager } from '@theia/output/lib/common/output-channel';
|
||||||
import { OutputService, OutputMessage } from '../common/protocol/output-service';
|
import { OutputService, OutputMessage } from '../common/protocol/output-service';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@ -22,19 +22,7 @@ export class OutputServiceImpl implements OutputService {
|
|||||||
// This will open, reveal but do not activate the Output view.
|
// This will open, reveal but do not activate the Output view.
|
||||||
: Promise.resolve(channel.show({ preserveFocus: true }));
|
: Promise.resolve(channel.show({ preserveFocus: true }));
|
||||||
|
|
||||||
show.then(() => channel.append(chunk, this.toOutputSeverity(message)));
|
show.then(() => channel.append(chunk));
|
||||||
}
|
|
||||||
|
|
||||||
protected toOutputSeverity(message: OutputMessage): OutputChannelSeverity {
|
|
||||||
if (message.severity) {
|
|
||||||
switch (message.severity) {
|
|
||||||
case 'error': return OutputChannelSeverity.Error
|
|
||||||
case 'warning': return OutputChannelSeverity.Warning
|
|
||||||
case 'info': return OutputChannelSeverity.Info
|
|
||||||
default: return OutputChannelSeverity.Info
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return OutputChannelSeverity.Info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ export const CoreService = Symbol('CoreService');
|
|||||||
export interface CoreService {
|
export interface CoreService {
|
||||||
compile(options: CoreService.Compile.Options): Promise<void>;
|
compile(options: CoreService.Compile.Options): Promise<void>;
|
||||||
upload(options: CoreService.Upload.Options): Promise<void>;
|
upload(options: CoreService.Upload.Options): Promise<void>;
|
||||||
|
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
|
||||||
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;
|
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,22 +14,23 @@ export namespace CoreService {
|
|||||||
export namespace Compile {
|
export namespace Compile {
|
||||||
export interface Options {
|
export interface Options {
|
||||||
readonly sketchUri: string;
|
readonly sketchUri: string;
|
||||||
readonly fqbn: string;
|
readonly fqbn?: string | undefined;
|
||||||
readonly optimizeForDebug: boolean;
|
readonly optimizeForDebug: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Upload {
|
export namespace Upload {
|
||||||
export type Options =
|
export interface Options extends Compile.Options {
|
||||||
Compile.Options & Readonly<{ port: string }> |
|
readonly port?: string | undefined;
|
||||||
Compile.Options & Readonly<{ programmer: Programmer, port?: string }>;
|
readonly programmer?: Programmer | undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Bootloader {
|
export namespace Bootloader {
|
||||||
export interface Options {
|
export interface Options {
|
||||||
readonly fqbn: string;
|
readonly fqbn?: string | undefined;
|
||||||
readonly programmer: Programmer;
|
readonly port?: string | undefined;
|
||||||
readonly port: string;
|
readonly programmer?: Programmer | undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export interface OutputMessage {
|
export interface OutputMessage {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly chunk: string;
|
readonly chunk: string;
|
||||||
readonly severity?: 'error' | 'warning' | 'info';
|
readonly severity?: 'error' | 'warning' | 'info'; // Currently not used!
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OutputServicePath = '/services/output-service';
|
export const OutputServicePath = '/services/output-service';
|
||||||
|
@ -4,9 +4,12 @@ import { dirname } from 'path';
|
|||||||
import { CoreService } from '../common/protocol/core-service';
|
import { CoreService } from '../common/protocol/core-service';
|
||||||
import { CompileReq, CompileResp } from './cli-protocol/commands/compile_pb';
|
import { CompileReq, CompileResp } from './cli-protocol/commands/compile_pb';
|
||||||
import { CoreClientProvider } from './core-client-provider';
|
import { CoreClientProvider } from './core-client-provider';
|
||||||
import { UploadReq, UploadResp, BurnBootloaderReq, BurnBootloaderResp } from './cli-protocol/commands/upload_pb';
|
import { UploadReq, UploadResp, BurnBootloaderReq, BurnBootloaderResp, UploadUsingProgrammerReq, UploadUsingProgrammerResp } from './cli-protocol/commands/upload_pb';
|
||||||
import { OutputService } from '../common/protocol/output-service';
|
import { OutputService } from '../common/protocol/output-service';
|
||||||
import { NotificationServiceServer } from '../common/protocol';
|
import { NotificationServiceServer } from '../common/protocol';
|
||||||
|
import { ClientReadableStream } from '@grpc/grpc-js';
|
||||||
|
import { ArduinoCoreClient } from './cli-protocol/commands/commands_grpc_pb';
|
||||||
|
import { firstToUpperCase, firstToLowerCase } from '../common/utils';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class CoreServiceImpl implements CoreService {
|
export class CoreServiceImpl implements CoreService {
|
||||||
@ -21,7 +24,7 @@ export class CoreServiceImpl implements CoreService {
|
|||||||
protected readonly notificationService: NotificationServiceServer;
|
protected readonly notificationService: NotificationServiceServer;
|
||||||
|
|
||||||
async compile(options: CoreService.Compile.Options): Promise<void> {
|
async compile(options: CoreService.Compile.Options): Promise<void> {
|
||||||
this.outputService.append({ name: 'compile', chunk: 'Compiling...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
|
this.outputService.append({ name: 'compile', chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
|
||||||
const { sketchUri, fqbn } = options;
|
const { sketchUri, fqbn } = options;
|
||||||
const sketchFilePath = FileUri.fsPath(sketchUri);
|
const sketchFilePath = FileUri.fsPath(sketchUri);
|
||||||
const sketchpath = dirname(sketchFilePath);
|
const sketchpath = dirname(sketchFilePath);
|
||||||
@ -32,14 +35,12 @@ export class CoreServiceImpl implements CoreService {
|
|||||||
}
|
}
|
||||||
const { client, instance } = coreClient;
|
const { client, instance } = coreClient;
|
||||||
|
|
||||||
if (!fqbn) {
|
|
||||||
throw new Error('The selected board has no FQBN.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const compilerReq = new CompileReq();
|
const compilerReq = new CompileReq();
|
||||||
compilerReq.setInstance(instance);
|
compilerReq.setInstance(instance);
|
||||||
compilerReq.setSketchpath(sketchpath);
|
compilerReq.setSketchpath(sketchpath);
|
||||||
compilerReq.setFqbn(fqbn);
|
if (fqbn) {
|
||||||
|
compilerReq.setFqbn(fqbn);
|
||||||
|
}
|
||||||
compilerReq.setOptimizefordebug(options.optimizeForDebug);
|
compilerReq.setOptimizefordebug(options.optimizeForDebug);
|
||||||
compilerReq.setPreprocess(false);
|
compilerReq.setPreprocess(false);
|
||||||
compilerReq.setVerbose(true);
|
compilerReq.setVerbose(true);
|
||||||
@ -63,9 +64,23 @@ export class CoreServiceImpl implements CoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async upload(options: CoreService.Upload.Options): Promise<void> {
|
async upload(options: CoreService.Upload.Options): Promise<void> {
|
||||||
|
await this.doUpload(options, () => new UploadReq(), (client, req) => client.upload(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
async uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void> {
|
||||||
|
await this.doUpload(options, () => new UploadUsingProgrammerReq(), (client, req) => client.uploadUsingProgrammer(req), 'upload using programmer');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async doUpload(
|
||||||
|
options: CoreService.Upload.Options,
|
||||||
|
requestProvider: () => UploadReq | UploadUsingProgrammerReq,
|
||||||
|
responseHandler: (client: ArduinoCoreClient, req: UploadReq | UploadUsingProgrammerReq) => ClientReadableStream<UploadResp | UploadUsingProgrammerResp>,
|
||||||
|
task: string = 'upload'): Promise<void> {
|
||||||
|
|
||||||
await this.compile(options);
|
await this.compile(options);
|
||||||
this.outputService.append({ name: 'upload', chunk: 'Uploading...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
|
const chunk = firstToUpperCase(task) + '...\n';
|
||||||
const { sketchUri, fqbn } = options;
|
this.outputService.append({ name: 'upload', chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
|
||||||
|
const { sketchUri, fqbn, port, programmer } = options;
|
||||||
const sketchFilePath = FileUri.fsPath(sketchUri);
|
const sketchFilePath = FileUri.fsPath(sketchUri);
|
||||||
const sketchpath = dirname(sketchFilePath);
|
const sketchpath = dirname(sketchFilePath);
|
||||||
|
|
||||||
@ -75,34 +90,32 @@ export class CoreServiceImpl implements CoreService {
|
|||||||
}
|
}
|
||||||
const { client, instance } = coreClient;
|
const { client, instance } = coreClient;
|
||||||
|
|
||||||
if (!fqbn) {
|
const req = requestProvider();
|
||||||
throw new Error('The selected board has no FQBN.');
|
req.setInstance(instance);
|
||||||
|
req.setSketchPath(sketchpath);
|
||||||
|
if (fqbn) {
|
||||||
|
req.setFqbn(fqbn);
|
||||||
}
|
}
|
||||||
|
if (port) {
|
||||||
const uploadReq = new UploadReq();
|
req.setPort(port);
|
||||||
uploadReq.setInstance(instance);
|
|
||||||
uploadReq.setSketchPath(sketchpath);
|
|
||||||
uploadReq.setFqbn(fqbn);
|
|
||||||
if ('programmer' in options) {
|
|
||||||
uploadReq.setProgrammer(options.programmer.id);
|
|
||||||
}
|
}
|
||||||
if (options.port) {
|
if (programmer) {
|
||||||
uploadReq.setPort(options.port);
|
req.setProgrammer(programmer.id);
|
||||||
}
|
}
|
||||||
const result = client.upload(uploadReq);
|
const result = responseHandler(client, req);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
result.on('data', (resp: UploadResp) => {
|
result.on('data', (resp: UploadResp) => {
|
||||||
this.outputService.append({ name: 'upload', chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
|
this.outputService.append({ name: task, chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
|
||||||
this.outputService.append({ name: 'upload', chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
|
this.outputService.append({ name: task, chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
|
||||||
});
|
});
|
||||||
result.on('error', error => reject(error));
|
result.on('error', error => reject(error));
|
||||||
result.on('end', () => resolve());
|
result.on('end', () => resolve());
|
||||||
});
|
});
|
||||||
this.outputService.append({ name: 'upload', chunk: '\n--------------------------\nUpload complete.\n' });
|
this.outputService.append({ name: 'upload', chunk: '\n--------------------------\n' + firstToLowerCase(task) + ' complete.\n' });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.outputService.append({ name: 'upload', chunk: `Upload error: ${e}\n`, severity: 'error' });
|
this.outputService.append({ name: 'upload', chunk: `${firstToUpperCase(task)} error: ${e}\n`, severity: 'error' });
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,19 +126,19 @@ export class CoreServiceImpl implements CoreService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { fqbn, port, programmer } = options;
|
const { fqbn, port, programmer } = options;
|
||||||
if (!fqbn) {
|
|
||||||
throw new Error('The selected board has no FQBN.');
|
|
||||||
}
|
|
||||||
if (!port) {
|
|
||||||
throw new Error('Port must be specified.');
|
|
||||||
}
|
|
||||||
const { client, instance } = coreClient;
|
const { client, instance } = coreClient;
|
||||||
const req = new BurnBootloaderReq();
|
const burnReq = new BurnBootloaderReq();
|
||||||
req.setFqbn(fqbn);
|
burnReq.setInstance(instance);
|
||||||
req.setPort(port);
|
if (fqbn) {
|
||||||
req.setProgrammer(programmer.id);
|
burnReq.setFqbn(fqbn);
|
||||||
req.setInstance(instance);
|
}
|
||||||
const result = client.burnBootloader(req);
|
if (port) {
|
||||||
|
burnReq.setPort(port);
|
||||||
|
}
|
||||||
|
if (programmer) {
|
||||||
|
burnReq.setProgrammer(programmer.id);
|
||||||
|
}
|
||||||
|
const result = client.burnBootloader(burnReq);
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
result.on('data', (resp: BurnBootloaderResp) => {
|
result.on('data', (resp: BurnBootloaderResp) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user