Open
Description
Describe the request
As a consumer of the gRPC API, I would like to receive an event if the gRPC equivalent of the board list watch
command has started.
Currently, one can listen to the first BoardListWatchResponse
event and consider the command running, but the first event might not ever arrive if the environment does have built-in ports (for example, COM1
on Windows, or /dev/cu.Bluetooth-Incoming-Port
on macOS) although the command has successfully started and is running. A similar feature has been implemented for the monitor via 7afdc38.
Describe the current behavior
There is no explicit signaling if the gRPC equivalent of the board list watch
has started.
Arduino CLI version
0.34.0
Operating system
macOS
Operating system version
13.5
Additional context
No response
Issue checklist
- I searched for previous requests in the issue trackerI verified the feature was still missing when using the nightly buildMy request contains all necessary details
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
cmaglie commentedon Sep 1, 2023
What's the use case for this feature?
kittaakos commentedon Sep 1, 2023
See this 👇
A machine might want to know if the
board list watch
command is running. Imagine a standalone discovery service using theboard list watch
gRPC API. When you ask this discovery service, it should know its state and whether ready.kittaakos commentedon Sep 1, 2023
The CLI has a dedicated event type (
'quit'
) to signal the end; why not add the'start'
?arduino-cli/rpc/cc/arduino/cli/commands/v1/board.proto
Lines 199 to 200 in 3f9373a
cmaglie commentedon Sep 1, 2023
But even after the hypothetical
started
acknowledgment, you don't know when/if a portadd
event will arrive afterward.The discoveries are asynchronous by nature, they don't have an "initial state"... I mean, even after discovery is started, it may require a few milliseconds for the initial messages to arrive.
That's the reason why the
board list
command has a--discovery-timeout
argument: it's the amount of time to wait for discoveries to get data:As you can see the slowest discoveries take more time to provide port data,
serial
is fairly quick (<100ms)mdns-discovery
may take even >1s to actually discover the board via network.Uhm... the
quit
message is used internally to unwire a single discovery from being broadcasted to the active watchers, did you read aquit
message in the gRPC API?kittaakos commentedon Sep 1, 2023
arduino/arduino-ide@a8ae0bb#diff-535c5b57092ab0075afb79d52d75b187b361a4eed5e581be76a51de1500bf8fdR101-R105
From here arduino/arduino-ide#674 (comment):
cmaglie commentedon Sep 1, 2023
That comment refers to a very old implementation of the board watch, in fact, the same message says:
And that's how I reimplemented the watcher, I'm pretty sure no
quit
messages are incoming from the board watch gRPC API.The IDE only sees a stream of
add
andremove
events, it doesn't know if there were 1 or more discoveries under the hood. If a discovery is "removed", this is handled internally from the daemon, the IDE only sees a bunch of portsremove
events.