use programmer id for upload/verify

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-07-21 20:12:51 +02:00
parent cc76f2bbc8
commit 87b383f57e
4 changed files with 26 additions and 11 deletions

View File

@ -81,13 +81,17 @@ export class UploadSketch extends SketchContribution {
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);
const [fqbn, data] = await Promise.all([
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn),
this.boardsDataStore.getData(boardsConfig.selectedBoard.fqbn)
]);
this.outputChannelManager.getChannel('Arduino: upload').clear();
await this.coreService.upload({
sketchUri: uri,
fqbn,
port: selectedPort.address,
optimizeForDebug: this.editorMode.compileForDebug
optimizeForDebug: this.editorMode.compileForDebug,
programmer: data.selectedProgrammer
});
this.messageService.info('Done uploading.', { timeout: 1000 });
} catch (e) {

View File

@ -69,12 +69,16 @@ export class VerifySketch extends SketchContribution {
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);
const [data, fqbn] = await Promise.all([
this.boardsDataStore.getData(boardsConfig.selectedBoard.fqbn),
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn)
]);
this.outputChannelManager.getChannel('Arduino: compile').clear();
await this.coreService.compile({
sketchUri: uri,
fqbn,
optimizeForDebug: this.editorMode.compileForDebug
optimizeForDebug: this.editorMode.compileForDebug,
programmer: data.selectedProgrammer
});
this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) {

View File

@ -1,4 +1,5 @@
import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
import { Programmer } from './boards-service';
export const CoreServiceClient = Symbol('CoreServiceClient');
export interface CoreServiceClient {
@ -19,6 +20,7 @@ export namespace CoreService {
readonly sketchUri: string;
readonly fqbn: string;
readonly optimizeForDebug: boolean;
readonly programmer?: Programmer;
}
}

View File

@ -61,6 +61,9 @@ export class CoreServiceImpl implements CoreService {
compilerReq.setPreprocess(false);
compilerReq.setVerbose(true);
compilerReq.setQuiet(false);
if (options.programmer) {
compilerReq.setProgrammer(options.programmer.id);
}
const result = client.compile(compilerReq);
try {
@ -89,7 +92,6 @@ export class CoreServiceImpl implements CoreService {
}
const sketchpath = path.dirname(sketchFilePath);
const coreClient = await this.coreClientProvider.client();
if (!coreClient) {
return;
@ -100,12 +102,15 @@ export class CoreServiceImpl implements CoreService {
throw new Error('The selected board has no FQBN.');
}
const req = new UploadReq();
req.setInstance(instance);
req.setSketchPath(sketchpath);
req.setFqbn(fqbn);
req.setPort(options.port);
const result = client.upload(req);
const uploadReq = new UploadReq();
uploadReq.setInstance(instance);
uploadReq.setSketchPath(sketchpath);
uploadReq.setFqbn(fqbn);
uploadReq.setPort(options.port);
if (options.programmer) {
uploadReq.setProgrammer(options.programmer.id);
}
const result = client.upload(uploadReq);
try {
await new Promise<void>((resolve, reject) => {