Skip to content
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

Monitor open request overrides port settings from platform's board definition #2504

Open
3 tasks done
sterretjeToo opened this issue Sep 10, 2024 · 0 comments
Open
3 tasks done
Labels
topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project

Comments

@sterretjeToo
Copy link

sterretjeToo commented Sep 10, 2024

Describe the problem

The Arduino boards platform framework allows pluggable monitor port settings to be configured via properties in the board definition:

https://arduino.github.io/arduino-cli/dev/platform-specification/#port-configuration

🐛 When Arduino IDE sends the monitor open request message, it passes an apparently hard coded complete port configuration, overriding any custom port settings from the board definition.

To reproduce

Equipment

A board that has an auto-reset circuit that causes the board to reset when its port's DTR or RTS control signal is asserted:

The scope of the bug is not limited to these boards only, but this set was selected for use in the demo.

Demo

  1. Select File > Quit (or Arduino > Quit Arduino for macOS users) from the Arduino IDE menus if it is running.
    All Arduino IDE windows will close.
  2. Open any text editor.
  3. Add the following text to a new text file in the editor:
    uno.monitor_port.serial.rts=off
    uno.monitor_port.serial.dtr=off
    
    unomini.monitor_port.serial.rts=off
    unomini.monitor_port.serial.dtr=off
    
    nano.monitor_port.serial.rts=off
    nano.monitor_port.serial.dtr=off
    
    mega.monitor_port.serial.rts=off
    mega.monitor_port.serial.dtr=off
    
  4. Save the file with the filename boards.local.txt in the following location:
    • If you are using Linux:
      /home/<username>/.arduino15/packages/arduino/hardware/avr/1.8.6/boards.local.txt
      
      (Where <username> is your Linux username)
      ❗ The .arduino15 folder may be hidden by default in your file manager and terminal.
    • If you are using macOS:
      /Users/<username>/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/boards.local.txt
      
      (Where <username> is your macOS username)
      ❗ The Library folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.
    • If you are using Windows:
      C:\Users\<username>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\boards.local.txt
      
      (Where <username> is your Windows username)
      ❗ If looking for it with your file manager or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".
  5. Start Arduino IDE.
  6. Connect the Arduino board to your computer with a USB cable.
  7. Select the appropriate board and port from the Arduino IDE menus.
  8. If Serial Monitor is running, select Tools > Serial Monitor from the Arduino IDE menus to close it.
  9. Upload the following sketch to the board:
    void setup() {
      Serial.begin(9600);
      delay(500);
      Serial.println("setup");
    }
    
    void loop() {
      Serial.println("loop");
      delay(1000);
    }
  10. Wait for the upload to finish.
  11. Wait a few more seconds to allow the program to run on the board for a while.
  12. Select Tools > Serial Monitor from the Arduino IDE menus.

🐛 The board is reset, resulting in "setup" being printed to Serial Monitor before the "loop" starts being printed.

This reset would not have occurred if the pluggable monitor port settings from the board definition had been honored, and thus we expect to only see "loop" in Serial Monitor (since the program has been running for some seconds before Serial Monitor was opened).

Clean up

Delete the boards.local.txt file you created.

Expected behavior

Arduino IDE only controls the Monitor's baudrate port setting (according to the menu selection in the Serial Monitor GUI). The platform framework provides all other port settings (either via the defaults or custom settings from the board definition).

Arduino IDE version

Original report

2.3.2

Last verified with

1ec0a8c

Operating system

Windows

Operating system version

Win11 Home

Additional context

The fault does not occur when I use arduino-cli monitor or the cc.arduino.cli.commands.v1.ArduinoCoreService.Monitor request directly, specifying only the baudrate port setting.


When I enable the arduino.cli.daemon.debug advanced setting, I see that Arduino IDE sends a cc.arduino.cli.commands.v1.ArduinoCoreService.EnumerateMonitorPortSettings request, and the response contains the customized rts and dtr port setting values (off):

2024-09-11 21:42:57 2024-09-12T04:42:57.095Z daemon INFO 41 CALLED: /cc.arduino.cli.commands.v1.ArduinoCoreService/EnumerateMonitorPortSettings
41 |  REQ:  {
41 |    "instance": {
41 |      "id": 1
41 |    },
41 |    "port_protocol": "serial",
41 |    "fqbn": "arduino:avr:uno"
41 |  }
41 |  RESP: {
41 |    "settings": [
41 |      {
41 |        "setting_id": "dtr",
41 |        "label": "DTR",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "on",
41 |          "off"
41 |        ],
41 |        "value": "off"
41 |      },
41 |      {
41 |        "setting_id": "parity",
41 |        "label": "Parity",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "none",
41 |          "even",
41 |          "odd",
41 |          "mark",
41 |          "space"
41 |        ],
41 |        "value": "none"
41 |      },
41 |      {
41 |        "setting_id": "rts",
41 |        "label": "RTS",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "on",
41 |          "off"
41 |        ],
41 |        "value": "off"
41 |      },
41 |      {
41 |        "setting_id": "stop_bits",
41 |        "label": "Stop bits",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "1",
41 |          "1.5",
41 |          "2"
41 |        ],
41 |        "value": "1"
41 |      },
41 |      {
41 |        "setting_id": "baudrate",
41 |        "label": "Baudrate",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "300",
41 |          "600",
41 |          "750",
41 |          "1200",
41 |          "2400",
41 |          "4800",
41 |          "9600",
41 |          "19200",
41 |          "31250",
41 |          "38400",
41 |          "57600",
41 |          "74880",
41 |          "115200",
41 |          "230400",
41 |          "250000",
41 |          "460800",
41 |          "500000",
41 |          "921600",
41 |          "1000000",
41 |          "2000000"
41 |        ],
41 |        "value": "9600"
41 |      },
41 |      {
41 |        "setting_id": "bits",
41 |        "label": "Data bits",
41 |        "type": "enum",
41 |        "enum_values": [
41 |          "5",
41 |          "6",
41 |          "7",
41 |          "8",
41 |          "9"
41 |        ],
41 |        "value": "8"
41 |      }
41 |    ]
41 |  }
41 CALL END

(note the value of the rts and dtr settings is off)

But then that data is not used in the full configuration that is passed in the subsequent monitor open request message:

2024-09-11 21:42:57 2024-09-12T04:42:57.113Z daemon INFO 42 CALLED: /cc.arduino.cli.commands.v1.ArduinoCoreService/Monitor STREAM_REQ STREAM_RESP
2024-09-11 21:42:57 2024-09-12T04:42:57.113Z daemon INFO 42 |  REQ:  {
42 |    "Message": {
42 |      "OpenRequest": {
42 |        "instance": {
42 |          "id": 1
42 |        },
42 |        "port": {
42 |          "address": "COM17",
42 |          "protocol": "serial"
42 |        },
42 |        "fqbn": "arduino:avr:uno",
42 |        "port_configuration": {
42 |          "settings": [
42 |            {
42 |              "setting_id": "dtr",
42 |              "value": "on"
42 |            },
42 |            {
42 |              "setting_id": "parity",
42 |              "value": "none"
42 |            },
42 |            {
42 |              "setting_id": "rts",
42 |              "value": "on"
42 |            },
42 |            {
42 |              "setting_id": "stop_bits",
42 |              "value": "1"
42 |            },
42 |            {
42 |              "setting_id": "baudrate",
42 |              "value": "9600"
42 |            },
42 |            {
42 |              "setting_id": "bits",
42 |              "value": "8"
42 |            }
42 |          ]
42 |        }
42 |      }
42 |    }
42 |  }
2024-09-11 21:42:57 2024-09-12T04:42:57.129Z daemon INFO 42 |  RESP: {
42 |    "Message": {
42 |      "Success": true
42 |    }
42 |  }

(note the value of the rts and dtr settings is on)

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@sterretjeToo sterretjeToo added the type: imperfection Perceived defect in any part of project label Sep 10, 2024
@per1234 per1234 transferred this issue from arduino/arduino-ide Sep 12, 2024
@per1234 per1234 transferred this issue from arduino/arduino-cli Sep 12, 2024
@per1234 per1234 changed the title IDE 2.3.2 ignores disableDTR and/or disableRTS in AVR boards.txt Monitor open request overrides dtr and rts settings from platform's board definition Sep 12, 2024
@per1234 per1234 changed the title Monitor open request overrides dtr and rts settings from platform's board definition Monitor open request overrides settings from platform's board definition Sep 12, 2024
@per1234 per1234 changed the title Monitor open request overrides settings from platform's board definition Monitor open request overrides port settings from platform's board definition Sep 12, 2024
@per1234 per1234 added topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants