Skip to content

Pluggable discovery #2

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

Merged
merged 44 commits into from
Jun 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3dc657e
Add RFC for pluggable discovery
cmaglie Mar 15, 2021
2f7f65d
Fixed some typos and made RFC compliant to RFC template
cmaglie Mar 16, 2021
3254493
Assign RFC number
cmaglie Mar 31, 2021
78ee413
Added a note about multiple 'add' events
cmaglie Apr 1, 2021
bfcb83d
Added a note about START_SYNC
cmaglie Apr 1, 2021
16a2687
Added discovery priority based on the currently selected board
cmaglie Apr 1, 2021
afac1cc
fix: Address and Protocol must be unique
cmaglie Apr 30, 2021
2a1cc89
Renamed 'prefs' field to 'properties'
cmaglie Apr 30, 2021
2cab0a9
Made matching algorithm more explicit about mixing identification props
cmaglie Apr 30, 2021
e17982c
Removed identificationPrefs
cmaglie Apr 30, 2021
44e8d99
Added some backward compatibility considerations
cmaglie Apr 30, 2021
b10d52d
Added HELLO command
cmaglie Apr 30, 2021
a88bd92
Added possibility to use discovery from other platforms
cmaglie May 4, 2021
4c7f1bf
cleaned up examples for board identification
cmaglie May 4, 2021
972e15a
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
8aa8f6e
Made 'plugin' more explicit
cmaglie May 13, 2021
4b9d4b2
Added HELLO negotiation
cmaglie May 13, 2021
0316cb9
Use a single number revision scheme
cmaglie May 13, 2021
e051454
Added 'name' field in hypotetical serial-discovery
cmaglie May 13, 2021
bad688c
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
3916891
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
26de7ce
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
8affbd7
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
a4a7e63
fixed link
cmaglie May 13, 2021
ec88d16
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
e50a9dc
Removed weird cuts markers
cmaglie May 13, 2021
7f8c194
Update RFCs/0002-pluggable-discovery.md
cmaglie May 13, 2021
69c3f9f
Added a note about LIST timings
cmaglie May 17, 2021
c591ebb
Specify that backward compatibliity rules apply only for VID/PID
cmaglie May 17, 2021
5149d92
Specify that backward compatibliity rules apply even for indexed rules
cmaglie May 17, 2021
cc44f9b
Builtin discoveries are used by default, unless specified
cmaglie May 17, 2021
875ce97
fix typo
cmaglie May 17, 2021
c3242ad
Transfer ALL port metadata into upload preferences
cmaglie May 17, 2021
5bdfe30
Added no-port protocol support
cmaglie May 24, 2021
db340b1
Rename 'user' custom field to 'field'
cmaglie May 24, 2021
bc3963d
Added error handling
cmaglie May 26, 2021
c6cdecc
Moved paragraph and cleared arduino-cli usage scenario
cmaglie May 26, 2021
e756a44
Added more details about message sequencing
cmaglie May 26, 2021
1c082fd
Discovery install via package_index.json
cmaglie May 27, 2021
6ed74a2
Give to 'Board Identification' its own chapter
cmaglie May 27, 2021
2e078d4
Only serial-discovery and network-discovery are automatically added t…
cmaglie May 31, 2021
1885102
Renamed 'no-port' protocol to 'default'
cmaglie May 31, 2021
6830030
Made backward compatibility mode more explicit for default upload
cmaglie May 31, 2021
ef19331
Changed field to integer
cmaglie Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added error handling
  • Loading branch information
cmaglie committed May 26, 2021
commit bc3963d75f6a64e1b00cdb7b604e29f8897f2895
79 changes: 75 additions & 4 deletions RFCs/0002-pluggable-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ All the commands listed in this specification must be implemented in the discove

After startup, the tool will just stay idle waiting for commands. The available commands are: `HELLO`, `START`, `STOP`, `QUIT`, `LIST` and `START_SYNC`.

The discovery must not introduce any delay in the protocol and must respond to all commands as fast as possible.

#### HELLO command

`HELLO` is the **first command that must be sent** to the discovery to tell the name of the client/IDE and the version of the pluggable discovery protocol that the client/IDE supports.
`HELLO` **must be the first command sent** to the discovery to tell the name of the client/IDE and the version of the pluggable discovery protocol that the client/IDE supports.
The syntax of the command is:

`HELLO <PROTOCOL_VERSION> "<USER_AGENT>"`
Expand Down Expand Up @@ -92,6 +94,18 @@ The `START` command initializes and start the discovery internal subroutines. Th
}
```

If the discovery could not start, for any reason, it must report the error with:

```JSON
{
"eventType": "start",
"error": true,
"message": "Permission error"
}
```

The `error` field must be set to `true` and the `message` field should contain a description of the error.

#### STOP command

The `STOP` command stops the discovery internal subroutines and possibly free the internally used resources. This command should be called if the client wants to pause the discovery for a while. The response to the command is:
Expand All @@ -103,6 +117,18 @@ The `STOP` command stops the discovery internal subroutines and possibly free th
}
```

If an error occurs:

```JSON
{
"eventType": "stop",
"error": true,
"message": "Resource busy"
}
```

The `error` field must be set to `true` and the `message` field should contain a description of the error.

#### QUIT command

The `QUIT` command terminates the discovery. The response to `QUIT` is:
Expand All @@ -114,7 +140,7 @@ The `QUIT` command terminates the discovery. The response to `QUIT` is:
}
```

after this output the discovery exits.
after this output the discovery exits. This command is supposed to always succeed.

#### LIST command

Expand Down Expand Up @@ -181,11 +207,42 @@ The `LIST` command performs a one-shot polling of the ports. The discovery shoul

Some discoveries may require some time to discover a new port (for example network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients) in that case is fine to answer with an empty or incomplete list.

If an error occurs and the discovery can't complete the enumeration is must report the error with:

```JSON
{
"eventType": "list",
"error": true,
"message": "Resource busy"
}
```

The `error` field must be set to `true` and the `message` field should contain a description of the error.

#### START_SYNC command

The `START_SYNC` command puts the tool in "events" mode: the discovery will send `add` and `remove` events each time a new port is detected or removed respectively.
The `START_SYNC` command puts the tool in "events" mode: the discovery will send `add` and `remove` events each time a new port is detected or removed respectively. If the discovery goes into "events" mode successfully the response to this command is:

```JSON
{
"eventType": "start_sync",
"message": "OK"
}
```

If the CLI is used in command-line mode (`arduino-cli board list` command) then we need a one-shot output and we can run the discoveries with the `LIST` command instead. Note that some discoveries may not be able to `LIST` ports immediately after the launch (in particular network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients).
After this message the discoery will send `add` and `remove` event asyncronoushly (more on that later). If an error occurs and the discovery can't go in "events" mode the error must be reported as:

```JSON
{
"eventType": "start_sync",
"error": true,
"message": "Resource busy"
}
```

The `error` field must be set to `true` and the `message` field should contain a description of the error.

If the CLI is used in command-line mode (for example the `arduino-cli board list` command) then we need a one-shot output and we can run the discoveries with the `LIST` command instead of using `START_SYNC`. Note that some discoveries may not be able to `LIST` ports immediately after the launch (in particular network protocols like MDNS, Bluetooth, etc. requires some seconds to receive the broadcasts from all available clients).

If the CLI is running in daemon mode, ideally, all the installed discoveries should be started simultaneously in “event mode” (with `START_SYNC`) and the list of available ports should be cached inside the CLI daemon.

Expand Down Expand Up @@ -227,6 +284,20 @@ The content is straightforward, in this case only the `address` and `protocol` f

If the information about a port needs to be updated the discovery may send a new `add` message for the same port address and protocol without sending a `remove` first: this means that all the previous information about the port must be discarded and replaced with the new one.

#### Invalid commands

If the client sends an invalid or malformed command, the discovery should answer with:

```JSON
{
"eventType": "command_error",
"error": true,
"message": "Unknown command XXXX"
}
```

#### Reference implementations

A demo tool is available here:
https://github.com/arduino/serial-discovery

Expand Down