arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.33k stars 394 forks source link

Free serial port when panel of the Serial Monitor view is collapsed #2491

Open per1234 opened 3 months ago

per1234 commented 3 months ago

Describe the request

When the Serial Monitor view is opened, the monitor opens the selected port. When the view is closed, the port is closed, allowing it to be used by other processes.

The bottom panel or right side panel of the Arduino IDE window serve as the containers for the Serial Monitor view.

The user can control the visibility of these panels. From a user's perspective, there isn't a significant difference between collapsing the panel in which the view is located and closing the view because either results in the visual disappearance of the view. However, there is a significant functional difference in that the port remains open in Serial Monitor when its view is collapsed. Not realizing that the port is still being used can be problematic because it blocks any other application (even including Arduino IDE's own firmware updater and upload operation in some cases) from opening the port.

šŸ™‚ A more intuitive behavior would be for Serial Monitor to close the port when the view's panel is collapsed.

Demo

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette". A menu will appear on the editor toolbar: Command Palette
  2. Select the "Preferences: Open Settings (UI)" command from the menu. ā“˜ You can scroll down through the list of commands to find it or type the name in the field. A "Preferences" tab will open in the Arduino IDE main panel.
  3. Type arduino.monitor.dockPanel in the "Search Settings" field of the "Preferences" tab.
  4. Select "right" from the menu under the "Arduino ā€ŗ Monitor: Dock Panel" setting. ā“˜ The behavior is not specific to the right panel, but the demo is more compelling in this configuration. The reason being that the right panel is only used for the Serial Monitor view and its toggle control is very discoverable, so the user is likely to collapse the right panel during normal use. Conversely, since the bottom panel is also the container for the frequently used "Output" view, and since its primary toggle control is less discoverable, the user is less likely to ever collapse the bottom panel.
  5. Close the Preferences tab by clicking its X icon.
  6. Select any port from the Tools > Port menu.
  7. Select Tools > Serial Monitor from the Arduino IDE menus. The Serial Monitor view opens in the right side panel.
  8. Click the magnifying icon in the right activity bar. The right side panel collapses, making the Serial Monitor view no longer visible.
  9. Open the port in any other application. ā“˜ You can use arduino cli monitor for this purpose, the Arduino IDE 1.x Serial Monitor, a standalone terminal emulator like PuTTY, or whatever else you have on hand. šŸ™ The other application can't open the port.
  10. Click the "Serial Monitor" icon on the Arduino IDE 2.x toolbar. The right activity bar disappears.
  11. Open the port in any other application. šŸ˜• The application is now able to open the port.

Note that these two icons are very similar, and adjacent, yet have very different functions. The difference between the two is not well communicated to the user:

image

Arduino IDE version

aa9b10d

Operating system

Operating system version

Additional context

Originally reported by @mjs513 at https://forum.arduino.cc/t/should-we-still-report-and-check-for-semi-minor-issues-and-annoyances/1290531/9

Issue checklist

Lorandil commented 4 weeks ago

I'm not 100% sure, but if collapsing the view frees the port, what happens if I want to see the output again? Wouldn't reconnecting cause an Arduino Uno to reset? Is that 'intuitive behaviour'? If this is so, the behaviour on collapsing should at least be an option.