@@ -9,10 +9,7 @@ import { BoardsConfig } from '../boards/boards-config';
99import { MainMenuManager } from '../../common/main-menu-manager' ;
1010import { BoardsListWidget } from '../boards/boards-list-widget' ;
1111import { NotificationCenter } from '../notification-center' ;
12- import {
13- AvailableBoard ,
14- BoardsServiceProvider ,
15- } from '../boards/boards-service-provider' ;
12+ import { BoardsServiceProvider } from '../boards/boards-service-provider' ;
1613import {
1714 ArduinoMenus ,
1815 PlaceholderMenuNode ,
@@ -23,6 +20,7 @@ import {
2320 InstalledBoardWithPackage ,
2421 AvailablePorts ,
2522 Port ,
23+ Board ,
2624} from '../../common/protocol' ;
2725import { SketchContribution , Command , CommandRegistry } from './contribution' ;
2826import { nls } from '@theia/core/lib/common' ;
@@ -84,7 +82,6 @@ export class BoardSelection extends SketchContribution {
8482 }
8583 // IDE2 must show the board info based on the selected port.
8684 // https://github.com/arduino/arduino-ide/issues/1489
87-
8885 // IDE 1.x does not support network ports
8986 if ( selectedPort . protocol === 'network' ) {
9087 this . messageService . info (
@@ -95,21 +92,19 @@ export class BoardSelection extends SketchContribution {
9592 ) ;
9693 return ;
9794 }
95+ // serial protocol with one or many detected boards or available VID+PID properties from the port
96+ const isNonNativeSerial = ( port : Port , boards : Board [ ] ) => {
97+ return (
98+ port . protocol === 'serial' &&
99+ ( boards . length ||
100+ ( port . properties ?. [ 'vid' ] && port . properties ?. [ 'pid' ] ) )
101+ ) ;
102+ } ;
98103 const selectedPortKey = Port . keyOf ( selectedPort ) ;
99- console . log ( 'selectedportkey' , JSON . stringify ( selectedPortKey ) ) ;
100- console . log (
101- 'availableboards' ,
102- JSON . stringify (
103- this . boardsServiceProvider . availableBoards . filter (
104- AvailableBoard . hasPort
105- )
106- )
107- ) ;
108-
109104 const state = await this . boardsService . getState ( ) ;
110105 const boardListOnSelectedPort = Object . entries ( state ) . filter (
111- ( [ portKey , [ , boards ] ] ) =>
112- portKey === selectedPortKey && boards . length
106+ ( [ portKey , [ port , boards ] ] ) =>
107+ portKey === selectedPortKey && isNonNativeSerial ( port , boards )
113108 ) ;
114109 // IDE 1.x show this when cannot identify for example a ESP8266MOD although compile and upload works
115110 if ( ! boardListOnSelectedPort . length ) {
@@ -123,7 +118,6 @@ export class BoardSelection extends SketchContribution {
123118 }
124119
125120 const [ , [ port , boards ] ] = boardListOnSelectedPort [ 0 ] ;
126- boardListOnSelectedPort . length && boardListOnSelectedPort [ 0 ] ;
127121 if ( boardListOnSelectedPort . length > 1 || boards . length > 1 ) {
128122 console . warn (
129123 `Detected more than one available boards on the selected port : ${ JSON . stringify (
@@ -139,10 +133,17 @@ export class BoardSelection extends SketchContribution {
139133 ! ! s ? s : '(null)' ;
140134 const readProperty = ( property : string , port : Port ) =>
141135 falsyToNullString ( port . properties ?. [ property ] ) ;
142- const BN = board . name ;
136+ const BN =
137+ board ?. name ??
138+ nls . localize ( 'arduino/board/unknownBoard' , 'Unknown board' ) ;
143139 const VID = readProperty ( 'vid' , port ) ;
144140 const PID = readProperty ( 'pid' , port ) ;
145- const SN = readProperty ( 'serialNumber' , port ) ;
141+ const SN = board
142+ ? readProperty ( 'serialNumber' , port )
143+ : nls . localize (
144+ 'arduino/board/unknownBoardSerialNumber' ,
145+ 'Upload any sketch to obtain it.'
146+ ) ;
146147 const detail = `
147148BN: ${ BN }
148149VID: ${ VID }
0 commit comments