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) { if (!boardsConfig.selectedBoard.fqbn) {
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`); 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(); this.outputChannelManager.getChannel('Arduino: upload').clear();
await this.coreService.upload({ await this.coreService.upload({
sketchUri: uri, sketchUri: uri,
fqbn, fqbn,
port: selectedPort.address, port: selectedPort.address,
optimizeForDebug: this.editorMode.compileForDebug optimizeForDebug: this.editorMode.compileForDebug,
programmer: data.selectedProgrammer
}); });
this.messageService.info('Done uploading.', { timeout: 1000 }); this.messageService.info('Done uploading.', { timeout: 1000 });
} catch (e) { } catch (e) {

View File

@ -69,12 +69,16 @@ export class VerifySketch extends SketchContribution {
if (!boardsConfig.selectedBoard.fqbn) { if (!boardsConfig.selectedBoard.fqbn) {
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`); 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(); this.outputChannelManager.getChannel('Arduino: compile').clear();
await this.coreService.compile({ await this.coreService.compile({
sketchUri: uri, sketchUri: uri,
fqbn, fqbn,
optimizeForDebug: this.editorMode.compileForDebug optimizeForDebug: this.editorMode.compileForDebug,
programmer: data.selectedProgrammer
}); });
this.messageService.info('Done compiling.', { timeout: 1000 }); this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) { } catch (e) {

View File

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

View File

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