11These tools must be in the form of executables that can be launched as a subprocess using a ` platform.txt ` command line
2- recipe. They will communicate to the parent process via stdin/stdout, in particular a discovery will accept commands as
3- plain text strings from stdin and will send answers back in JSON format on stdout. Each tool will implement the commands
4- to list and enumerate ports for a specific protocol as specified in this document.
2+ recipe. They communicate to the parent process via stdin/stdout, accepting commands as plain text strings from stdin and
3+ sending answers back in JSON format on stdout. Each tool will implement the commands to list and enumerate ports for a
4+ specific protocol as specified in this document.
55
66### Pluggable discovery API via stdin/stdout
77
@@ -10,7 +10,7 @@ All the commands listed in this specification must be implemented in the discove
1010After startup, the tool will just stay idle waiting for commands. The available commands are: ` HELLO ` , ` START ` , ` STOP ` ,
1111` QUIT ` , ` LIST ` and ` START_SYNC ` .
1212
13- After each command the client always expect a response from the discovery. The discovery must not introduce any delay
13+ After each command the client always expects a response from the discovery. The discovery must not introduce any delay
1414and must respond to all commands as fast as possible.
1515
1616#### HELLO command
@@ -21,8 +21,7 @@ pluggable discovery protocol that the client/IDE supports. The syntax of the com
2121` HELLO <PROTOCOL_VERSION> "<USER_AGENT>" `
2222
2323- ` <PROTOCOL_VERSION> ` is the maximum protocol version supported by the client/IDE (currently ` 1 ` )
24-
25- - ` <USER_AGENT> ` is the name and version of the client (double-quotes ` " ` are not allowed)
24+ - ` <USER_AGENT> ` is the name and version of the client. It must not contain double-quotes (` " ` ).
2625
2726some examples:
2827
@@ -48,13 +47,13 @@ are three possible cases:
4847- if the discovery supports a more recent version of the protocol than the client/IDE: the discovery should downgrade
4948 itself into compatibility mode and report a ` protocolVersion ` that is less than or equal to the one supported by the
5049 client/IDE.
51- - if the discovery cannot go into compatibility mode, it will report the protocol version supported (even if greater
50+ - if the discovery cannot go into compatibility mode, it must report the protocol version supported (even if greater
5251 than the version supported by the client/IDE) and the client/IDE may decide to terminate the discovery or produce an
5352 error/warning.
5453
5554#### START command
5655
57- The ` START ` command initializes and start the discovery internal subroutines. This command must be called before ` LIST `
56+ The ` START ` command initializes and starts the discovery internal subroutines. This command must be called before ` LIST `
5857or ` START_SYNC ` . The response to the start command is:
5958
6059``` JSON
@@ -78,7 +77,7 @@ The `error` field must be set to `true` and the `message` field should contain a
7877
7978#### STOP command
8079
81- The ` STOP ` command stops the discovery internal subroutines and possibly free the internally used resources. This
80+ The ` STOP ` command stops the discovery internal subroutines and possibly frees the internally used resources. This
8281command should be called if the client wants to pause the discovery for a while. The response to the command is:
8382
8483``` JSON
@@ -130,7 +129,8 @@ call. The format of the response is the following:
130129 "properties": {
131130 <-- A LIST OF PROPERTIES OF THE PORT
132131 }
133- }, {
132+ },
133+ {
134134 ... <-- OTHER PORTS...
135135 }
136136 ]
@@ -142,17 +142,13 @@ The `ports` field contains a list of the available ports.
142142Each port has:
143143
144144- an ` address ` (for example ` /dev/ttyACM0 ` for serial ports or ` 192.168.10.100 ` for network ports)
145-
146145- a ` label ` that is the human readable form of the ` address ` (it may be for example ` ttyACM0 ` or
147146 ` SSH on 192.168.10.100 ` )
148-
149147- ` protocol ` is the protocol identifier (such as ` serial ` or ` dfu ` or ` ssh ` )
150-
151148- ` protocolLabel ` is the ` protocol ` in human readable form (for example ` Serial port ` or ` DFU USB ` or ` Network (ssh) ` )
152-
153149- ` properties ` is a list of key/value pairs that represent information relative to the specific port
154150
155- To make the above more clear let’ s show an example with the ` serial_discovery ` :
151+ To make the above more clear let' s show an example with the ` serial_discovery ` :
156152
157153``` JSON
158154{
@@ -174,18 +170,18 @@ To make the above more clear let’s show an example with the `serial_discovery`
174170}
175171```
176172
177- In this case the serial port metadata comes from an USB serial converter. Inside the ` properties ` we have all the
173+ In this case the serial port metadata comes from a USB serial converter. Inside the ` properties ` we have all the
178174properties of the port, and some of them may be useful for product identification (in this case only USB VID/PID is
179175useful to identify the board model).
180176
181177The ` LIST ` command performs a one-shot polling of the ports. The discovery should answer as soon as reasonably possible,
182178without any additional delay.
183179
184180Some discoveries may require some time to discover a new port (for example network protocols like MDNS, Bluetooth, etc.
185- requires some seconds to receive the broadcasts from all available clients) in that case is fine to answer with an empty
186- or incomplete list.
181+ require some seconds to receive the broadcasts from all available clients) in that case it is fine to answer with an
182+ empty or incomplete list.
187183
188- If an error occurs and the discovery can't complete the enumeration is must report the error with:
184+ If an error occurs and the discovery can't complete the enumeration, it must report the error with:
189185
190186``` JSON
191187{
@@ -210,7 +206,7 @@ command is:
210206}
211207```
212208
213- After this message the discoery will send ` add ` and ` remove ` event asyncronoushly (more on that later). If an error
209+ After this message the discovery will send ` add ` and ` remove ` events asynchronously (more on that later). If an error
214210occurs and the discovery can't go in "events" mode the error must be reported as:
215211
216212``` JSON
@@ -283,29 +279,31 @@ If the client sends an invalid or malformed command, the discovery should answer
283279
284280The ` properties ` associated to a port can be used to identify the board attached to that port. The algorithm is simple:
285281
286- - each board listed in the platform file ` boards.txt ` may declare a set of ` upload_port.* ` properties
282+ - each board listed in the platform file [ ` boards.txt ` ] ( platform-specification.md#boardstxt ) may declare a set of
283+ ` upload_port.* ` properties
287284- if each ` upload_port.* ` property has a match in the ` properties ` set coming from the discovery then the board is a
288- “ candidate” board attached to that port.
285+ " candidate" board attached to that port.
289286
290287Some port ` properties ` may not be precise enough to uniquely identify a board, in that case more boards may match the
291- same set of ` properties ` , that’ s why we called it “ candidate” .
288+ same set of ` properties ` , that' s why we called it " candidate" .
292289
293- Let’ s see an example to clarify things a bit, let's suppose that we have the following ` properties ` coming from the
290+ Let' s see an example to clarify things a bit, let's suppose that we have the following ` properties ` coming from the
294291serial discovery:
295292
296- ``` JSON
293+ ```
297294 "port": {
298295 "address": "/dev/ttyACM0",
299296 "properties": {
300297 "pid": "0x804e",
301298 "vid": "0x2341",
302299 "serialNumber": "EBEABFD6514D32364E202020FF10181E",
303300 "name": "ttyACM0"
304- }
301+ },
302+ ...
305303```
306304
307305in this case we can use ` vid ` and ` pid ` to identify the board. The ` serialNumber ` , instead, is unique for that specific
308- instance of the board so it can't be used to identify the board model. Let’ s suppose we have the following `boards.txt`:
306+ instance of the board so it can't be used to identify the board model. Let' s suppose we have the following ` boards.txt ` :
309307
310308```
311309# Arduino Zero (Programming Port)
@@ -365,4 +363,4 @@ myboard.upload_port.1.apples=40
365363```
366364
367365will match on both ` pears=20, apples=30 ` and ` pears=30, apples=40 ` but not ` pears=20, apples=40 ` , in that sense each
368- " set" of identification properties is indepentent from each other and cannot be mixed for port matching.
366+ "set" of identification properties is independent from each other and cannot be mixed for port matching.
0 commit comments