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

Report is_hidden field in board identification #2224

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jun 21, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Populates the is_hidden field when the board is detected.

What is the current behavior?

board list do not report hidden field:

What is the new behavior?

board list do report hidden field:

[
  {
    "matching_boards": [
      {
        "name": "Arduino Uno R4 WiFi",
        "fqbn": "arduino:renesas_portenta:unor4wifi",
        "is_hidden": true
      },
      {
        "name": "Arduino Uno R4 WiFi",
        "fqbn": "arduino:renesas_uno:unor4wifi"
      }
    ],
    "port": {
      "address": "/dev/ttyACM0",
      "label": "/dev/ttyACM0",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x1002",
        "serialNumber": "DC5475C30184",
        "vid": "0x2341"
      },
      "hardware_id": "DC5475C30184"
    }
  },
  {
    "port": {
      "address": "/dev/ttyS4",
      "label": "/dev/ttyS4",
      "protocol": "serial",
      "protocol_label": "Serial Port"
    }
  }
]

Does this PR introduce a breaking change, and is titled accordingly?

No

Other information

At the moment this is only reported as metadata in JSON / gRPC responses, it has no direct effect on the board list command. A board filtering based on the is_hidden value may be implemented later.

@cmaglie cmaglie added type: enhancement Proposed improvement topic: gRPC Related to the gRPC interface labels Jun 21, 2023
@cmaglie cmaglie self-assigned this Jun 21, 2023
Copy link
Contributor

@umbynos umbynos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kittaakos is this field used by the IDE?

@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.04 ⚠️

Comparison is base (223d3fa) 62.99% compared to head (da62890) 62.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2224      +/-   ##
==========================================
- Coverage   62.99%   62.95%   -0.04%     
==========================================
  Files         220      220              
  Lines       19477    19477              
==========================================
- Hits        12269    12262       -7     
- Misses       6128     6132       +4     
- Partials     1080     1083       +3     
Flag Coverage Δ
unit 62.95% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commands/board/list.go 60.19% <100.00%> (+0.19%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kittaakos
Copy link
Contributor

@kittaakos is this field used by the IDE?

No, it's unused in IDE2. What's the purpose of this property?

If the board is marked as "hidden" in the platform

@per1234 per1234 added the topic: code Related to content of the project itself label Jun 23, 2023
@umbynos
Copy link
Contributor

umbynos commented Jun 23, 2023

It comes from here https://arduino.github.io/arduino-cli/0.33/platform-specification/#hiding-boards
And here works correctly: In the Tools > Board menu the hidden board is not visibile.

The problem is that this field do not have anything to do in filtering of the board list command.

@kittaakos
Copy link
Contributor

here works correctly: In the Tools > Board menu

Do you mean this in IDE2?

Screenshot 2023-06-23 at 14 11 23

IDE2 uses the gRPC equivalent of ./arduino-cli board listall to populate the above menu per platform.


Slightly off:

The problem is that this field do not have anything to do in filtering of the board list command.

As a long-time user of the CLI API, I recommend not reusing the same type for different command responses. The commands board search, board listall, and board list are perfect examples. On the gRPC level, all response objects refer to a "board" concept as a BoardListItem, but the props are populated on different conditions. Please make it easier for clients to see what response object structure to expect.

For example, fqbn could be available on a board from the board list command response even if the platform is not installed. This behaves differently for board serarch.

@cmaglie
Copy link
Member Author

cmaglie commented Jun 26, 2023

Do you mean this in IDE2?

No, the equivalent of board list is the "Tools > Port" selection menu (DetectedBoard in gRPC world).
What we want to know is: when a hidden board is detected is it displayed in the "Tools > Port" menu?

Previously the matching_boards[].is_hidden field was not populated (even if present in the gRPC structure), it was always false, instead after this patch is now populated correctly:

  {
    "matching_boards": [
      {
        "name": "Arduino Uno R4 WiFi",
        "fqbn": "arduino:renesas_portenta:unor4wifi",
        "is_hidden": true                  <---------------------
      },
      {
        "name": "Arduino Uno R4 WiFi",
        "fqbn": "arduino:renesas_uno:unor4wifi"
      }
    ],
    "port": {
      "address": "/dev/ttyACM0",
      "label": "/dev/ttyACM0",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x1002",
        "serialNumber": "DC5475C30184",
        "vid": "0x2341"
      },
      "hardware_id": "DC5475C30184"
    }
  },

As a long-time user of the CLI API, I recommend not reusing the same type for different command responses. The commands board search, board listall, and board list are perfect examples. On the gRPC level, all response objects refer to a "board" concept as a BoardListItem, but the props are populated on different conditions. Please make it easier for clients to see what response object structure to expect.

This change is exactly to solve this problem, we reused BoardListItem but the is_hidden field was correctly populated only in the board listall command (so I expect the "hidden" boards to be correctly hidden in the Tools > Board menu).

@kittaakos
Copy link
Contributor

What we want to know is: when a hidden board is detected is it displayed in the "Tools > Port" menu?

Probably. IDE2 does not use the isHidden property at all.

@cmaglie cmaglie merged commit 53004ef into arduino:master Jun 27, 2023
@cmaglie cmaglie deleted the handle_hidden_items_in_board_list branch June 27, 2023 08:33
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: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants