mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-27 05:06:42 +00:00
Updated port discovery to support unknown boards
From now on, we do not retrieve the ports from the attached boards. A board can be unknown but the port is still relevant. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
8971dc4c5f
commit
4353bfb5b9
@ -30,6 +30,7 @@
|
|||||||
"react-select": "^3.0.4",
|
"react-select": "^3.0.4",
|
||||||
"p-queue": "^5.0.0",
|
"p-queue": "^5.0.0",
|
||||||
"ps-tree": "^1.2.0",
|
"ps-tree": "^1.2.0",
|
||||||
|
"string-natural-compare": "^2.0.3",
|
||||||
"tree-kill": "^1.2.1",
|
"tree-kill": "^1.2.1",
|
||||||
"upath": "^1.1.2",
|
"upath": "^1.1.2",
|
||||||
"which": "^1.3.1"
|
"which": "^1.3.1"
|
||||||
|
@ -165,7 +165,10 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
|||||||
|
|
||||||
this.registerSketchesInMenu(this.menuRegistry);
|
this.registerSketchesInMenu(this.menuRegistry);
|
||||||
|
|
||||||
this.boardsService.getAttachedBoards().then(({ boards }) => this.boardsServiceClient.tryReconnect(boards));
|
Promise.all([
|
||||||
|
this.boardsService.getAttachedBoards(),
|
||||||
|
this.boardsService.getAvailablePorts()
|
||||||
|
]).then(([{ boards }, { ports }]) => this.boardsServiceClient.tryReconnect(boards, ports));
|
||||||
}
|
}
|
||||||
|
|
||||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
||||||
@ -270,7 +273,7 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
|||||||
if (!selectedPort) {
|
if (!selectedPort) {
|
||||||
throw new Error('No ports selected. Please select a port.');
|
throw new Error('No ports selected. Please select a port.');
|
||||||
}
|
}
|
||||||
await this.coreService.upload({ uri: uri.toString(), board: boardsConfig.selectedBoard, port: selectedPort });
|
await this.coreService.upload({ uri: uri.toString(), board: boardsConfig.selectedBoard, port: selectedPort.address });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await this.messageService.error(e.toString());
|
await this.messageService.error(e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { DisposableCollection } from '@theia/core';
|
import { DisposableCollection } from '@theia/core';
|
||||||
import { BoardsService, Board, AttachedSerialBoard, AttachedBoardsChangeEvent } from '../../common/protocol/boards-service';
|
import { BoardsService, Board, Port, AttachedSerialBoard, AttachedBoardsChangeEvent } from '../../common/protocol/boards-service';
|
||||||
import { BoardsServiceClientImpl } from './boards-service-client-impl';
|
import { BoardsServiceClientImpl } from './boards-service-client-impl';
|
||||||
|
|
||||||
export namespace BoardsConfig {
|
export namespace BoardsConfig {
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
selectedBoard?: Board;
|
selectedBoard?: Board;
|
||||||
selectedPort?: string;
|
selectedPort?: Port;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
@ -19,7 +19,8 @@ export namespace BoardsConfig {
|
|||||||
|
|
||||||
export interface State extends Config {
|
export interface State extends Config {
|
||||||
searchResults: Array<Board & { packageName: string }>;
|
searchResults: Array<Board & { packageName: string }>;
|
||||||
knownPorts: string[];
|
knownPorts: Port[];
|
||||||
|
showAllPorts: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -68,16 +69,17 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
this.state = {
|
this.state = {
|
||||||
searchResults: [],
|
searchResults: [],
|
||||||
knownPorts: [],
|
knownPorts: [],
|
||||||
|
showAllPorts: false,
|
||||||
...boardsConfig
|
...boardsConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.updateBoards();
|
this.updateBoards();
|
||||||
this.props.boardsService.getAttachedBoards().then(({ boards }) => this.updatePorts(boards));
|
this.props.boardsService.getAvailablePorts().then(({ ports }) => this.updatePorts(ports));
|
||||||
const { boardsServiceClient: client } = this.props;
|
const { boardsServiceClient: client } = this.props;
|
||||||
this.toDispose.pushAll([
|
this.toDispose.pushAll([
|
||||||
client.onBoardsChanged(event => this.updatePorts(event.newState.boards, AttachedBoardsChangeEvent.diff(event).detached)),
|
client.onBoardsChanged(event => this.updatePorts(event.newState.ports, AttachedBoardsChangeEvent.diff(event).detached.ports)),
|
||||||
client.onBoardsConfigChanged(({ selectedBoard, selectedPort }) => {
|
client.onBoardsConfigChanged(({ selectedBoard, selectedPort }) => {
|
||||||
this.setState({ selectedBoard, selectedPort }, () => this.fireConfigChanged());
|
this.setState({ selectedBoard, selectedPort }, () => this.fireConfigChanged());
|
||||||
})
|
})
|
||||||
@ -101,11 +103,11 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
this.queryBoards({ query }).then(({ searchResults }) => this.setState({ searchResults }));
|
this.queryBoards({ query }).then(({ searchResults }) => this.setState({ searchResults }));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updatePorts = (boards: Board[] = [], detachedBoards: Board[] = []) => {
|
protected updatePorts = (ports: Port[] = [], removedPorts: Port[] = []) => {
|
||||||
this.queryPorts(Promise.resolve({ boards })).then(({ knownPorts }) => {
|
this.queryPorts(Promise.resolve({ ports })).then(({ knownPorts }) => {
|
||||||
let { selectedPort } = this.state;
|
let { selectedPort } = this.state;
|
||||||
const removedPorts = detachedBoards.filter(AttachedSerialBoard.is).map(({ port }) => port);
|
// If the currently selected port is not available anymore, unset the selected port.
|
||||||
if (!!selectedPort && removedPorts.indexOf(selectedPort) !== -1) {
|
if (removedPorts.some(port => Port.equals(port, selectedPort))) {
|
||||||
selectedPort = undefined;
|
selectedPort = undefined;
|
||||||
}
|
}
|
||||||
this.setState({ knownPorts, selectedPort }, () => this.fireConfigChanged());
|
this.setState({ knownPorts, selectedPort }, () => this.fireConfigChanged());
|
||||||
@ -130,18 +132,24 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
return this.props.boardsService.getAttachedBoards();
|
return this.props.boardsService.getAttachedBoards();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected queryPorts = (attachedBoards: Promise<{ boards: Board[] }> = this.attachedBoards) => {
|
protected get availablePorts(): Promise<{ ports: Port[] }> {
|
||||||
return new Promise<{ knownPorts: string[] }>(resolve => {
|
return this.props.boardsService.getAvailablePorts();
|
||||||
attachedBoards
|
}
|
||||||
.then(({ boards }) => boards
|
|
||||||
.filter(AttachedSerialBoard.is)
|
protected queryPorts = (availablePorts: Promise<{ ports: Port[] }> = this.availablePorts) => {
|
||||||
.map(({ port }) => port)
|
return new Promise<{ knownPorts: Port[] }>(resolve => {
|
||||||
.sort())
|
availablePorts
|
||||||
|
.then(({ ports }) => ports
|
||||||
|
.sort(Port.compare))
|
||||||
.then(knownPorts => resolve({ knownPorts }));
|
.then(knownPorts => resolve({ knownPorts }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected selectPort = (selectedPort: string | undefined) => {
|
protected toggleFilterPorts = () => {
|
||||||
|
this.setState({ showAllPorts: !this.state.showAllPorts });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected selectPort = (selectedPort: Port | undefined) => {
|
||||||
this.setState({ selectedPort }, () => this.fireConfigChanged());
|
this.setState({ selectedPort }, () => this.fireConfigChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,17 +164,20 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
return <div className='body'>
|
return <div className='body'>
|
||||||
{this.renderContainer('boards', this.renderBoards.bind(this))}
|
{this.renderContainer('boards', this.renderBoards.bind(this))}
|
||||||
{this.renderContainer('ports', this.renderPorts.bind(this))}
|
{this.renderContainer('ports', this.renderPorts.bind(this), this.renderPortsFooter.bind(this))}
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected renderContainer(title: string, contentRenderer: () => React.ReactNode): React.ReactNode {
|
protected renderContainer(title: string, contentRenderer: () => React.ReactNode, footerRenderer?: () => React.ReactNode): React.ReactNode {
|
||||||
return <div className='container'>
|
return <div className='container'>
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<div className='title'>
|
<div className='title'>
|
||||||
{title}
|
{title}
|
||||||
</div>
|
</div>
|
||||||
{contentRenderer()}
|
{contentRenderer()}
|
||||||
|
<div className='footer'>
|
||||||
|
{(footerRenderer ? footerRenderer() : '')}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
@ -214,7 +225,9 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected renderPorts(): React.ReactNode {
|
protected renderPorts(): React.ReactNode {
|
||||||
return !this.state.knownPorts.length ?
|
const filter = this.state.showAllPorts ? () => true : Port.isBoardPort;
|
||||||
|
const ports = this.state.knownPorts.filter(filter);
|
||||||
|
return !ports.length ?
|
||||||
(
|
(
|
||||||
<div className='loading noselect'>
|
<div className='loading noselect'>
|
||||||
No ports discovered
|
No ports discovered
|
||||||
@ -222,17 +235,31 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
) :
|
) :
|
||||||
(
|
(
|
||||||
<div className='ports list'>
|
<div className='ports list'>
|
||||||
{this.state.knownPorts.map(port => <Item<string>
|
{ports.map(port => <Item<Port>
|
||||||
key={port}
|
key={Port.toString(port)}
|
||||||
item={port}
|
item={port}
|
||||||
label={port}
|
label={Port.toString(port)}
|
||||||
selected={this.state.selectedPort === port}
|
selected={Port.equals(this.state.selectedPort, port)}
|
||||||
onClick={this.selectPort}
|
onClick={this.selectPort}
|
||||||
/>)}
|
/>)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected renderPortsFooter(): React.ReactNode {
|
||||||
|
return <div className='noselect'>
|
||||||
|
<label
|
||||||
|
title='Shows all available ports when enabled'>
|
||||||
|
<input
|
||||||
|
type='checkbox'
|
||||||
|
defaultChecked={this.state.showAllPorts}
|
||||||
|
onChange={this.toggleFilterPorts}
|
||||||
|
/>
|
||||||
|
<span>Show all ports</span>
|
||||||
|
</label>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace BoardsConfig {
|
export namespace BoardsConfig {
|
||||||
@ -244,7 +271,7 @@ export namespace BoardsConfig {
|
|||||||
if (AttachedSerialBoard.is(other)) {
|
if (AttachedSerialBoard.is(other)) {
|
||||||
return !!selectedBoard
|
return !!selectedBoard
|
||||||
&& Board.equals(other, selectedBoard)
|
&& Board.equals(other, selectedBoard)
|
||||||
&& selectedPort === other.port;
|
&& Port.sameAs(selectedPort, other.port);
|
||||||
}
|
}
|
||||||
return sameAs(config, other);
|
return sameAs(config, other);
|
||||||
}
|
}
|
||||||
@ -260,7 +287,7 @@ export namespace BoardsConfig {
|
|||||||
return options.default;
|
return options.default;
|
||||||
}
|
}
|
||||||
const { name } = selectedBoard;
|
const { name } = selectedBoard;
|
||||||
return `${name}${port ? ' at ' + port : ''}`;
|
return `${name}${port ? ' at ' + Port.toString(port) : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,8 @@ import { Emitter } from '@theia/core/lib/common/event';
|
|||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
import { LocalStorageService } from '@theia/core/lib/browser/storage-service';
|
import { LocalStorageService } from '@theia/core/lib/browser/storage-service';
|
||||||
import { RecursiveRequired } from '../../common/types';
|
import { RecursiveRequired } from '../../common/types';
|
||||||
import { BoardsServiceClient, AttachedBoardsChangeEvent, BoardInstalledEvent, AttachedSerialBoard, Board } from '../../common/protocol/boards-service';
|
import { BoardsServiceClient, AttachedBoardsChangeEvent, BoardInstalledEvent, AttachedSerialBoard, Board, Port } from '../../common/protocol/boards-service';
|
||||||
import { BoardsConfig } from './boards-config';
|
import { BoardsConfig } from './boards-config';
|
||||||
import { MaybePromise } from '@theia/core';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsServiceClientImpl implements BoardsServiceClient {
|
export class BoardsServiceClientImpl implements BoardsServiceClient {
|
||||||
@ -40,29 +39,27 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifyAttachedBoardsChanged(event: AttachedBoardsChangeEvent): void {
|
notifyAttachedBoardsChanged(event: AttachedBoardsChangeEvent): void {
|
||||||
this.logger.info('Attached boards changed: ', JSON.stringify(event));
|
this.logger.info('Attached boards and available ports changed: ', JSON.stringify(event));
|
||||||
const { detached, attached } = AttachedBoardsChangeEvent.diff(event);
|
const { detached, attached } = AttachedBoardsChangeEvent.diff(event);
|
||||||
const detachedBoards = detached.filter(AttachedSerialBoard.is).map(({ port }) => port);
|
|
||||||
const { selectedPort, selectedBoard } = this.boardsConfig;
|
const { selectedPort, selectedBoard } = this.boardsConfig;
|
||||||
this.onAttachedBoardsChangedEmitter.fire(event);
|
this.onAttachedBoardsChangedEmitter.fire(event);
|
||||||
// Dynamically unset the port if the selected board was an attached one and we detached it.
|
// Dynamically unset the port if is not available anymore. A port can be "detached" when removing a board.
|
||||||
if (!!selectedPort && detachedBoards.indexOf(selectedPort) !== -1) {
|
if (detached.ports.some(port => Port.equals(selectedPort, port))) {
|
||||||
this.boardsConfig = {
|
this.boardsConfig = {
|
||||||
selectedBoard,
|
selectedBoard,
|
||||||
selectedPort: undefined
|
selectedPort: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Try to reconnect.
|
// Try to reconnect.
|
||||||
this.tryReconnect(attached);
|
this.tryReconnect(attached.boards, attached.ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tryReconnect(attachedBoards: MaybePromise<Array<Board>>): Promise<boolean> {
|
async tryReconnect(attachedBoards: Board[], availablePorts: Port[]): Promise<boolean> {
|
||||||
const boards = await attachedBoards;
|
|
||||||
if (this.latestValidBoardsConfig && !this.canUploadTo(this.boardsConfig)) {
|
if (this.latestValidBoardsConfig && !this.canUploadTo(this.boardsConfig)) {
|
||||||
for (const board of boards.filter(AttachedSerialBoard.is)) {
|
for (const board of attachedBoards.filter(AttachedSerialBoard.is)) {
|
||||||
if (this.latestValidBoardsConfig.selectedBoard.fqbn === board.fqbn
|
if (this.latestValidBoardsConfig.selectedBoard.fqbn === board.fqbn
|
||||||
&& this.latestValidBoardsConfig.selectedBoard.name === board.name
|
&& this.latestValidBoardsConfig.selectedBoard.name === board.name
|
||||||
&& this.latestValidBoardsConfig.selectedPort === board.port) {
|
&& Port.sameAs(this.latestValidBoardsConfig.selectedPort, board.port)) {
|
||||||
|
|
||||||
this.boardsConfig = this.latestValidBoardsConfig;
|
this.boardsConfig = this.latestValidBoardsConfig;
|
||||||
return true;
|
return true;
|
||||||
@ -70,13 +67,13 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
|
|||||||
}
|
}
|
||||||
// If we could not find an exact match, we compare the board FQBN-name pairs and ignore the port, as it might have changed.
|
// If we could not find an exact match, we compare the board FQBN-name pairs and ignore the port, as it might have changed.
|
||||||
// See documentation on `latestValidBoardsConfig`.
|
// See documentation on `latestValidBoardsConfig`.
|
||||||
for (const board of boards.filter(AttachedSerialBoard.is)) {
|
for (const board of attachedBoards.filter(AttachedSerialBoard.is)) {
|
||||||
if (this.latestValidBoardsConfig.selectedBoard.fqbn === board.fqbn
|
if (this.latestValidBoardsConfig.selectedBoard.fqbn === board.fqbn
|
||||||
&& this.latestValidBoardsConfig.selectedBoard.name === board.name) {
|
&& this.latestValidBoardsConfig.selectedBoard.name === board.name) {
|
||||||
|
|
||||||
this.boardsConfig = {
|
this.boardsConfig = {
|
||||||
...this.latestValidBoardsConfig,
|
...this.latestValidBoardsConfig,
|
||||||
selectedPort: board.port
|
selectedPort: availablePorts.find(port => Port.sameAs(port, board.port))
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
import { CommandRegistry, DisposableCollection } from '@theia/core';
|
import { CommandRegistry, DisposableCollection } from '@theia/core';
|
||||||
import { BoardsService, Board, AttachedSerialBoard } from '../../common/protocol/boards-service';
|
import { BoardsService, Board, AttachedSerialBoard, Port } from '../../common/protocol/boards-service';
|
||||||
import { ArduinoCommands } from '../arduino-commands';
|
import { ArduinoCommands } from '../arduino-commands';
|
||||||
import { BoardsServiceClientImpl } from './boards-service-client-impl';
|
import { BoardsServiceClientImpl } from './boards-service-client-impl';
|
||||||
import { BoardsConfig } from './boards-config';
|
import { BoardsConfig } from './boards-config';
|
||||||
@ -88,6 +88,7 @@ export namespace BoardsToolBarItem {
|
|||||||
export interface State {
|
export interface State {
|
||||||
boardsConfig: BoardsConfig.Config;
|
boardsConfig: BoardsConfig.Config;
|
||||||
attachedBoards: Board[];
|
attachedBoards: Board[];
|
||||||
|
availablePorts: Port[];
|
||||||
coords: BoardsDropDownListCoords | 'hidden';
|
coords: BoardsDropDownListCoords | 'hidden';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +105,7 @@ export class BoardsToolBarItem extends React.Component<BoardsToolBarItem.Props,
|
|||||||
this.state = {
|
this.state = {
|
||||||
boardsConfig: this.props.boardsServiceClient.boardsConfig,
|
boardsConfig: this.props.boardsServiceClient.boardsConfig,
|
||||||
attachedBoards: [],
|
attachedBoards: [],
|
||||||
|
availablePorts: [],
|
||||||
coords: 'hidden'
|
coords: 'hidden'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,10 +118,13 @@ export class BoardsToolBarItem extends React.Component<BoardsToolBarItem.Props,
|
|||||||
const { boardsServiceClient: client, boardService } = this.props;
|
const { boardsServiceClient: client, boardService } = this.props;
|
||||||
this.toDispose.pushAll([
|
this.toDispose.pushAll([
|
||||||
client.onBoardsConfigChanged(boardsConfig => this.setState({ boardsConfig })),
|
client.onBoardsConfigChanged(boardsConfig => this.setState({ boardsConfig })),
|
||||||
client.onBoardsChanged(({ newState }) => this.setState({ attachedBoards: newState.boards }))
|
client.onBoardsChanged(({ newState }) => this.setState({ attachedBoards: newState.boards, availablePorts: newState.ports }))
|
||||||
]);
|
]);
|
||||||
boardService.getAttachedBoards().then(({ boards: attachedBoards }) => {
|
Promise.all([
|
||||||
this.setState({ attachedBoards })
|
boardService.getAttachedBoards(),
|
||||||
|
boardService.getAvailablePorts()
|
||||||
|
]).then(([{boards: attachedBoards}, { ports: availablePorts }]) => {
|
||||||
|
this.setState({ attachedBoards, availablePorts })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,29 +154,32 @@ export class BoardsToolBarItem extends React.Component<BoardsToolBarItem.Props,
|
|||||||
};
|
};
|
||||||
|
|
||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
const { boardsConfig, coords, attachedBoards } = this.state;
|
const { boardsConfig, coords, attachedBoards, availablePorts } = this.state;
|
||||||
const boardsConfigText = BoardsConfig.Config.toString(boardsConfig, { default: 'no board selected' });
|
const title = BoardsConfig.Config.toString(boardsConfig, { default: 'no board selected' });
|
||||||
const configuredBoard = attachedBoards
|
const configuredBoard = attachedBoards
|
||||||
.filter(AttachedSerialBoard.is)
|
.filter(AttachedSerialBoard.is)
|
||||||
|
.filter(board => availablePorts.some(port => Port.sameAs(port, board.port)))
|
||||||
.filter(board => BoardsConfig.Config.sameAs(boardsConfig, board)).shift();
|
.filter(board => BoardsConfig.Config.sameAs(boardsConfig, board)).shift();
|
||||||
|
|
||||||
const items = attachedBoards.filter(AttachedSerialBoard.is).map(board => ({
|
const items = attachedBoards.filter(AttachedSerialBoard.is).map(board => ({
|
||||||
label: `${board.name} at ${board.port}`,
|
label: `${board.name} at ${board.port}`,
|
||||||
selected: configuredBoard === board,
|
selected: configuredBoard === board,
|
||||||
onClick: () => this.props.boardsServiceClient.boardsConfig = {
|
onClick: () => {
|
||||||
|
this.props.boardsServiceClient.boardsConfig = {
|
||||||
selectedBoard: board,
|
selectedBoard: board,
|
||||||
selectedPort: board.port
|
selectedPort: availablePorts.find(port => Port.sameAs(port, board.port))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return <React.Fragment>
|
return <React.Fragment>
|
||||||
<div className='arduino-boards-toolbar-item-container'>
|
<div className='arduino-boards-toolbar-item-container'>
|
||||||
<div className='arduino-boards-toolbar-item' title={boardsConfigText}>
|
<div className='arduino-boards-toolbar-item' title={title}>
|
||||||
<div className='inner-container' onClick={this.show}>
|
<div className='inner-container' onClick={this.show}>
|
||||||
<span className={!configuredBoard ? 'fa fa-times notAttached' : ''}/>
|
<span className={!configuredBoard ? 'fa fa-times notAttached' : ''}/>
|
||||||
<div className='label noWrapInfo'>
|
<div className='label noWrapInfo'>
|
||||||
<div className='noWrapInfo noselect'>
|
<div className='noWrapInfo noselect'>
|
||||||
{boardsConfigText}
|
{title}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span className='fa fa-caret-down caret'/>
|
<span className='fa fa-caret-down caret'/>
|
||||||
|
@ -268,7 +268,7 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
|||||||
return {
|
return {
|
||||||
baudRate,
|
baudRate,
|
||||||
board: selectedBoard,
|
board: selectedBoard,
|
||||||
port: selectedPort
|
port: selectedPort.address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,11 +73,18 @@ div#select-board-dialog .selectBoardContainer .body .list .item.selected i{
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#select-board-dialog .selectBoardContainer .body .container .content .footer {
|
||||||
|
padding: 10px 5px 10px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
#select-board-dialog .selectBoardContainer .body .container .content .loading {
|
#select-board-dialog .selectBoardContainer .body .container .content .loading {
|
||||||
font-size: var(--theia-ui-font-size1);
|
font-size: var(--theia-ui-font-size1);
|
||||||
color: #7f8c8d;
|
color: #7f8c8d;
|
||||||
padding: 10px 5px 10px 10px;
|
padding: 10px 5px 10px 10px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
/* The max, min-height comes from `.body .list` 265px + 47px top padding - 2 * 10px top padding */
|
||||||
|
max-height: 292px;
|
||||||
|
min-height: 292px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#select-board-dialog .selectBoardContainer .body .list .item {
|
#select-board-dialog .selectBoardContainer .body .list .item {
|
||||||
|
@ -1,23 +1,42 @@
|
|||||||
import { JsonRpcServer } from '@theia/core';
|
import { isWindows, isOSX } from '@theia/core/lib/common/os';
|
||||||
|
import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
|
||||||
import { Searchable } from './searchable';
|
import { Searchable } from './searchable';
|
||||||
import { Installable } from './installable';
|
import { Installable } from './installable';
|
||||||
import { ArduinoComponent } from './arduino-component';
|
import { ArduinoComponent } from './arduino-component';
|
||||||
|
const naturalCompare: (left: string, right: string) => number = require('string-natural-compare').caseInsensitive;
|
||||||
|
|
||||||
export interface AttachedBoardsChangeEvent {
|
export interface AttachedBoardsChangeEvent {
|
||||||
readonly oldState: Readonly<{ boards: Board[] }>;
|
readonly oldState: Readonly<{ boards: Board[], ports: Port[] }>;
|
||||||
readonly newState: Readonly<{ boards: Board[] }>;
|
readonly newState: Readonly<{ boards: Board[], ports: Port[] }>;
|
||||||
}
|
}
|
||||||
export namespace AttachedBoardsChangeEvent {
|
export namespace AttachedBoardsChangeEvent {
|
||||||
|
|
||||||
export function diff(event: AttachedBoardsChangeEvent): Readonly<{ attached: Board[], detached: Board[] }> {
|
export function diff(event: AttachedBoardsChangeEvent): Readonly<{
|
||||||
|
attached: {
|
||||||
|
boards: Board[],
|
||||||
|
ports: Port[]
|
||||||
|
},
|
||||||
|
detached: {
|
||||||
|
boards: Board[],
|
||||||
|
ports: Port[]
|
||||||
|
}
|
||||||
|
}> {
|
||||||
const diff = <T>(left: T[], right: T[]) => {
|
const diff = <T>(left: T[], right: T[]) => {
|
||||||
return left.filter(item => right.indexOf(item) === -1);
|
return left.filter(item => right.indexOf(item) === -1);
|
||||||
}
|
}
|
||||||
const { boards: newBoards } = event.newState;
|
const { boards: newBoards } = event.newState;
|
||||||
const { boards: oldBoards } = event.oldState;
|
const { boards: oldBoards } = event.oldState;
|
||||||
|
const { ports: newPorts } = event.newState;
|
||||||
|
const { ports: oldPorts } = event.oldState;
|
||||||
return {
|
return {
|
||||||
detached: diff(oldBoards, newBoards),
|
detached: {
|
||||||
attached: diff(newBoards, oldBoards)
|
boards: diff(oldBoards, newBoards),
|
||||||
|
ports: diff(oldPorts, newPorts)
|
||||||
|
},
|
||||||
|
attached: {
|
||||||
|
boards: diff(newBoards, oldBoards),
|
||||||
|
ports: diff(newPorts, oldPorts)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +56,114 @@ export const BoardsServicePath = '/services/boards-service';
|
|||||||
export const BoardsService = Symbol('BoardsService');
|
export const BoardsService = Symbol('BoardsService');
|
||||||
export interface BoardsService extends Installable<BoardPackage>, Searchable<BoardPackage>, JsonRpcServer<BoardsServiceClient> {
|
export interface BoardsService extends Installable<BoardPackage>, Searchable<BoardPackage>, JsonRpcServer<BoardsServiceClient> {
|
||||||
getAttachedBoards(): Promise<{ boards: Board[] }>;
|
getAttachedBoards(): Promise<{ boards: Board[] }>;
|
||||||
|
getAvailablePorts(): Promise<{ ports: Port[] }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Port {
|
||||||
|
readonly address: string;
|
||||||
|
readonly protocol: Port.Protocol;
|
||||||
|
/**
|
||||||
|
* Optional label for the protocol. For example: `Serial Port (USB)`.
|
||||||
|
*/
|
||||||
|
readonly label?: string;
|
||||||
|
}
|
||||||
|
export namespace Port {
|
||||||
|
|
||||||
|
export type Protocol = 'serial' | 'network' | 'unknown';
|
||||||
|
export namespace Protocol {
|
||||||
|
export function toProtocol(protocol: string | undefined): Protocol {
|
||||||
|
if (protocol === 'serial') {
|
||||||
|
return 'serial';
|
||||||
|
} else if (protocol === 'network') {
|
||||||
|
return 'network';
|
||||||
|
} else {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toString(port: Port, options: { useLabel: boolean } = { useLabel: false }): string {
|
||||||
|
if (options.useLabel && port.label) {
|
||||||
|
return `${port.address} ${port.label}`
|
||||||
|
}
|
||||||
|
return port.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function compare(left: Port, right: Port): number {
|
||||||
|
// Board ports have higher priorities, they come first.
|
||||||
|
if (isBoardPort(left) && !isBoardPort(right)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!isBoardPort(left) && isBoardPort(right)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
let result = left.protocol.toLocaleLowerCase().localeCompare(right.protocol.toLocaleLowerCase());
|
||||||
|
if (result !== 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = naturalCompare(left.address, right.address);
|
||||||
|
if (result !== 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return (left.label || '').localeCompare(right.label || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function equals(left: Port | undefined, right: Port | undefined): boolean {
|
||||||
|
if (left && right) {
|
||||||
|
return left.address === right.address
|
||||||
|
&& left.protocol === right.protocol
|
||||||
|
&& (left.label || '') === (right.label || '');
|
||||||
|
}
|
||||||
|
return left === right;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Based on: https://github.com/arduino/Arduino/blob/93581b03d723e55c60caedb4729ffc6ea808fe78/arduino-core/src/processing/app/SerialPortList.java#L48-L74
|
||||||
|
export function isBoardPort(port: Port): boolean {
|
||||||
|
const address = port.address.toLocaleLowerCase();
|
||||||
|
if (isWindows) {
|
||||||
|
// `COM1` seems to be the default serial port on Windows.
|
||||||
|
return address !== 'COM1'.toLocaleLowerCase();
|
||||||
|
}
|
||||||
|
// On macOS and Linux, the port should start with `/dev/`.
|
||||||
|
if (!address.startsWith('/dev/')) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (isOSX) {
|
||||||
|
// Example: `/dev/cu.usbmodem14401`
|
||||||
|
if (/(tty|cu)\..*/.test(address.substring('/dev/'.length))) {
|
||||||
|
return [
|
||||||
|
'/dev/cu.MALS',
|
||||||
|
'/dev/cu.SOC',
|
||||||
|
'/dev/cu.Bluetooth-Incoming-Port'
|
||||||
|
].map(a => a.toLocaleLowerCase()).every(a => a !== address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example: `/dev/ttyACM0`
|
||||||
|
if (/(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm|ttyO)[0-9]{1,3}/.test(address.substring('/dev/'.length))) {
|
||||||
|
// Default ports were `/dev/ttyS0` -> `/dev/ttyS31` on Ubuntu 16.04.2.
|
||||||
|
if (address.startsWith('/dev/ttyS')) {
|
||||||
|
const index = Number.parseInt(address.substring('/dev/ttyS'.length), 10);
|
||||||
|
if (!Number.isNaN(index) && 0 <= index && 31 >= index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sameAs(left: Port | undefined, right: string | undefined) {
|
||||||
|
if (left && right) {
|
||||||
|
if (left.protocol !== 'serial') {
|
||||||
|
console.log(`Unexpected protocol for port: ${JSON.stringify(left)}. Ignoring protocol, comparing addresses with ${right}.`);
|
||||||
|
}
|
||||||
|
return left.address === right;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BoardPackage extends ArduinoComponent {
|
export interface BoardPackage extends ArduinoComponent {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as PQueue from 'p-queue';
|
import * as PQueue from 'p-queue';
|
||||||
import { injectable, inject, postConstruct, named } from 'inversify';
|
import { injectable, inject, postConstruct, named } from 'inversify';
|
||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient } from '../common/protocol/boards-service';
|
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service';
|
||||||
import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInstallResp, PlatformListReq, PlatformListResp } from './cli-protocol/commands/core_pb';
|
import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInstallResp, PlatformListReq, PlatformListResp } from './cli-protocol/commands/core_pb';
|
||||||
import { CoreClientProvider } from './core-client-provider';
|
import { CoreClientProvider } from './core-client-provider';
|
||||||
import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb';
|
import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb';
|
||||||
@ -20,7 +20,6 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
@inject(ToolOutputServiceServer)
|
@inject(ToolOutputServiceServer)
|
||||||
protected readonly toolOutputService: ToolOutputServiceServer;
|
protected readonly toolOutputService: ToolOutputServiceServer;
|
||||||
|
|
||||||
protected selectedBoard: Board | undefined;
|
|
||||||
protected discoveryInitialized = false;
|
protected discoveryInitialized = false;
|
||||||
protected discoveryTimer: NodeJS.Timeout | undefined;
|
protected discoveryTimer: NodeJS.Timeout | undefined;
|
||||||
/**
|
/**
|
||||||
@ -29,44 +28,58 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
* This state is updated via periodical polls.
|
* This state is updated via periodical polls.
|
||||||
*/
|
*/
|
||||||
protected _attachedBoards: { boards: Board[] } = { boards: [] };
|
protected _attachedBoards: { boards: Board[] } = { boards: [] };
|
||||||
|
protected _availablePorts: { ports: Port[] } = { ports: [] };
|
||||||
protected client: BoardsServiceClient | undefined;
|
protected client: BoardsServiceClient | undefined;
|
||||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected async init(): Promise<void> {
|
protected async init(): Promise<void> {
|
||||||
this.discoveryTimer = setInterval(() => {
|
this.discoveryTimer = setInterval(() => {
|
||||||
this.discoveryLogger.trace('Discovering attached boards...');
|
this.discoveryLogger.trace('Discovering attached boards and available ports...');
|
||||||
this.doGetAttachedBoards().then(({ boards }) => {
|
this.doGetAttachedBoardsAndAvailablePorts().then(({ boards, ports }) => {
|
||||||
const update = (oldState: Board[], newState: Board[], message: string) => {
|
const update = (oldBoards: Board[], newBoards: Board[], oldPorts: Port[], newPorts: Port[], message: string) => {
|
||||||
this._attachedBoards = { boards: newState };
|
this._attachedBoards = { boards: newBoards };
|
||||||
this.discoveryLogger.info(`${message} - Discovered boards: ${JSON.stringify(newState)}`);
|
this._availablePorts = { ports: newPorts };
|
||||||
|
this.discoveryLogger.info(`${message} - Discovered boards: ${JSON.stringify(newBoards)} and available ports: ${JSON.stringify(newPorts)}`);
|
||||||
if (this.client) {
|
if (this.client) {
|
||||||
this.client.notifyAttachedBoardsChanged({
|
this.client.notifyAttachedBoardsChanged({
|
||||||
oldState: {
|
oldState: {
|
||||||
boards: oldState
|
boards: oldBoards,
|
||||||
|
ports: oldPorts
|
||||||
},
|
},
|
||||||
newState: {
|
newState: {
|
||||||
boards: newState
|
boards: newBoards,
|
||||||
|
ports: newPorts
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const sortedBoards = boards.sort(Board.compare);
|
const sortedBoards = boards.sort(Board.compare);
|
||||||
this.discoveryLogger.trace(`Discovery done. ${JSON.stringify(sortedBoards)}`);
|
const sortedPorts = ports.sort(Port.compare);
|
||||||
|
this.discoveryLogger.trace(`Discovery done. Boards: ${JSON.stringify(sortedBoards)}. Ports: ${sortedPorts}`);
|
||||||
if (!this.discoveryInitialized) {
|
if (!this.discoveryInitialized) {
|
||||||
update([], sortedBoards, 'Initialized attached boards.');
|
update([], sortedBoards, [], sortedPorts, 'Initialized attached boards and available ports.');
|
||||||
this.discoveryInitialized = true;
|
this.discoveryInitialized = true;
|
||||||
} else {
|
} else {
|
||||||
this.getAttachedBoards().then(({ boards: currentBoards }) => {
|
Promise.all([
|
||||||
|
this.getAttachedBoards(),
|
||||||
|
this.getAvailablePorts()
|
||||||
|
]).then(([{ boards: currentBoards }, { ports: currentPorts }]) => {
|
||||||
this.discoveryLogger.trace(`Updating discovered boards... ${JSON.stringify(currentBoards)}`);
|
this.discoveryLogger.trace(`Updating discovered boards... ${JSON.stringify(currentBoards)}`);
|
||||||
if (currentBoards.length !== sortedBoards.length) {
|
if (currentBoards.length !== sortedBoards.length || currentPorts.length !== sortedPorts.length) {
|
||||||
update(currentBoards, sortedBoards, 'Updated discovered boards.');
|
update(currentBoards, sortedBoards, currentPorts, sortedPorts, 'Updated discovered boards and available ports.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// `currentBoards` is already sorted.
|
// `currentBoards` is already sorted.
|
||||||
for (let i = 0; i < sortedBoards.length; i++) {
|
for (let i = 0; i < sortedBoards.length; i++) {
|
||||||
if (Board.compare(sortedBoards[i], currentBoards[i]) !== 0) {
|
if (Board.compare(sortedBoards[i], currentBoards[i]) !== 0) {
|
||||||
update(currentBoards, sortedBoards, 'Updated discovered boards.');
|
update(currentBoards, sortedBoards, currentPorts, sortedPorts, 'Updated discovered boards.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < sortedPorts.length; i++) {
|
||||||
|
if (Port.compare(sortedPorts[i], currentPorts[i]) !== 0) {
|
||||||
|
update(currentBoards, sortedBoards, currentPorts, sortedPorts, 'Updated discovered boards.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,13 +104,18 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
return this._attachedBoards;
|
return this._attachedBoards;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async doGetAttachedBoards(): Promise<{ boards: Board[] }> {
|
async getAvailablePorts(): Promise<{ ports: Port[] }> {
|
||||||
|
return this._availablePorts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async doGetAttachedBoardsAndAvailablePorts(): Promise<{ boards: Board[], ports: Port[] }> {
|
||||||
return this.queue.add(() => {
|
return this.queue.add(() => {
|
||||||
return new Promise<{ boards: Board[] }>(async resolve => {
|
return new Promise<{ boards: Board[], ports: Port[] }>(async resolve => {
|
||||||
const coreClient = await this.coreClientProvider.getClient();
|
const coreClient = await this.coreClientProvider.getClient();
|
||||||
const boards: Board[] = [];
|
const boards: Board[] = [];
|
||||||
|
const ports: Port[] = [];
|
||||||
if (!coreClient) {
|
if (!coreClient) {
|
||||||
resolve({ boards });
|
resolve({ boards, ports });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +123,43 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
const req = new BoardListReq();
|
const req = new BoardListReq();
|
||||||
req.setInstance(instance);
|
req.setInstance(instance);
|
||||||
const resp = await new Promise<BoardListResp>((resolve, reject) => client.boardList(req, (err, resp) => (!!err ? reject : resolve)(!!err ? err : resp)));
|
const resp = await new Promise<BoardListResp>((resolve, reject) => client.boardList(req, (err, resp) => (!!err ? reject : resolve)(!!err ? err : resp)));
|
||||||
for (const portsList of resp.getPortsList()) {
|
const portsList = resp.getPortsList();
|
||||||
const protocol = portsList.getProtocol();
|
// TODO: remove unknown board mocking!
|
||||||
const address = portsList.getAddress();
|
// You also have to manually import `DetectedPort`.
|
||||||
for (const board of portsList.getBoardsList()) {
|
// const unknownPortList = new DetectedPort();
|
||||||
|
// unknownPortList.setAddress(platform() === 'win32' ? 'COM3' : platform() === 'darwin' ? '/dev/cu.usbmodem94401' : '/dev/ttyACM0');
|
||||||
|
// unknownPortList.setProtocol('serial');
|
||||||
|
// unknownPortList.setProtocolLabel('Serial Port (USB)');
|
||||||
|
// portsList.push(unknownPortList);
|
||||||
|
|
||||||
|
for (const portList of portsList) {
|
||||||
|
const protocol = Port.Protocol.toProtocol(portList.getProtocol());
|
||||||
|
const address = portList.getAddress();
|
||||||
|
// Available ports can exist with unknown attached boards.
|
||||||
|
// The `BoardListResp` looks like this for a known attached board:
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// "address": "COM10",
|
||||||
|
// "protocol": "serial",
|
||||||
|
// "protocol_label": "Serial Port (USB)",
|
||||||
|
// "boards": [
|
||||||
|
// {
|
||||||
|
// "name": "Arduino MKR1000",
|
||||||
|
// "FQBN": "arduino:samd:mkr1000"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// And the `BoardListResp` looks like this for an unknown board:
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// "address": "COM9",
|
||||||
|
// "protocol": "serial",
|
||||||
|
// "protocol_label": "Serial Port (USB)",
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
ports.push({ protocol, address });
|
||||||
|
for (const board of portList.getBoardsList()) {
|
||||||
const name = board.getName() || 'unknown';
|
const name = board.getName() || 'unknown';
|
||||||
const fqbn = board.getFqbn();
|
const fqbn = board.getFqbn();
|
||||||
const port = address;
|
const port = address;
|
||||||
@ -118,13 +169,15 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
fqbn,
|
fqbn,
|
||||||
port
|
port
|
||||||
});
|
});
|
||||||
} else { // We assume, it is a `network` board.
|
} else if (protocol === 'network') { // We assume, it is a `network` board.
|
||||||
boards.push(<AttachedNetworkBoard>{
|
boards.push(<AttachedNetworkBoard>{
|
||||||
name,
|
name,
|
||||||
fqbn,
|
fqbn,
|
||||||
address,
|
address,
|
||||||
port
|
port
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown protocol for port: ${address}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,11 +186,13 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
// <AttachedSerialBoard>{ name: 'Arduino/Genuino Uno', fqbn: 'arduino:avr:uno', port: '/dev/cu.usbmodem14201' },
|
// <AttachedSerialBoard>{ name: 'Arduino/Genuino Uno', fqbn: 'arduino:avr:uno', port: '/dev/cu.usbmodem14201' },
|
||||||
// <AttachedSerialBoard>{ name: 'Arduino/Genuino Uno', fqbn: 'arduino:avr:uno', port: '/dev/cu.usbmodem142xx' },
|
// <AttachedSerialBoard>{ name: 'Arduino/Genuino Uno', fqbn: 'arduino:avr:uno', port: '/dev/cu.usbmodem142xx' },
|
||||||
// ]);
|
// ]);
|
||||||
resolve({ boards });
|
resolve({ boards, ports });
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async search(options: { query?: string }): Promise<{ items: BoardPackage[] }> {
|
async search(options: { query?: string }): Promise<{ items: BoardPackage[] }> {
|
||||||
const coreClient = await this.coreClientProvider.getClient();
|
const coreClient = await this.coreClientProvider.getClient();
|
||||||
if (!coreClient) {
|
if (!coreClient) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "theia build --mode development",
|
"prepare": "theia build --mode development",
|
||||||
"start": "theia start --root-dir=../workspace",
|
"start": "theia start",
|
||||||
"watch": "theia build --watch --mode development"
|
"watch": "theia build --watch --mode development"
|
||||||
},
|
},
|
||||||
"theia": {
|
"theia": {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "theia build --mode development",
|
"prepare": "theia build --mode development",
|
||||||
"start": "theia start --root-dir=../workspace",
|
"start": "theia start",
|
||||||
"watch": "theia build --watch --mode development"
|
"watch": "theia build --watch --mode development"
|
||||||
},
|
},
|
||||||
"theia": {
|
"theia": {
|
||||||
|
@ -11924,6 +11924,11 @@ string-argv@^0.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.1.2.tgz#c5b7bc03fb2b11983ba3a72333dd0559e77e4738"
|
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.1.2.tgz#c5b7bc03fb2b11983ba3a72333dd0559e77e4738"
|
||||||
integrity sha512-mBqPGEOMNJKXRo7z0keX0wlAhbBAjilUdPW13nN0PecVryZxdHIeM7TqbsSUA7VYuS00HGC6mojP7DlQzfa9ZA==
|
integrity sha512-mBqPGEOMNJKXRo7z0keX0wlAhbBAjilUdPW13nN0PecVryZxdHIeM7TqbsSUA7VYuS00HGC6mojP7DlQzfa9ZA==
|
||||||
|
|
||||||
|
string-natural-compare@^2.0.3:
|
||||||
|
version "2.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-2.0.3.tgz#9dbe1dd65490a5fe14f7a5c9bc686fc67cb9c6e4"
|
||||||
|
integrity sha512-4Kcl12rNjc+6EKhY8QyDVuQTAlMWwRiNbsxnVwBUKFr7dYPQuXVrtNU4sEkjF9LHY0AY6uVbB3ktbkIH4LC+BQ==
|
||||||
|
|
||||||
string-template@~0.2.1:
|
string-template@~0.2.1:
|
||||||
version "0.2.1"
|
version "0.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"
|
resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user