Skip to content

Commit 378b8bf

Browse files
author
rsora
committed
Cosmetics here and there
1 parent 9923f62 commit 378b8bf

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

arduino/utils/stream.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func FeedStreamTo(writer func(data []byte)) io.Writer {
3737
// ConsumeStreamFrom creates a pipe to consume data from the reader function.
3838
// ConsumeStreamFrom returns the io.Reader side of the pipe, which the user can use to consume the data
3939
func ConsumeStreamFrom(reader func() ([]byte, error)) io.Reader {
40-
4140
r, w := io.Pipe()
4241
go func() {
4342
for {

cli/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package cli
1717

1818
import (
1919
"fmt"
20-
"github.com/arduino/arduino-cli/cli/debug"
2120
"io/ioutil"
2221
"os"
2322
"path/filepath"
@@ -29,6 +28,7 @@ import (
2928
"github.com/arduino/arduino-cli/cli/config"
3029
"github.com/arduino/arduino-cli/cli/core"
3130
"github.com/arduino/arduino-cli/cli/daemon"
31+
"github.com/arduino/arduino-cli/cli/debug"
3232
"github.com/arduino/arduino-cli/cli/errorcodes"
3333
"github.com/arduino/arduino-cli/cli/feedback"
3434
"github.com/arduino/arduino-cli/cli/generatedocs"

cli/debug/debug.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,15 @@ func NewCommand() *cobra.Command {
4242
debugCommand := &cobra.Command{
4343
Use: "debug",
4444
Short: "Debug Arduino sketches.",
45-
Long: "Debug Arduino sketches.",
46-
Example: " " + os.Args[0] + " debug /home/user/Arduino/MySketch",
45+
Long: "Debug Arduino sketches. (this command opens an interactive gdb session)",
46+
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 /home/user/Arduino/MySketch",
4747
Args: cobra.MaximumNArgs(1),
4848
Run: run,
4949
}
5050

5151
debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
5252
debugCommand.Flags().StringVarP(&port, "port", "p", "", "Upload port, e.g.: COM10 or /dev/ttyACM0")
53-
debugCommand.Flags().StringVarP(&importFile, "input", "i", "", "Input file to be uploaded.")
54-
55-
debugCommand.MarkFlagRequired("port")
53+
debugCommand.Flags().StringVarP(&importFile, "input", "i", "", "Input file to be uploaded for debug.")
5654

5755
return debugCommand
5856
}
@@ -77,7 +75,7 @@ func run(command *cobra.Command, args []string) {
7775
Port: port,
7876
ImportFile: importFile,
7977
}, os.Stdin, os.Stdout); err != nil {
80-
feedback.Errorf("Error during Upload: %v", err)
78+
feedback.Errorf("Error during Debug: %v", err)
8179
os.Exit(errorcodes.ErrGeneric)
8280
}
8381
}

commands/debug/debug.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ import (
2828
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2929
"github.com/arduino/arduino-cli/arduino/sketches"
3030
"github.com/arduino/arduino-cli/commands"
31+
"github.com/arduino/arduino-cli/executils"
32+
dbg "github.com/arduino/arduino-cli/rpc/debug"
3133
"github.com/arduino/go-paths-helper"
3234
"github.com/arduino/go-properties-orderedmap"
3335
"github.com/sirupsen/logrus"
34-
35-
"github.com/arduino/arduino-cli/executils"
36-
dbg "github.com/arduino/arduino-cli/rpc/debug"
3736
)
3837

3938
// Debug command launches a debug tool for a sketch.
@@ -44,7 +43,7 @@ import (
4443
// It also implements tool process lifecycle management
4544
func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out io.Writer) (*dbg.DebugResp, error) {
4645

47-
// get tool commandLine from core recipe
46+
// Get tool commandLine from core recipe
4847
pm := commands.GetPackageManager(req.GetInstance().GetId())
4948
commandLine, err := getCommandLine(req, pm)
5049
if err != nil {

commands/debug/debug_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ package debug
1717

1818
import (
1919
"fmt"
20+
"strings"
21+
"testing"
22+
2023
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
21-
rpc "github.com/arduino/arduino-cli/rpc/common"
2224
dbg "github.com/arduino/arduino-cli/rpc/debug"
2325
"github.com/arduino/go-paths-helper"
2426
"github.com/stretchr/testify/assert"
25-
"strings"
26-
"testing"
2727
)
2828

2929
var customHardware = paths.New("testdata", "custom_hardware")
@@ -36,14 +36,18 @@ func TestGetCommandLine(t *testing.T) {
3636
pm.LoadHardwareFromDirectory(customHardware)
3737
pm.LoadHardwareFromDirectory(dataDir)
3838

39+
// Arduino Zero has an integrated debugger port, anc it could be debugged directly using USB
3940
req := &dbg.DebugConfigReq{
40-
Instance: &rpc.Instance{Id: 1},
41+
Instance: &dbg.Instance{Id: 1},
4142
Fqbn: "arduino-test:samd:arduino_zero_edbg",
4243
SketchPath: sketchPath,
4344
Port: "none",
4445
}
4546
packageName := strings.Split(req.Fqbn, ":")[0]
4647
processor := strings.Split(req.Fqbn, ":")[1]
48+
// This boardFamily variable is necessary for this particular board as it is represented in the core as 2 separated
49+
// boards, to expose the programming port and the debug (edbg) port. So we point at the same openocd configuration
50+
// variant for upload in both cases
4751
boardFamily := "arduino_zero"
4852

4953
goldCommand := []string{
@@ -59,9 +63,10 @@ func TestGetCommandLine(t *testing.T) {
5963
assert.Nil(t, err)
6064
assert.Equal(t, goldCommand, command)
6165

62-
// for other samd boards
66+
// Other samd boards such as mkr1000 can be debugged using an external tool such as Atmel ICE connected to
67+
// the board debug port
6368
req2 := &dbg.DebugConfigReq{
64-
Instance: &rpc.Instance{Id: 1},
69+
Instance: &dbg.Instance{Id: 1},
6570
Fqbn: "arduino-test:samd:mkr1000",
6671
SketchPath: sketchPath,
6772
Port: "none",

0 commit comments

Comments
 (0)