Skip to content

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

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

Closed
romainreignier opened this issue Nov 23, 2021 · 2 comments · Fixed by #1604
Closed

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

romainreignier opened this issue Nov 23, 2021 · 2 comments · Fixed by #1604
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@romainreignier
Copy link

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,
@romainreignier
Copy link
Author

As a side note, an example of changing the baudrate should be added to the documentation.

@per1234 per1234 changed the title monitor do apply serial port configuration change like baudrate monitor does not apply serial port configuration change like baudrate Nov 23, 2021
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Nov 23, 2021
cmaglie added a commit to cmaglie/arduino-cli that referenced this issue Dec 23, 2021
@cmaglie cmaglie assigned cmaglie and unassigned silvanocerza Dec 23, 2021
@cmaglie
Copy link
Member

cmaglie commented Dec 23, 2021

Thanks @romainreignier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants