Description
Describe the bug
If a custom discovery lists a port with the same address as another port, but a different protocol, then Arduino-IDE should treat them as separate ports. This is how the Arduino-cli works and the 1.X IDE.
The 2.0 IDE groups them together and only shows one device, with the protocol determined by which discovery reported the added device first.
To Reproduce
Steps to reproduce the behavior:
- Edit the code for serial-discovery to return protocol="newprotocol" instead of serial and compile it with the name newprotocol-discovery.
- Then configure a platform to use the newprotocol-discovery as a discovery source.
- Then when you plug in a comm port, instead of see it listed twice, once with protocol 'serial' and once with protocl 'newprotocol' you will only see it once. If you unplug and replug the device, it may show up with a different protocol depending on who discovery say the reconnect first.
Expected behavior
In the setup above, any comm port connected to the system should be listed twice, once under 'serial' protocol, and once under 'newprotocol'.
Debug Lines
For my testing, I have an Arduino device. serial-discovery sees it as:
"ports": [
{
"address": "COM16",
"label": "COM16",
"protocol": "serial",
"protocolLabel": "Serial Port (USB)",
"properties": {
"pid": "0x0941",
"serialNumber": "90742540",
"vid": "0x1781"
}
}
]
A second discovery I'm running (quarto-discovery) sees that same port as
"ports": [
{
"address": "COM16",
"label": "Quarto (COM16)",
"protocol": "sam-ba",
"protocolLabel": "sam-ba emulator",
"properties": {
"mi": "0x00",
"pid": "0x0941",
"serialNumber": "90742540",
"upload": "1",
"vid": "0x1781"
}
}
]
I then run arduino-ide rc2 in verbose mode and when I plug in my device, I sometimes get:
root INFO Attached boards and available ports changed:
root INFO - Attached board: Quarto [qnimble:imxrt:quarto] on COM16 Quarto (COM16)
root INFO ------------------------------------------
daemon INFO from discovery builtin:serial-discovery received message type: add, port: COM16
root WARN Port 'COM16' was already available. Known boards before override: [{"fqbn":"qnimble:imxrt:quarto","name":"Quarto","port":{"address":"COM16","protocol":"sam-ba","label":"Quarto (COM16)"}}]
In this case, the serial-discovery return is ignored. Other times, I get
daemon INFO from discovery builtin:serial-discovery received message type: add, port: COM16
daemon INFO from discovery qnimble:quarto-discovery received message type: add, port: COM16
root WARN Port 'COM16' was already available. Known boards before override: []
and in this case quarto-discovery's return is ignored.
I've run the same test with arduino-cli and there I get:
INFO[0186] from discovery builtin:serial-discovery received message type: add, port: COM16
INFO[0186] from discovery qnimble:quarto-discovery received message type: add, port: COM16
where the two discoveries do not conflict and it adds COM16 twice, once with each protocol.
Desktop (please complete the following information):
- OS: Windows 10
- Version: 2.0rc2