Skip to content

monitor does not apply serial port configuration change like baudrate #1562

Closed
@romainreignier

Description

@romainreignier

Bug Report

Current behavior

With the new 0.20.0 version, the monitor has been added but the configuration changes are not applied.

For example, changing the baudrate to 115200 is not applied with this command:

arduino-cli monitor -p /dev/ttyUSB0 -c baudrate=115200

The configuration is recognized because the following output is given:

Monitor port settings:
baudrate=115200
Connected to /dev/ttyUSB0! Press CTRL-C to exit.

And the output of the serial port is not readable, showing not printable characters because of the bad baudrate settings.

Expected behavior

I would expect to see the strings printed by my Arduino board at 115200 bauds.

Environment

  • CLI version (output of arduino-cli version): arduino-cli Version: 0.20.0 Commit: 553c6375 Date: 2021-11-23T14:35:08Z and git master version: arduino-cli Version: git-snapshot Commit: c756a0f1 Date: 2021-11-23T17:20:00Z
  • OS and platform: Linux, Ubuntu 18.04.6

Additional context

After ading some logs from the source code, I did not found anywhere where the serial port config where sent to the serial-monitor program.

Adding this quick and dirty patch fixed the issue:

diff --git a/commands/monitor/monitor.go b/commands/monitor/monitor.go
index 8c217f81..49cbab66 100644
--- a/commands/monitor/monitor.go
+++ b/commands/monitor/monitor.go
@@ -84,6 +84,10 @@ func Monitor(ctx context.Context, req *rpc.MonitorRequest) (*PortProxy, *pluggab
                return nil, nil, &arduino.FailedMonitorError{Cause: err}
        }

+       for _, setting := range req.GetPortConfiguration().Settings {
+               m.Configure(setting.SettingId, setting.Value)
+       }
+
        return &PortProxy{
                rw:               monIO,
                changeSettingsCB: m.Configure,

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions