arduino / arduino-ide

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

Identified ports of protocols other than serial or network not shown in Board Selector #1365

Closed per1234 closed 1 year ago

per1234 commented 1 year ago

Describe the problem

The Arduino pluggable discovery system allows the use of any communication channel between an Arduino board and the Arduino development software. This means that, in addition to the traditional "serial" and "network" protocols supported by Arduino IDE 1.x, Arduino IDE 2.x supports any arbitrary protocol which may be implemented by a package developer.

These are presented to the user via the same interfaces as serial and network ports:

🐛 Ports of protocols other than "serial" and "network" are not shown in the latter two.

To reproduce

Equipment

Steps

  1. Disconnect the Teensy board from your computer if it is currently connected.
  2. Select File > New from the Arduino IDE menus. These first two steps are required to ensure there isn't a preexisting user-created board association for the port.
  3. Connect the Teensy board to your computer.
  4. Open the Tools > Port menu in the Arduino IDE. 🙂 The teensy protocol port is shown on the menu, and identified as the appropriate board: image
  5. Open the "Board Selector" menu in the Arduino IDE. 🐛 The identified teensy protocol port is not shown on the menu: image
  6. Select "Select other board and port..." from the "Board Selector" menu. 🐛 The identified teensy protocol port is not shown on the "PORTS" menu: image

Expected behavior

Protocol is not a factor in whether a port is shown in the "Board Selector" menu and "Select Other Board and Port" dialog. The same criteria should be applied to all ports.

image

Arduino IDE version

2.0.0-rc9.2.snapshot-34a7fdb

Operating system

Windows, Linux

Operating system version

Windows 10, Ubuntu 20.04

Additional context

I bisected the introduction of the bug to https://github.com/arduino/arduino-ide/pull/1332 (it does not occur when using the build from https://github.com/arduino/arduino-ide/commit/d674ab9b7365ab75d659b5a3a3a51d8809516593)

Even though the stated purpose of that PR was only to cause unidentified network ports to be shown in the "Board Selector" menu, the PR also changed the code so that even identified ports of any other protocol are no longer shown.


All is as expected in the Arduino CLI output (note that the Teensy board's port has a matching_boards object):

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: 63f1e185 Date: 2022-08-28T21:55:54Z

$ arduino-cli board list --format json
[
  {
    "matching_boards": [
      {
        "name": "Teensy 4.1",
        "fqbn": "teensy:avr:teensy41"
      }
    ],
    "port": {
      "address": "usb:0/1A0000/0/1/5/1/1/3",
      "label": "hid#vid_16c0\u0026pid_0486 RawHID",
      "protocol": "teensy",
      "protocol_label": "Teensy Ports",
      "properties": {
        "modelID": "0x25",
        "name": "Teensy 4.1",
        "serialNumber": "808372",
        "usbtype": "USB_RAWHID"
      }
    }
  },
  {
    "port": {
      "address": "COM1",
      "label": "COM1",
      "protocol": "serial",
      "protocol_label": "Serial Port"
    }
  },
  {
    "matching_boards": [
      {
        "name": "Arduino Mega or Mega 2560",
        "fqbn": "arduino:avr:mega"
      }
    ],
    "port": {
      "address": "COM7",
      "label": "COM7",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x0042",
        "serialNumber": "754393136373518111D2",
        "vid": "0x2341"
      }
    }
  },
  {
    "port": {
      "address": "COM254",
      "label": "COM254",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x6001",
        "serialNumber": "A9VD4GXEA",
        "vid": "0x0403"
      }
    }
  },
  {
    "port": {
      "address": "COM3",
      "label": "COM3",
      "protocol": "serial",
      "protocol_label": "Serial Port"
    }
  },
  {
    "port": {
      "address": "COM52",
      "label": "COM52",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0xFA78",
        "serialNumber": "6",
        "vid": "0x0403"
      }
    }
  },
  {
    "port": {
      "address": "192.168.254.127",
      "label": "esp32-b4e62dbf693d at 192.168.254.127",
      "protocol": "network",
      "protocol_label": "Network Port",
      "properties": {
        ".": "node32s",
        "auth_upload": "no",
        "board": "node32s",
        "hostname": "esp32-b4e62dbf693d.local.",
        "port": "3232",
        "ssh_upload": "no",
        "tcp_check": "no"
      }
    }
  }
]

This is an example of the problems that can be caused by the current practice of treating ports of specific protocols differently than others in the Arduino IDE codebase: https://github.com/arduino/arduino-ide/issues/1334

Issue checklist

KurtE commented 1 year ago

@per1234 - The Teensy example above is probably a valid choice.

That is for example, when you build for a Teensy 4.1 you have several options for what USB type you are building for.

Serial
Dual Serial
Triple Serial
Keyboard
Keyboard + Touch Screen
Keyboard + Mouse + Touch Screen
Keyboard + Mouse + Joystick
Serial + Keyboard + Mouse + Joystick
MIDI
MIDIx4
MIDIx16
Serial + MIDI
Serial + MIDIx4
Serial + MIDIx16
Audio
Serial + MIDI + Audio
Serial + MIDIx16 + Audio
MTP Disk (Experimental)
Serial + MTP Disk (Experimental)
Raw HID
Flight Sim Controls
Flight Sim Controls + Joystick

Only those types in the list that have the word Serial in their name, like Serial, or Serial + MTP Disk (Experimental) ..

Actually, would create a Standard Windows CDC ACM Serial port. Most of the other instead create what the Teensy refers to as a Serial Emulator (SEREMU), which is sort of another special RAW HID, which the pluggable Serial Monitor code can talk to. like wise the upload code can talk to.

Question: over the last few nightly builds it feels like the Arduino code is losing track of which Com port to use, much more often.

I mentioned this on the forum thread: https://forum.arduino.cc/t/serial-monitor-issues-hopefully-fixed-before-release

Where ptillisch (@kittaakos ?) mentioned that it is probably related to the recent PR: https://github.com/arduino/arduino-ide/pull/1328

Wondering if I should create new issue, or it is maybe also related to this.

per1234 commented 1 year ago

ptillisch (@kittaakos ?)

Arduino Forum user "ptillisch" is me (the "p" is for "Per", my first name).

it is probably related to the recent PR: https://github.com/arduino/arduino-ide/pull/1328

I didn't, and wouldn't say "probably" at this stage in the investigation. The next step will be to do a bisection, which will indicate whether there was a regression, and if so, at which commit/PR that happened. I haven't done the bisection yet because the intermittent (hopefully pseudo-intermittent) nature of the bug makes doing that more difficult. I was hoping I could find the conditions required to consistently reproduce the bug before starting on the bisection.

Wondering if I should create new issue

I will take care of that (UPDATE: https://github.com/arduino/arduino-ide/issues/1366). I already started on preparing one, but then ran into the intermittency and decided I needed to attempt to progress with the investigation a bit farther first in order to ensure the formal report is actionable by the developers.

maybe also related to this.

I don't think it is related from a technical standpoint.

However, not seeing the port listed in the "Board Selector" may give the user the impression that the IDE has "lost track" of the port, even though that can occur completely independently from the bug that causes the loss of the port selection.