@@ -9,10 +9,7 @@ import { BoardsConfig } from '../boards/boards-config';
9
9
import { MainMenuManager } from '../../common/main-menu-manager' ;
10
10
import { BoardsListWidget } from '../boards/boards-list-widget' ;
11
11
import { NotificationCenter } from '../notification-center' ;
12
- import {
13
- AvailableBoard ,
14
- BoardsServiceProvider ,
15
- } from '../boards/boards-service-provider' ;
12
+ import { BoardsServiceProvider } from '../boards/boards-service-provider' ;
16
13
import {
17
14
ArduinoMenus ,
18
15
PlaceholderMenuNode ,
@@ -23,6 +20,7 @@ import {
23
20
InstalledBoardWithPackage ,
24
21
AvailablePorts ,
25
22
Port ,
23
+ Board ,
26
24
} from '../../common/protocol' ;
27
25
import { SketchContribution , Command , CommandRegistry } from './contribution' ;
28
26
import { nls } from '@theia/core/lib/common' ;
@@ -84,7 +82,6 @@ export class BoardSelection extends SketchContribution {
84
82
}
85
83
// IDE2 must show the board info based on the selected port.
86
84
// https://github.com/arduino/arduino-ide/issues/1489
87
-
88
85
// IDE 1.x does not support network ports
89
86
if ( selectedPort . protocol === 'network' ) {
90
87
this . messageService . info (
@@ -95,21 +92,19 @@ export class BoardSelection extends SketchContribution {
95
92
) ;
96
93
return ;
97
94
}
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
+ } ;
98
103
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
-
109
104
const state = await this . boardsService . getState ( ) ;
110
105
const boardListOnSelectedPort = Object . entries ( state ) . filter (
111
- ( [ portKey , [ , boards ] ] ) =>
112
- portKey === selectedPortKey && boards . length
106
+ ( [ portKey , [ port , boards ] ] ) =>
107
+ portKey === selectedPortKey && isNonNativeSerial ( port , boards )
113
108
) ;
114
109
// IDE 1.x show this when cannot identify for example a ESP8266MOD although compile and upload works
115
110
if ( ! boardListOnSelectedPort . length ) {
@@ -123,7 +118,6 @@ export class BoardSelection extends SketchContribution {
123
118
}
124
119
125
120
const [ , [ port , boards ] ] = boardListOnSelectedPort [ 0 ] ;
126
- boardListOnSelectedPort . length && boardListOnSelectedPort [ 0 ] ;
127
121
if ( boardListOnSelectedPort . length > 1 || boards . length > 1 ) {
128
122
console . warn (
129
123
`Detected more than one available boards on the selected port : ${ JSON . stringify (
@@ -139,10 +133,17 @@ export class BoardSelection extends SketchContribution {
139
133
! ! s ? s : '(null)' ;
140
134
const readProperty = ( property : string , port : Port ) =>
141
135
falsyToNullString ( port . properties ?. [ property ] ) ;
142
- const BN = board . name ;
136
+ const BN =
137
+ board ?. name ??
138
+ nls . localize ( 'arduino/board/unknownBoard' , 'Unknown board' ) ;
143
139
const VID = readProperty ( 'vid' , port ) ;
144
140
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
+ ) ;
146
147
const detail = `
147
148
BN: ${ BN }
148
149
VID: ${ VID }
0 commit comments