Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f8b227

Browse files
Alberto Iannacconesilvanocerza
Alberto Iannaccone
andauthored
[ATL-1531] Integrate arduino-cli 0.19.1 (#506)
* integrate cli 0.19.0 * Update CLI version used to fix crash on lib/core install/uninstall * Update CLI version * Update CLI version * update cli version Co-authored-by: Silvano Cerza <silvanocerza@gmail.com>
1 parent ba177be commit 7f8b227

30 files changed

+3066
-1207
lines changed

‎arduino-ide-extension/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
],
141141
"arduino": {
142142
"cli": {
143-
"version": "0.18.3"
143+
"version": "0.19.1"
144144
},
145145
"fwuploader": {
146146
"version": "2.0.0"

‎arduino-ide-extension/src/browser/contributions/burn-bootloader.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class BurnBootloader extends SketchContribution {
5050
}
5151
try {
5252
const { boardsConfig } = this.boardsServiceClientImpl;
53-
const port = boardsConfig.selectedPort?.address;
53+
const port = boardsConfig.selectedPort;
5454
const [fqbn, { selectedProgrammer: programmer }, verify, verbose] =
5555
await Promise.all([
5656
this.boardsDataStore.appendConfigToFqbn(

‎arduino-ide-extension/src/browser/contributions/upload-sketch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class UploadSketch extends SketchContribution {
130130
const sketchUri = sketch.uri;
131131
const optimizeForDebug = this.editorMode.compileForDebug;
132132
const { selectedPort } = boardsConfig;
133-
const port = selectedPort?.address;
133+
const port = selectedPort;
134134

135135
if (usingProgrammer) {
136136
const programmer = selectedProgrammer;

‎arduino-ide-extension/src/common/protocol/core-service.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Port } from '../../common/protocol/boards-service';
12
import { Programmer } from './boards-service';
23

34
export const CompilerWarningLiterals = [
@@ -39,7 +40,7 @@ export namespace CoreService {
3940

4041
export namespace Upload {
4142
export interface Options extends Compile.Options {
42-
readonly port?: string | undefined;
43+
readonly port?: Port | undefined;
4344
readonly programmer?: Programmer | undefined;
4445
readonly verify: boolean;
4546
}
@@ -48,7 +49,7 @@ export namespace CoreService {
4849
export namespace Bootloader {
4950
export interface Options {
5051
readonly fqbn?: string | undefined;
51-
readonly port?: string | undefined;
52+
readonly port?: Port | undefined;
5253
readonly programmer?: Programmer | undefined;
5354
readonly verbose: boolean;
5455
readonly verify: boolean;

‎arduino-ide-extension/src/node/board-discovery.ts‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { injectable, inject, postConstruct, named } from 'inversify';
22
import { ClientDuplexStream } from '@grpc/grpc-js';
33
import { ILogger } from '@theia/core/lib/common/logger';
44
import { deepClone } from '@theia/core/lib/common/objects';
5-
import { CoreClientAware } from './core-client-provider';
5+
import { CoreClientAware,CoreClientProvider } from './core-client-provider';
66
import {
77
BoardListWatchRequest,
88
BoardListWatchResponse,
@@ -29,6 +29,10 @@ export class BoardDiscovery extends CoreClientAware {
2929
@inject(NotificationServiceServer)
3030
protected readonly notificationService: NotificationServiceServer;
3131

32+
// Used to know if the board watch process is already running to avoid
33+
// starting it multiple times
34+
private watching: boolean;
35+
3236
protected boardWatchDuplex:
3337
| ClientDuplexStream<BoardListWatchRequest, BoardListWatchResponse>
3438
| undefined;
@@ -51,11 +55,26 @@ export class BoardDiscovery extends CoreClientAware {
5155

5256
@postConstruct()
5357
protected async init(): Promise<void> {
58+
await this.coreClientProvider.initialized;
5459
const coreClient = await this.coreClient();
60+
this.startBoardListWatch(coreClient);
61+
}
62+
63+
startBoardListWatch(coreClient: CoreClientProvider.Client): void {
64+
if (this.watching) {
65+
// We want to avoid starting the board list watch process multiple
66+
// times to meet unforseen consequences
67+
return
68+
}
69+
this.watching = true;
5570
const { client, instance } = coreClient;
5671
const req = new BoardListWatchRequest();
5772
req.setInstance(instance);
5873
this.boardWatchDuplex = client.boardListWatch();
74+
this.boardWatchDuplex.on('end', () => {
75+
this.watching = false;
76+
console.info('board watch ended')
77+
})
5978
this.boardWatchDuplex.on('data', (resp: BoardListWatchResponse) => {
6079
const detectedPort = resp.getPort();
6180
if (detectedPort) {
@@ -75,12 +94,14 @@ export class BoardDiscovery extends CoreClientAware {
7594
const oldState = deepClone(this._state);
7695
const newState = deepClone(this._state);
7796

78-
const address = detectedPort.getAddress();
79-
const protocol = Port.Protocol.toProtocol(detectedPort.getProtocol());
97+
const address = (detectedPort as any).getPort().getAddress();
98+
const protocol = Port.Protocol.toProtocol(
99+
(detectedPort as any).getPort().getProtocol()
100+
);
80101
// const label = detectedPort.getProtocolLabel();
81102
const port = { address, protocol };
82103
const boards: Board[] = [];
83-
for (const item of detectedPort.getBoardsList()) {
104+
for (const item of detectedPort.getMatchingBoardsList()) {
84105
boards.push({
85106
fqbn: item.getFqbn(),
86107
name: item.getName() || 'unknown',
@@ -92,9 +113,7 @@ export class BoardDiscovery extends CoreClientAware {
92113
if (newState[port.address] !== undefined) {
93114
const [, knownBoards] = newState[port.address];
94115
console.warn(
95-
`Port '${
96-
port.address
97-
}' was already available. Known boards before override: ${JSON.stringify(
116+
`Port '${port.address}' was already available. Known boards before override: ${JSON.stringify(
98117
knownBoards
99118
)}`
100119
);

‎arduino-ide-extension/src/node/boards-service-impl.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ import { InstallWithProgress } from './grpc-installable';
4242
@injectable()
4343
export class BoardsServiceImpl
4444
extends CoreClientAware
45-
implements BoardsService
46-
{
45+
implements BoardsService {
4746
@inject(ILogger)
4847
protected logger: ILogger;
4948

@@ -75,6 +74,7 @@ export class BoardsServiceImpl
7574
async getBoardDetails(options: {
7675
fqbn: string;
7776
}): Promise<BoardDetails | undefined> {
77+
await this.coreClientProvider.initialized;
7878
const coreClient = await this.coreClient();
7979
const { client, instance } = coreClient;
8080
const { fqbn } = options;
@@ -165,13 +165,13 @@ export class BoardsServiceImpl
165165

166166
let VID = 'N/A';
167167
let PID = 'N/A';
168-
const usbId = detailsResp
169-
.getIdentificationPrefsList()
170-
.map((item) => item.getUsbId())
168+
const prop = detailsResp
169+
.getIdentificationPropertiesList()
170+
.map((item) => item.getPropertiesMap())
171171
.find(notEmpty);
172-
if (usbId) {
173-
VID = usbId.getVid();
174-
PID = usbId.getPid();
172+
if (prop) {
173+
VID = prop.get('vid')||'';
174+
PID = prop.get('pid')||'';
175175
}
176176

177177
return {
@@ -214,6 +214,7 @@ export class BoardsServiceImpl
214214
}: {
215215
query?: string;
216216
}): Promise<BoardWithPackage[]> {
217+
await this.coreClientProvider.initialized;
217218
const { instance, client } = await this.coreClient();
218219
const req = new BoardSearchRequest();
219220
req.setSearchArgs(query || '');
@@ -244,6 +245,7 @@ export class BoardsServiceImpl
244245
}
245246

246247
async search(options: { query?: string }): Promise<BoardsPackage[]> {
248+
await this.coreClientProvider.initialized;
247249
const coreClient = await this.coreClient();
248250
const { client, instance } = coreClient;
249251

@@ -361,6 +363,7 @@ export class BoardsServiceImpl
361363
const version = !!options.version
362364
? options.version
363365
: item.availableVersions[0];
366+
await this.coreClientProvider.initialized;
364367
const coreClient = await this.coreClient();
365368
const { client, instance } = coreClient;
366369

@@ -382,7 +385,10 @@ export class BoardsServiceImpl
382385
})
383386
);
384387
await new Promise<void>((resolve, reject) => {
385-
resp.on('end', resolve);
388+
resp.on('end', () => {
389+
this.boardDiscovery.startBoardListWatch(coreClient)
390+
resolve();
391+
});
386392
resp.on('error', (error) => {
387393
this.responseService.appendToOutput({
388394
chunk: `Failed to install platform: ${item.id}.\n`,
@@ -406,6 +412,7 @@ export class BoardsServiceImpl
406412
progressId?: string;
407413
}): Promise<void> {
408414
const { item, progressId } = options;
415+
await this.coreClientProvider.initialized;
409416
const coreClient = await this.coreClient();
410417
const { client, instance } = coreClient;
411418

@@ -426,7 +433,10 @@ export class BoardsServiceImpl
426433
})
427434
);
428435
await new Promise<void>((resolve, reject) => {
429-
resp.on('end', resolve);
436+
resp.on('end', () => {
437+
this.boardDiscovery.startBoardListWatch(coreClient)
438+
resolve();
439+
});
430440
resp.on('error', reject);
431441
});
432442

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /