mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-04-19 12:57:17 +00:00
feat: upload using programmer by default if board requires it
This commit is contained in:
parent
2de8bd1717
commit
a5bf56ffa6
@ -127,6 +127,7 @@ export class UploadSketch extends CoreServiceContribution {
|
||||
usingProgrammer,
|
||||
verifyOptions
|
||||
);
|
||||
|
||||
if (!uploadOptions) {
|
||||
return;
|
||||
}
|
||||
@ -137,11 +138,37 @@ export class UploadSketch extends CoreServiceContribution {
|
||||
|
||||
const uploadResponse = await this.doWithProgress({
|
||||
progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'),
|
||||
task: (progressId, coreService, token) =>
|
||||
coreService.upload({ ...uploadOptions, progressId }, token),
|
||||
task: async (progressId, coreService, token) => {
|
||||
try {
|
||||
return await coreService.upload(
|
||||
{ ...uploadOptions, progressId },
|
||||
token
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.code === 4005) {
|
||||
const uploadWithProgrammerOptions = await this.uploadOptions(
|
||||
true,
|
||||
verifyOptions
|
||||
);
|
||||
if (uploadWithProgrammerOptions) {
|
||||
return coreService.upload(
|
||||
{ ...uploadWithProgrammerOptions, progressId },
|
||||
token
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
},
|
||||
keepOutput: true,
|
||||
cancelable: true,
|
||||
});
|
||||
|
||||
if (!uploadResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
// the port update is NOOP if nothing has changed
|
||||
this.boardsServiceProvider.updateConfig(uploadResponse.portAfterUpload);
|
||||
|
||||
|
@ -71,6 +71,7 @@ export namespace CoreError {
|
||||
Upload: 4002,
|
||||
UploadUsingProgrammer: 4003,
|
||||
BurnBootloader: 4004,
|
||||
UploadRequiresProgrammer: 4005,
|
||||
};
|
||||
export const VerifyFailed = declareCoreError(Codes.Verify);
|
||||
export const UploadFailed = declareCoreError(Codes.Upload);
|
||||
@ -78,6 +79,10 @@ export namespace CoreError {
|
||||
Codes.UploadUsingProgrammer
|
||||
);
|
||||
export const BurnBootloaderFailed = declareCoreError(Codes.BurnBootloader);
|
||||
export const UploadRequiresProgrammer = declareCoreError(
|
||||
Codes.UploadRequiresProgrammer
|
||||
);
|
||||
|
||||
export function is(
|
||||
error: unknown
|
||||
): error is ApplicationError<number, ErrorLocation[]> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { ClientReadableStream } from '@grpc/grpc-js';
|
||||
import { type ClientReadableStream } from '@grpc/grpc-js';
|
||||
import { ApplicationError } from '@theia/core/lib/common/application-error';
|
||||
import type { CancellationToken } from '@theia/core/lib/common/cancellation';
|
||||
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_
|
||||
import {
|
||||
BurnBootloaderRequest,
|
||||
BurnBootloaderResponse,
|
||||
ProgrammerIsRequiredForUploadError,
|
||||
UploadRequest,
|
||||
UploadResponse,
|
||||
UploadUsingProgrammerRequest,
|
||||
@ -295,12 +296,24 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
||||
reject(UserAbortApplicationError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
ServiceError.isInstanceOf(
|
||||
error,
|
||||
ProgrammerIsRequiredForUploadError
|
||||
)
|
||||
) {
|
||||
reject(CoreError.UploadRequiresProgrammer());
|
||||
return;
|
||||
}
|
||||
|
||||
const message = nls.localize(
|
||||
'arduino/upload/error',
|
||||
'{0} error: {1}',
|
||||
firstToUpperCase(task),
|
||||
error.details
|
||||
);
|
||||
|
||||
this.sendResponse(error.details, OutputMessage.Severity.Error);
|
||||
reject(
|
||||
errorCtor(
|
||||
|
Loading…
x
Reference in New Issue
Block a user