Skip to content

[skip changelog] Small cleanups #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion arduino/cores/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func ParseFQBN(fqbnIn string) (*FQBN, error) {
}

func (fqbn *FQBN) String() string {
res := fmt.Sprintf("%s:%s:%s", fqbn.Package, fqbn.PlatformArch, fqbn.BoardID)
res := fqbn.StringWithoutConfig()
if fqbn.Configs.Size() > 0 {
sep := ":"
for _, k := range fqbn.Configs.Keys() {
Expand All @@ -75,3 +75,8 @@ func (fqbn *FQBN) String() string {
}
return res
}

// StringWithoutConfig returns the FQBN without the Config part
func (fqbn *FQBN) StringWithoutConfig() string {
return fqbn.Package + ":" + fqbn.PlatformArch + ":" + fqbn.BoardID
}
3 changes: 1 addition & 2 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W

// FIXME: Make a function to produce a better name...
// Make the filename without the FQBN configs part
fqbn.Configs = properties.NewMap()
fqbnSuffix := strings.Replace(fqbn.String(), ":", ".", -1)
fqbnSuffix := strings.Replace(fqbn.StringWithoutConfig(), ":", ".", -1)

var exportPath *paths.Path
var exportFile string
Expand Down
16 changes: 12 additions & 4 deletions commands/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
}

// Set properties for verbose upload
Verbose := req.GetVerbose()
if Verbose {
if req.GetVerbose() {
if v, ok := uploadProperties.GetOk("upload.params.verbose"); ok {
uploadProperties.Set("upload.verbose", v)
}
Expand All @@ -142,8 +141,7 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
}

// Set properties for verify
Verify := req.GetVerify()
if Verify {
if req.GetVerify() {
uploadProperties.Set("upload.verify", uploadProperties.Get("upload.params.verify"))
} else {
uploadProperties.Set("upload.verify", uploadProperties.Get("upload.params.noverify"))
Expand Down Expand Up @@ -191,6 +189,10 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
return nil, fmt.Errorf("cannot get serial port list: %s", err)
}
for _, p := range ports {
if req.GetVerbose() {
outStream.Write([]byte(fmt.Sprintf("Performing 1200-bps touch reset on serial port %s", p)))
outStream.Write([]byte(fmt.Sprintln()))
}
if p == port {
if err := touchSerialPortAt1200bps(p); err != nil {
return nil, fmt.Errorf("cannot perform reset: %s", err)
Expand All @@ -209,6 +211,9 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
// Wait for upload port if requested
actualPort := port // default
if uploadProperties.GetBoolean("upload.wait_for_upload_port") {
if req.GetVerbose() {
outStream.Write([]byte(fmt.Sprintln("Waiting for upload port...")))
}
if p, err := waitForNewSerialPort(); err != nil {
return nil, fmt.Errorf("cannot detect serial ports: %s", err)
} else if p == "" {
Expand Down Expand Up @@ -240,6 +245,9 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
}

// Run Tool
if req.GetVerbose() {
outStream.Write([]byte(fmt.Sprintln(cmdLine)))
}
cmd, err := executils.Command(cmdArgs)
if err != nil {
return nil, fmt.Errorf("cannot execute upload tool: %s", err)
Expand Down