Unverified Commit 4079684e authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

[skip-changelog] Added UploadUsingProgrammer gRPC API (#1045)

* Added UploadUsingProgrammer gRPC call

* fix indent
parent bf6bb1eb
...@@ -258,6 +258,19 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadReq, stream rpc.ArduinoCor ...@@ -258,6 +258,19 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadReq, stream rpc.ArduinoCor
return stream.Send(resp) return stream.Send(resp)
} }
// UploadUsingProgrammer FIXMEDOC
func (s *ArduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgrammerReq, stream rpc.ArduinoCore_UploadUsingProgrammerServer) error {
resp, err := upload.UsingProgrammer(
stream.Context(), req,
utils.FeedStreamTo(func(data []byte) { stream.Send(&rpc.UploadUsingProgrammerResp{OutStream: data}) }),
utils.FeedStreamTo(func(data []byte) { stream.Send(&rpc.UploadUsingProgrammerResp{ErrStream: data}) }),
)
if err != nil {
return err
}
return stream.Send(resp)
}
// BurnBootloader FIXMEDOC // BurnBootloader FIXMEDOC
func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderReq, stream rpc.ArduinoCore_BurnBootloaderServer) error { func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderReq, stream rpc.ArduinoCore_BurnBootloaderServer) error {
resp, err := upload.BurnBootloader( resp, err := upload.BurnBootloader(
......
...@@ -71,6 +71,27 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr ...@@ -71,6 +71,27 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
return &rpc.UploadResp{}, nil return &rpc.UploadResp{}, nil
} }
// UsingProgrammer FIXMEDOC
func UsingProgrammer(ctx context.Context, req *rpc.UploadUsingProgrammerReq, outStream io.Writer, errStream io.Writer) (*rpc.UploadUsingProgrammerResp, error) {
logrus.Tracef("Upload using programmer %s on %s started", req.GetSketchPath(), req.GetFqbn())
if req.GetProgrammer() == "" {
return nil, errors.New("programmer not specified")
}
_, err := Upload(ctx, &rpc.UploadReq{
Instance: req.GetInstance(),
SketchPath: req.GetSketchPath(),
ImportFile: req.GetImportFile(),
ImportDir: req.GetImportDir(),
Fqbn: req.GetFqbn(),
Port: req.GetPort(),
Programmer: req.GetProgrammer(),
Verbose: req.GetVerbose(),
Verify: req.GetVerify(),
}, outStream, errStream)
return &rpc.UploadUsingProgrammerResp{}, err
}
func runProgramAction(pm *packagemanager.PackageManager, func runProgramAction(pm *packagemanager.PackageManager,
sketch *sketches.Sketch, sketch *sketches.Sketch,
importFile, importDir, fqbnIn, port string, importFile, importDir, fqbnIn, port string,
......
This diff is collapsed.
...@@ -97,9 +97,13 @@ service ArduinoCore { ...@@ -97,9 +97,13 @@ service ArduinoCore {
// Upgrade an installed platform to the latest version. // Upgrade an installed platform to the latest version.
rpc PlatformUpgrade(PlatformUpgradeReq) returns (stream PlatformUpgradeResp); rpc PlatformUpgrade(PlatformUpgradeReq) returns (stream PlatformUpgradeResp);
// Upload a compiled sketch to an Arduino board. // Upload a compiled sketch to a board.
rpc Upload(UploadReq) returns (stream UploadResp); rpc Upload(UploadReq) returns (stream UploadResp);
// Upload a compiled sketch to a board using a programmer.
rpc UploadUsingProgrammer(UploadUsingProgrammerReq) returns (stream UploadUsingProgrammerResp);
// List programmers available for a board.
rpc ListProgrammersAvailableForUpload(ListProgrammersAvailableForUploadReq) returns (ListProgrammersAvailableForUploadResp); rpc ListProgrammersAvailableForUpload(ListProgrammersAvailableForUploadReq) returns (ListProgrammersAvailableForUploadResp);
// Burn bootloader to a board. // Burn bootloader to a board.
......
This diff is collapsed.
...@@ -23,15 +23,15 @@ import "commands/common.proto"; ...@@ -23,15 +23,15 @@ import "commands/common.proto";
message UploadReq { message UploadReq {
// Arduino Core Service instance from the `Init` response. // Arduino Core Service instance from the `Init` response.
Instance instance = 1; Instance instance = 1;
// Fully qualified board name of the target board (e.g., `arduino:avr:uno`). // Fully qualified board name of the target board (e.g., `arduino:avr:uno`).
// If this field is not defined, the FQBN of the board attached to the sketch // If this field is not defined, the FQBN of the board attached to the sketch
// via the `BoardAttach` method is used. // via the `BoardAttach` method is used.
string fqbn = 2; string fqbn = 2;
// Path where the sketch to be uploaded is stored. Unless the `import_file` // Path where the sketch to be uploaded is stored. Unless the `import_file`
// field is defined, the compiled binary is assumed to be at the location and // field is defined, the compiled binary is assumed to be at the location and
// filename under this path where it is saved by the `Compile` method. // filename under this path where it is saved by the `Compile` method.
string sketch_path = 3; string sketch_path = 3;
// The port of the board. // The port of the board.
string port = 4; string port = 4;
// Whether to turn on verbose output during the upload. // Whether to turn on verbose output during the upload.
...@@ -45,6 +45,9 @@ message UploadReq { ...@@ -45,6 +45,9 @@ message UploadReq {
// Custom path to a directory containing compiled files. When `import_dir` is // Custom path to a directory containing compiled files. When `import_dir` is
// not specified, the standard build directory under `sketch_path` is used. // not specified, the standard build directory under `sketch_path` is used.
string import_dir = 8; string import_dir = 8;
// The programmer to use for upload. If set an UploadUsingProgrammer is triggered
// instead of a normal upload. The UploadUsingProgrammer call may also be used for
// explicit error check.
string programmer = 9; string programmer = 9;
} }
...@@ -55,6 +58,41 @@ message UploadResp { ...@@ -55,6 +58,41 @@ message UploadResp {
bytes err_stream = 2; bytes err_stream = 2;
} }
message UploadUsingProgrammerReq {
// Arduino Core Service instance from the `Init` response.
Instance instance = 1;
// Fully qualified board name of the target board (e.g., `arduino:avr:uno`).
// If this field is not defined, the FQBN of the board attached to the sketch
// via the `BoardAttach` method is used.
string fqbn = 2;
// Path where the sketch to be uploaded is stored. Unless the `import_file`
// field is defined, the compiled binary is assumed to be at the location and
// filename under this path where it is saved by the `Compile` method.
string sketch_path = 3;
// The port of the board.
string port = 4;
// Whether to turn on verbose output during the upload.
bool verbose = 5;
// After upload, verify that the contents of the memory on the board match the
// uploaded binary.
bool verify = 6;
// When `import_file` is specified, it overrides the `import_dir` and `sketch_path`
// params.
string import_file = 7;
// Custom path to a directory containing compiled files. When `import_dir` is
// not specified, the standard build directory under `sketch_path` is used.
string import_dir = 8;
// The programmer to use for upload.
string programmer = 9;
}
message UploadUsingProgrammerResp {
// The output of the upload process.
bytes out_stream = 1;
// The error output of the upload process.
bytes err_stream = 2;
}
message BurnBootloaderReq { message BurnBootloaderReq {
// Arduino Core Service instance from the `Init` response. // Arduino Core Service instance from the `Init` response.
Instance instance = 1; Instance instance = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment