-
-
Notifications
You must be signed in to change notification settings - Fork 470
Description
Describe the request
Follow-up of #1332.
Originally posted here:
I don't understand why these two specific protocols are treated differently than any other arbitrary protocol. In this new era of pluggable discovery, where no assumptions or restrictions are placed on which communication channel might be used between the Arduino tooling and an Arduino board, it seems best for the Arduino IDE to generalize the handling of ports.
Describe the current behavior
IDE2 handles 'serial'
and 'network'
protocols but nothing else. Generalize the protocol handling of the ports.
Besides showing the protocol label somewhere on the UI, IDE should not treat 'serial
' and 'network'
port protocols differently than other protocols.
Arduino IDE version
Operating system
macOS
Operating system version
12.3.1
Additional context
To clean up in the code-base:
['serial', 'network'].forEach((protocol) => { if (port.protocol === 'serial' || port.protocol === 'network') { if (port.protocol === 'serial' || port.protocol === 'network') {
To single-source in the code-base:
arduino-ide/arduino-ide-extension/src/browser/boards/boards-service-provider.ts
Lines 638 to 666 in 79ea0fa
export const compare = (left: AvailableBoard, right: AvailableBoard) => { if (left.port?.protocol === 'serial' && right.port?.protocol !== 'serial') { return -1; } else if ( left.port?.protocol !== 'serial' && right.port?.protocol === 'serial' ) { return 1; } else if ( left.port?.protocol === 'network' && right.port?.protocol !== 'network' ) { return -1; } else if ( left.port?.protocol !== 'network' && right.port?.protocol === 'network' ) { return 1; } else if (left.port?.protocol === right.port?.protocol) { // We show all ports, including those that have guessed // or unrecognized boards, so we must sort those too. if (left.state < right.state) { return -1; } else if (left.state > right.state) { return 1; } } return naturalCompare(left.port?.address!, right.port?.address!); }; arduino-ide/arduino-ide-extension/src/browser/boards/boards-config.tsx
Lines 204 to 238 in 79ea0fa
// Available ports must be sorted in this order: // 1. Serial with recognized boards // 2. Serial with guessed boards // 3. Serial with incomplete boards // 4. Network with recognized boards // 5. Other protocols with recognized boards const ports = (await availablePorts).sort((left: Port, right: Port) => { if (left.protocol === 'serial' && right.protocol !== 'serial') { return -1; } else if (left.protocol !== 'serial' && right.protocol === 'serial') { return 1; } else if (left.protocol === 'network' && right.protocol !== 'network') { return -1; } else if (left.protocol !== 'network' && right.protocol === 'network') { return 1; } else if (left.protocol === right.protocol) { // We show ports, including those that have guessed // or unrecognized boards, so we must sort those too. const leftBoard = this.availableBoards.find( (board) => board.port === left ); const rightBoard = this.availableBoards.find( (board) => board.port === right ); if (leftBoard && !rightBoard) { return -1; } else if (!leftBoard && rightBoard) { return 1; } else if (leftBoard?.state! < rightBoard?.state!) { return -1; } else if (leftBoard?.state! > rightBoard?.state!) { return 1; } } return naturalCompare(left.address, right.address);
Issue checklist
- I searched for previous requests in the issue tracker
- I verified the feature was still missing when using the latest nightly build
- My request contains all necessary details