Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f325e0

Browse filesBrowse files
feat: upload using programmer by default if board requires it
1 parent beabb80 commit 3f325e0
Copy full SHA for 3f325e0

File tree

3 files changed

+48
-3
lines changed
Filter options

3 files changed

+48
-3
lines changed

‎arduino-ide-extension/src/browser/contributions/upload-sketch.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/upload-sketch.ts
+29-2Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class UploadSketch extends CoreServiceContribution {
127127
usingProgrammer,
128128
verifyOptions
129129
);
130+
130131
if (!uploadOptions) {
131132
return;
132133
}
@@ -137,11 +138,37 @@ export class UploadSketch extends CoreServiceContribution {
137138

138139
const uploadResponse = await this.doWithProgress({
139140
progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'),
140-
task: (progressId, coreService, token) =>
141-
coreService.upload({ ...uploadOptions, progressId }, token),
141+
task: async (progressId, coreService, token) => {
142+
try {
143+
return await coreService.upload(
144+
{ ...uploadOptions, progressId },
145+
token
146+
);
147+
} catch (err) {
148+
if (err.code === 4005) {
149+
const uploadWithProgrammerOptions = await this.uploadOptions(
150+
true,
151+
verifyOptions
152+
);
153+
if (uploadWithProgrammerOptions) {
154+
return coreService.upload(
155+
{ ...uploadWithProgrammerOptions, progressId },
156+
token
157+
);
158+
}
159+
} else {
160+
throw err;
161+
}
162+
}
163+
},
142164
keepOutput: true,
143165
cancelable: true,
144166
});
167+
168+
if (!uploadResponse) {
169+
return;
170+
}
171+
145172
// the port update is NOOP if nothing has changed
146173
this.boardsServiceProvider.updateConfig(uploadResponse.portAfterUpload);
147174

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

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/common/protocol/core-service.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,18 @@ export namespace CoreError {
7171
Upload: 4002,
7272
UploadUsingProgrammer: 4003,
7373
BurnBootloader: 4004,
74+
UploadRequiresProgrammer: 4005,
7475
};
7576
export const VerifyFailed = declareCoreError(Codes.Verify);
7677
export const UploadFailed = declareCoreError(Codes.Upload);
7778
export const UploadUsingProgrammerFailed = declareCoreError(
7879
Codes.UploadUsingProgrammer
7980
);
8081
export const BurnBootloaderFailed = declareCoreError(Codes.BurnBootloader);
82+
export const UploadRequiresProgrammer = declareCoreError(
83+
Codes.UploadRequiresProgrammer
84+
);
85+
8186
export function is(
8287
error: unknown
8388
): error is ApplicationError<number, ErrorLocation[]> {

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

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/node/core-service-impl.ts
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ClientReadableStream } from '@grpc/grpc-js';
1+
import { type ClientReadableStream } from '@grpc/grpc-js';
22
import { ApplicationError } from '@theia/core/lib/common/application-error';
33
import type { CancellationToken } from '@theia/core/lib/common/cancellation';
44
import { CommandService } from '@theia/core/lib/common/command';
@@ -41,6 +41,7 @@ import { Port as RpcPort } from './cli-protocol/cc/arduino/cli/commands/v1/port_
4141
import {
4242
BurnBootloaderRequest,
4343
BurnBootloaderResponse,
44+
ProgrammerIsRequiredForUploadError,
4445
UploadRequest,
4546
UploadResponse,
4647
UploadUsingProgrammerRequest,
@@ -295,12 +296,24 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
295296
reject(UserAbortApplicationError());
296297
return;
297298
}
299+
300+
if (
301+
ServiceError.isInstanceOf(
302+
error,
303+
ProgrammerIsRequiredForUploadError
304+
)
305+
) {
306+
reject(CoreError.UploadRequiresProgrammer());
307+
return;
308+
}
309+
298310
const message = nls.localize(
299311
'arduino/upload/error',
300312
'{0} error: {1}',
301313
firstToUpperCase(task),
302314
error.details
303315
);
316+
304317
this.sendResponse(error.details, OutputMessage.Severity.Error);
305318
reject(
306319
errorCtor(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.