File tree 3 files changed +14
-6
lines changed
arduino-ide-extension/src
3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -98,20 +98,27 @@ export class UploadSketch extends SketchContribution {
98
98
let options : CoreService . Upload . Options | undefined = undefined ;
99
99
const sketchUri = uri ;
100
100
const optimizeForDebug = this . editorMode . compileForDebug ;
101
+ const { selectedPort } = boardsConfig ;
101
102
102
103
if ( usingProgrammer ) {
103
104
const programmer = selectedProgrammer ;
104
105
if ( ! programmer ) {
105
106
throw new Error ( 'Programmer is not selected. Please select a programmer.' ) ;
106
107
}
108
+ let port : undefined | string = undefined ;
109
+ // If the port is set by the user, we pass it to the CLI as it might be required.
110
+ // If it is not set but the CLI requires it, we let the CLI to complain.
111
+ if ( selectedPort ) {
112
+ port = selectedPort . address ;
113
+ }
107
114
options = {
108
115
sketchUri,
109
116
fqbn,
110
117
optimizeForDebug,
111
- programmer
118
+ programmer,
119
+ port
112
120
} ;
113
121
} else {
114
- const { selectedPort } = boardsConfig ;
115
122
if ( ! selectedPort ) {
116
123
throw new Error ( 'No ports selected. Please select a port.' ) ;
117
124
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export namespace CoreService {
26
26
export namespace Upload {
27
27
export type Options =
28
28
Compile . Options & Readonly < { port : string } > |
29
- Compile . Options & Readonly < { programmer : Programmer } > ;
29
+ Compile . Options & Readonly < { programmer : Programmer , port ?: string } > ;
30
30
}
31
31
32
32
}
Original file line number Diff line number Diff line change @@ -103,11 +103,12 @@ export class CoreServiceImpl implements CoreService {
103
103
uploadReq . setInstance ( instance ) ;
104
104
uploadReq . setSketchPath ( sketchpath ) ;
105
105
uploadReq . setFqbn ( fqbn ) ;
106
- if ( 'port' in options ) {
107
- uploadReq . setPort ( options . port ) ;
108
- } else {
106
+ if ( 'programmer' in options ) {
109
107
uploadReq . setProgrammer ( options . programmer . id ) ;
110
108
}
109
+ if ( options . port ) {
110
+ uploadReq . setPort ( options . port ) ;
111
+ }
111
112
const result = client . upload ( uploadReq ) ;
112
113
113
114
try {
You can’t perform that action at this time.
0 commit comments