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 e94aa89

Browse filesBrowse files
feat: upload using programmer by default if board requires it
1 parent 8ebc12f commit e94aa89
Copy full SHA for e94aa89

File tree

3 files changed

+44
-3
lines changed
Filter options

3 files changed

+44
-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
+25-2Lines changed: 25 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,8 +138,30 @@ 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+
const response = await coreService.upload(
144+
{ ...uploadOptions, progressId },
145+
token
146+
);
147+
return response;
148+
} catch (err) {
149+
if (err.code === 4005) {
150+
const uploadWithProgrammerOptions = await this.uploadOptions(
151+
true,
152+
verifyOptions
153+
);
154+
if (uploadWithProgrammerOptions) {
155+
return await coreService.upload(
156+
{ ...uploadWithProgrammerOptions, progressId },
157+
token
158+
);
159+
}
160+
}
161+
162+
throw err;
163+
}
164+
},
142165
keepOutput: true,
143166
cancelable: true,
144167
});

‎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.