Skip to content

Commit af33dce

Browse files
committedJan 31, 2022
Solve ports conflicts with same address and different protocol
1 parent b3b2279 commit af33dce

File tree

12 files changed

+124
-121
lines changed

12 files changed

+124
-121
lines changed
 

‎arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as React from 'react';
33
import { remote } from 'electron';
44
import {
55
BoardsService,
6-
Port,
76
SketchesService,
87
ExecutableService,
98
Sketch,
@@ -216,7 +215,7 @@ export class ArduinoFrontendContribution
216215
? nls.localize(
217216
'arduino/common/selectedOn',
218217
'on {0}',
219-
Port.toString(selectedPort)
218+
selectedPort.address
220219
)
221220
: nls.localize('arduino/common/notConnected', '[not connected]'),
222221
className: 'arduino-selected-port',

‎arduino-ide-extension/src/browser/boards/boards-config.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class BoardsConfig extends React.Component<
167167
this.queryPorts(Promise.resolve(ports)).then(({ knownPorts }) => {
168168
let { selectedPort } = this.state;
169169
// If the currently selected port is not available anymore, unset the selected port.
170-
if (removedPorts.some((port) => Port.equals(port, selectedPort))) {
170+
if (removedPorts.some((port) => Port.sameAs(port, selectedPort))) {
171171
selectedPort = undefined;
172172
}
173173
this.setState({ knownPorts, selectedPort }, () =>
@@ -213,11 +213,11 @@ export class BoardsConfig extends React.Component<
213213
} else if (left.protocol === right.protocol) {
214214
// We show ports, including those that have guessed
215215
// or unrecognized boards, so we must sort those too.
216-
const leftBoard = this.availableBoards.find((board) =>
217-
Port.sameAs(board.port, left)
216+
const leftBoard = this.availableBoards.find(
217+
(board) => board.port === left
218218
);
219-
const rightBoard = this.availableBoards.find((board) =>
220-
Port.sameAs(board.port, right)
219+
const rightBoard = this.availableBoards.find(
220+
(board) => board.port === right
221221
);
222222
if (leftBoard && !rightBoard) {
223223
return -1;
@@ -348,10 +348,10 @@ export class BoardsConfig extends React.Component<
348348
<div className="ports list">
349349
{ports.map((port) => (
350350
<Item<Port>
351-
key={Port.toString(port)}
351+
key={`${port.id}`}
352352
item={port}
353353
label={Port.toString(port)}
354-
selected={Port.equals(this.state.selectedPort, port)}
354+
selected={Port.sameAs(this.state.selectedPort, port)}
355355
onClick={this.selectPort}
356356
/>
357357
))}
@@ -410,7 +410,7 @@ export namespace BoardsConfig {
410410
return options.default;
411411
}
412412
const { name } = selectedBoard;
413-
return `${name}${port ? ' at ' + Port.toString(port) : ''}`;
413+
return `${name}${port ? ` at ${port.address}` : ''}`;
414414
}
415415

416416
export function setConfig(

‎arduino-ide-extension/src/browser/boards/boards-service-provider.ts

+14-15
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
185185
const selectedAvailableBoard = AvailableBoard.is(selectedBoard)
186186
? selectedBoard
187187
: this._availableBoards.find((availableBoard) =>
188-
Board.sameAs(availableBoard, selectedBoard)
189-
);
188+
Board.sameAs(availableBoard, selectedBoard)
189+
);
190190
if (
191191
selectedAvailableBoard &&
192192
selectedAvailableBoard.selected &&
@@ -244,7 +244,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
244244
}
245245

246246
set boardsConfig(config: BoardsConfig.Config) {
247-
this.doSetBoardsConfig(config);
247+
this.setBoardsConfig(config);
248248
this.saveState().finally(() =>
249249
this.reconcileAvailableBoards().finally(() =>
250250
this.onBoardsConfigChangedEmitter.fire(this._boardsConfig)
@@ -256,7 +256,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
256256
return this._boardsConfig;
257257
}
258258

259-
protected doSetBoardsConfig(config: BoardsConfig.Config): void {
259+
protected setBoardsConfig(config: BoardsConfig.Config): void {
260260
this.logger.info('Board config changed: ', JSON.stringify(config));
261261
this._boardsConfig = config;
262262
this.latestBoardsConfig = this._boardsConfig;
@@ -370,19 +370,19 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
370370
const find = (needle: Board & { port: Port }, haystack: AvailableBoard[]) =>
371371
haystack.find(
372372
(board) =>
373-
Board.equals(needle, board) && Port.equals(needle.port, board.port)
373+
Board.equals(needle, board) && Port.sameAs(needle.port, board.port)
374374
);
375375
const timeoutTask =
376376
!!timeout && timeout > 0
377377
? new Promise<void>((_, reject) =>
378-
setTimeout(
379-
() => reject(new Error(`Timeout after ${timeout} ms.`)),
380-
timeout
381-
)
378+
setTimeout(
379+
() => reject(new Error(`Timeout after ${timeout} ms.`)),
380+
timeout
382381
)
382+
)
383383
: new Promise<void>(() => {
384-
/* never */
385-
});
384+
/* never */
385+
});
386386
const waitUntilTask = new Promise<void>((resolve) => {
387387
let candidate = find(what, this.availableBoards);
388388
if (candidate) {
@@ -409,7 +409,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
409409
Port.sameAs(port, this.boardsConfig.selectedPort)
410410
)
411411
) {
412-
this.doSetBoardsConfig({
412+
this.setBoardsConfig({
413413
selectedBoard: this.boardsConfig.selectedBoard,
414414
selectedPort: undefined,
415415
});
@@ -533,9 +533,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
533533

534534
protected getLastSelectedBoardOnPortKey(port: Port | string): string {
535535
// TODO: we lose the port's `protocol` info (`serial`, `network`, etc.) here if the `port` is a `string`.
536-
return `last-selected-board-on-port:${
537-
typeof port === 'string' ? port : Port.toString(port)
538-
}`;
536+
return `last-selected-board-on-port:${typeof port === 'string' ? port : port.address
537+
}`;
539538
}
540539

541540
protected async loadState(): Promise<void> {

‎arduino-ide-extension/src/browser/contributions/board-selection.ts

+14-15
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,9 @@ PID: ${PID}`;
204204

205205
const packageLabel =
206206
packageName +
207-
`${
208-
manuallyInstalled
209-
? nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)')
210-
: ''
207+
`${manuallyInstalled
208+
? nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)')
209+
: ''
211210
}`;
212211
// Platform submenu
213212
const platformMenuPath = [...boardsPackagesGroup, packageId];
@@ -255,8 +254,8 @@ PID: ${PID}`;
255254
protocolOrder: number,
256255
ports: AvailablePorts
257256
) => {
258-
const addresses = Object.keys(ports);
259-
if (!addresses.length) {
257+
const portIDs = Object.keys(ports);
258+
if (!portIDs.length) {
260259
return;
261260
}
262261

@@ -279,27 +278,27 @@ PID: ${PID}`;
279278

280279
// First we show addresses with recognized boards connected,
281280
// then all the rest.
282-
const sortedAddresses = Object.keys(ports);
283-
sortedAddresses.sort((left: string, right: string): number => {
281+
const sortedIDs = Object.keys(ports);
282+
sortedIDs.sort((left: string, right: string): number => {
284283
const [, leftBoards] = ports[left];
285284
const [, rightBoards] = ports[right];
286285
return rightBoards.length - leftBoards.length;
287286
});
288287

289-
for (let i = 0; i < sortedAddresses.length; i++) {
290-
const address = sortedAddresses[i];
291-
const [port, boards] = ports[address];
292-
let label = `${address}`;
288+
for (let i = 0; i < sortedIDs.length; i++) {
289+
const portID = sortedIDs[i];
290+
const [port, boards] = ports[portID];
291+
let label = `${port.address}`;
293292
if (boards.length) {
294293
const boardsList = boards.map((board) => board.name).join(', ');
295294
label = `${label} (${boardsList})`;
296295
}
297-
const id = `arduino-select-port--${address}`;
296+
const id = `arduino-select-port--${portID}`;
298297
const command = { id };
299298
const handler = {
300299
execute: () => {
301300
if (
302-
!Port.equals(
301+
!Port.sameAs(
303302
port,
304303
this.boardsServiceProvider.boardsConfig.selectedPort
305304
)
@@ -312,7 +311,7 @@ PID: ${PID}`;
312311
}
313312
},
314313
isToggled: () =>
315-
Port.equals(
314+
Port.sameAs(
316315
port,
317316
this.boardsServiceProvider.boardsConfig.selectedPort
318317
),

‎arduino-ide-extension/src/browser/serial/monitor/serial-monitor-send-input.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { Key, KeyCode } from '@theia/core/lib/browser/keys';
3-
import { Board, Port } from '../../../common/protocol/boards-service';
3+
import { Board } from '../../../common/protocol/boards-service';
44
import { isOSX } from '@theia/core/lib/common/os';
55
import { DisposableCollection, nls } from '@theia/core/lib/common';
66
import { SerialConnectionManager } from '../serial-connection-manager';
@@ -87,7 +87,7 @@ export class SerialMonitorSendInput extends React.Component<
8787
useFqbn: false,
8888
})
8989
: 'unknown',
90-
port ? Port.toString(port) : 'unknown'
90+
port ? port.address : 'unknown'
9191
);
9292
}
9393

‎arduino-ide-extension/src/browser/serial/serial-connection-manager.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '../../common/protocol/serial-service';
1111
import { BoardsServiceProvider } from '../boards/boards-service-provider';
1212
import {
13-
Port,
1413
Board,
1514
BoardsService,
1615
} from '../../common/protocol/boards-service';
@@ -217,7 +216,7 @@ export class SerialConnectionManager {
217216
nls.localize(
218217
'arduino/serial/connectionBusy',
219218
'Connection failed. Serial port is busy: {0}',
220-
Port.toString(port)
219+
port.address
221220
),
222221
options
223222
);
@@ -232,7 +231,7 @@ export class SerialConnectionManager {
232231
Board.toString(board, {
233232
useFqbn: false,
234233
}),
235-
Port.toString(port)
234+
port.address
236235
),
237236
options
238237
);
@@ -244,7 +243,7 @@ export class SerialConnectionManager {
244243
'arduino/serial/unexpectedError',
245244
'Unexpected error. Reconnecting {0} on port {1}.',
246245
Board.toString(board),
247-
Port.toString(port)
246+
port.address
248247
),
249248
options
250249
);
@@ -262,7 +261,7 @@ export class SerialConnectionManager {
262261
Board.toString(board, {
263262
useFqbn: false,
264263
}),
265-
Port.toString(port)
264+
port.address
266265
)
267266
);
268267
this.serialErrors.length = 0;
@@ -280,7 +279,7 @@ export class SerialConnectionManager {
280279
Board.toString(board, {
281280
useFqbn: false,
282281
}),
283-
Port.toString(port),
282+
port.address,
284283
attempts.toString()
285284
)
286285
);
@@ -351,7 +350,7 @@ export namespace Serial {
351350
export function toString(config: Partial<SerialConfig>): string {
352351
if (!isSerialConfig(config)) return '';
353352
const { board, port } = config;
354-
return `${Board.toString(board)} ${Port.toString(port)}`;
353+
return `${Board.toString(board)} ${port.address}`;
355354
}
356355
}
357356
}

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

+17-42
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export type AvailablePorts = Record<string, [Port, Array<Board>]>;
77
export namespace AvailablePorts {
88
export function byProtocol(availablePorts: AvailablePorts): Map<string, AvailablePorts> {
99
const grouped = new Map<string, AvailablePorts>();
10-
for (const address of Object.keys(availablePorts)) {
11-
const [port, boards] = availablePorts[address];
10+
for (const portID of Object.keys(availablePorts)) {
11+
const [port, boards] = availablePorts[portID];
1212
let ports = grouped.get(port.protocol);
1313
if (!ports) {
1414
ports = {} as AvailablePorts;
1515
}
16-
ports[address] = [port, boards];
16+
ports[portID] = [port, boards];
1717
grouped.set(port.protocol, ports);
1818
}
1919
return grouped;
@@ -43,7 +43,7 @@ export namespace AttachedBoardsChangeEvent {
4343
const visitedDetachedPorts: Port[] = [];
4444
for (const board of attached.boards) {
4545
const port = board.port
46-
? ` on ${Port.toString(board.port, { useLabel: true })}`
46+
? ` on ${Port.toString(board.port)}`
4747
: '';
4848
rows.push(` - Attached board: ${Board.toString(board)}${port}`);
4949
if (board.port) {
@@ -52,7 +52,7 @@ export namespace AttachedBoardsChangeEvent {
5252
}
5353
for (const board of detached.boards) {
5454
const port = board.port
55-
? ` from ${Port.toString(board.port, { useLabel: true })}`
55+
? ` from ${Port.toString(board.port)}`
5656
: '';
5757
rows.push(` - Detached board: ${Board.toString(board)}${port}`);
5858
if (board.port) {
@@ -62,18 +62,14 @@ export namespace AttachedBoardsChangeEvent {
6262
for (const port of attached.ports) {
6363
if (!visitedAttachedPorts.find((p) => Port.sameAs(port, p))) {
6464
rows.push(
65-
` - New port is available on ${Port.toString(port, {
66-
useLabel: true,
67-
})}`
65+
` - New port is available on ${Port.toString(port)}`
6866
);
6967
}
7068
}
7169
for (const port of detached.ports) {
7270
if (!visitedDetachedPorts.find((p) => Port.sameAs(port, p))) {
7371
rows.push(
74-
` - Port is no longer available on ${Port.toString(port, {
75-
useLabel: true,
76-
})}`
72+
` - Port is no longer available on ${Port.toString(port)}`
7773
);
7874
}
7975
}
@@ -147,12 +143,14 @@ export interface BoardsService
147143
}
148144

149145
export interface Port {
146+
// id is the combination of address and protocol
147+
// formatted like "<address>|<protocol>" used
148+
// to univocally recognize a port
149+
readonly id: string;
150150
readonly address: string;
151+
readonly addressLabel: string;
151152
readonly protocol: string;
152-
/**
153-
* Optional label for the protocol. For example: `Serial Port (USB)`.
154-
*/
155-
readonly label?: string;
153+
readonly protocolLabel: string;
156154
}
157155
export namespace Port {
158156
export function is(arg: any): arg is Port {
@@ -165,14 +163,8 @@ export namespace Port {
165163
);
166164
}
167165

168-
export function toString(
169-
port: Port,
170-
options: { useLabel: boolean } = { useLabel: false }
171-
): string {
172-
if (options.useLabel && port.label) {
173-
return `${port.address} ${port.label}`;
174-
}
175-
return port.address;
166+
export function toString(port: Port): string {
167+
return `${port.addressLabel} ${port.protocolLabel}`;
176168
}
177169

178170
export function compare(left: Port, right: Port): number {
@@ -192,29 +184,12 @@ export namespace Port {
192184
return naturalCompare(left.address!, right.address!);
193185
}
194186

195-
export function equals(
187+
export function sameAs(
196188
left: Port | undefined,
197189
right: Port | undefined
198190
): boolean {
199191
if (left && right) {
200-
return (
201-
left.address === right.address &&
202-
left.protocol === right.protocol &&
203-
(left.label || '') === (right.label || '')
204-
);
205-
}
206-
return left === right;
207-
}
208-
209-
export function sameAs(
210-
left: Port | undefined,
211-
right: Port | string | undefined
212-
) {
213-
if (left && right) {
214-
if (typeof right === 'string') {
215-
return left.address === right;
216-
}
217-
return left.address === right.address;
192+
return left.address === right.address && left.protocol === right.protocol;
218193
}
219194
return false;
220195
}

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

+26-14
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,22 @@ export class BoardDiscovery extends CoreClientAware {
124124

125125
const address = (detectedPort as any).getPort().getAddress();
126126
const protocol = (detectedPort as any).getPort().getProtocol();
127+
// Different discoveries can detect the same port with different
128+
// protocols, so we consider the combination of address and protocol
129+
// to be the id of a certain port to distinguish it from others.
130+
// If we'd use only the address of a port to store it in a map
131+
// we can have conflicts the same port is found with multiple
132+
// protocols.
133+
const portID = `${address}|${protocol}`;
127134
const label = (detectedPort as any).getPort().getLabel();
128-
const port = { address, protocol, label };
135+
const protocolLabel = (detectedPort as any).getPort().getProtocolLabel();
136+
const port = {
137+
id: portID,
138+
address,
139+
addressLabel: label,
140+
protocol,
141+
protocolLabel,
142+
};
129143
const boards: Board[] = [];
130144
for (const item of detectedPort.getMatchingBoardsList()) {
131145
boards.push({
@@ -136,23 +150,21 @@ export class BoardDiscovery extends CoreClientAware {
136150
}
137151

138152
if (eventType === 'add') {
139-
if (newState[port.address]) {
140-
const [, knownBoards] = newState[port.address];
153+
if (newState[portID]) {
154+
const [, knownBoards] = newState[portID];
141155
console.warn(
142-
`Port '${
143-
port.address
144-
}' was already available. Known boards before override: ${JSON.stringify(
156+
`Port '${Port.toString(port)}' was already available. Known boards before override: ${JSON.stringify(
145157
knownBoards
146158
)}`
147159
);
148160
}
149-
newState[port.address] = [port, boards];
161+
newState[portID] = [port, boards];
150162
} else if (eventType === 'remove') {
151-
if (!newState[port.address]) {
152-
console.warn(`Port '${port.address}' was not available. Skipping`);
163+
if (!newState[portID]) {
164+
console.warn(`Port '${Port.toString(port)}' was not available. Skipping`);
153165
return;
154166
}
155-
delete newState[port.address];
167+
delete newState[portID];
156168
}
157169

158170
const oldAvailablePorts = this.getAvailablePorts(oldState);
@@ -179,17 +191,17 @@ export class BoardDiscovery extends CoreClientAware {
179191

180192
getAttachedBoards(state: AvailablePorts = this.state): Board[] {
181193
const attachedBoards: Board[] = [];
182-
for (const address of Object.keys(state)) {
183-
const [, boards] = state[address];
194+
for (const portID of Object.keys(state)) {
195+
const [, boards] = state[portID];
184196
attachedBoards.push(...boards);
185197
}
186198
return attachedBoards;
187199
}
188200

189201
getAvailablePorts(state: AvailablePorts = this.state): Port[] {
190202
const availablePorts: Port[] = [];
191-
for (const address of Object.keys(state)) {
192-
const [port] = state[address];
203+
for (const portID of Object.keys(state)) {
204+
const [port] = state[portID];
193205
availablePorts.push(port);
194206
}
195207
return availablePorts;

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
159159
const p = new Port();
160160
if (port) {
161161
p.setAddress(port.address);
162-
p.setLabel(port.label || '');
162+
p.setLabel(port.addressLabel);
163163
p.setProtocol(port.protocol);
164+
p.setProtocolLabel(port.protocolLabel);
164165
}
165166
req.setPort(p);
166167
if (programmer) {
@@ -229,8 +230,9 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
229230
const p = new Port();
230231
if (port) {
231232
p.setAddress(port.address);
232-
p.setLabel(port.label || '');
233+
p.setLabel(port.addressLabel);
233234
p.setProtocol(port.protocol);
235+
p.setProtocolLabel(port.protocolLabel);
234236
}
235237
burnReq.setPort(p);
236238
if (programmer) {

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
MonitorConfig as GrpcMonitorConfig,
1717
} from '../cli-protocol/cc/arduino/cli/monitor/v1/monitor_pb';
1818
import { MonitorClientProvider } from './monitor-client-provider';
19-
import { Board, Port } from '../../common/protocol/boards-service';
19+
import { Board } from '../../common/protocol/boards-service';
2020
import { WebSocketService } from '../web-socket/web-socket-service';
2121
import { SerialPlotter } from '../../browser/serial/plotter/protocol';
2222
import { Disposable } from '@theia/core/shared/vscode-languageserver-protocol';
@@ -88,7 +88,7 @@ export class SerialServiceImpl implements SerialService {
8888

8989
@inject(WebSocketService)
9090
protected readonly webSocketService: WebSocketService
91-
) {}
91+
) { }
9292

9393
async isSerialPortOpen(): Promise<boolean> {
9494
return !!this.serialConnection;
@@ -153,7 +153,7 @@ export class SerialServiceImpl implements SerialService {
153153
this.logger.info(
154154
`>>> Creating serial connection for ${Board.toString(
155155
this.serialConfig.board
156-
)} on port ${Port.toString(this.serialConfig.port)}...`
156+
)} on port ${this.serialConfig.port.address}...`
157157
);
158158

159159
if (this.serialConnection) {
@@ -225,7 +225,7 @@ export class SerialServiceImpl implements SerialService {
225225
default:
226226
break;
227227
}
228-
} catch (error) {}
228+
} catch (error) { }
229229
}
230230
);
231231

@@ -272,12 +272,12 @@ export class SerialServiceImpl implements SerialService {
272272
serialConnection.duplex.write(req, () => {
273273
const boardName = this.serialConfig?.board
274274
? Board.toString(this.serialConfig.board, {
275-
useFqbn: false,
276-
})
275+
useFqbn: false,
276+
})
277277
: 'unknown board';
278278

279279
const portName = this.serialConfig?.port
280-
? Port.toString(this.serialConfig.port)
280+
? this.serialConfig.port.address
281281
: 'unknown port';
282282
this.logger.info(
283283
`<<< Serial connection created for ${boardName} on port ${portName}.`
@@ -330,7 +330,7 @@ export class SerialServiceImpl implements SerialService {
330330
this.logger.info(
331331
`<<< Disposed serial connection for ${Board.toString(config.board, {
332332
useFqbn: false,
333-
})} on port ${Port.toString(config.port)}.`
333+
})} on port ${config.port.address}.`
334334
);
335335

336336
duplex.cancel();

‎arduino-ide-extension/src/test/browser/fixtures/boards.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ import { Board, BoardsPackage, Port } from '../../../common/protocol';
44
export const aBoard: Board = {
55
fqbn: 'some:board:fqbn',
66
name: 'Some Arduino Board',
7-
port: { address: '/lol/port1234', protocol: 'serial' },
7+
port: {
8+
id: '/lol/port1234|serial',
9+
address: '/lol/port1234',
10+
addressLabel: '/lol/port1234',
11+
protocol: 'serial',
12+
protocolLabel: 'Serial Port (USB)',
13+
},
814
};
915
export const aPort: Port = {
16+
id: aBoard.port!.id,
1017
address: aBoard.port!.address,
18+
addressLabel: aBoard.port!.addressLabel,
1119
protocol: aBoard.port!.protocol,
20+
protocolLabel: aBoard.port!.protocolLabel,
1221
};
1322
export const aBoardConfig: BoardsConfig.Config = {
1423
selectedBoard: aBoard,
@@ -17,11 +26,20 @@ export const aBoardConfig: BoardsConfig.Config = {
1726
export const anotherBoard: Board = {
1827
fqbn: 'another:board:fqbn',
1928
name: 'Another Arduino Board',
20-
port: { address: '/kek/port5678', protocol: 'serial' },
29+
port: {
30+
id: '/kek/port5678|serial',
31+
address: '/kek/port5678',
32+
addressLabel: '/kek/port5678',
33+
protocol: 'serial',
34+
protocolLabel: 'Serial Port (USB)',
35+
},
2136
};
2237
export const anotherPort: Port = {
38+
id: anotherBoard.port!.id,
2339
address: anotherBoard.port!.address,
40+
addressLabel: anotherBoard.port!.addressLabel,
2441
protocol: anotherBoard.port!.protocol,
42+
protocolLabel: anotherBoard.port!.protocolLabel,
2543
};
2644
export const anotherBoardConfig: BoardsConfig.Config = {
2745
selectedBoard: anotherBoard,

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('SerialServiceImpl', () => {
8686

8787
context('when a disconnection is requested', () => {
8888
const sandbox = createSandbox();
89-
beforeEach(() => {});
89+
beforeEach(() => { });
9090

9191
afterEach(function () {
9292
sandbox.restore();
@@ -132,11 +132,11 @@ describe('SerialServiceImpl', () => {
132132
return {
133133
streamingOpen: () => {
134134
return {
135-
on: (str: string, cb: any) => {},
135+
on: (str: string, cb: any) => { },
136136
write: (chunk: any, cb: any) => {
137137
cb();
138138
},
139-
cancel: () => {},
139+
cancel: () => { },
140140
};
141141
},
142142
} as MonitorServiceClient;
@@ -146,7 +146,7 @@ describe('SerialServiceImpl', () => {
146146

147147
await subject.setSerialConfig({
148148
board: { name: 'test' },
149-
port: { address: 'test', protocol: 'test' },
149+
port: { id: 'test|test', address: 'test', addressLabel: 'test', protocol: 'test', protocolLabel: 'test' },
150150
});
151151
});
152152

0 commit comments

Comments
 (0)
Please sign in to comment.