Skip to content

Commit a977a70

Browse files
authored
Merge pull request #16 from per1234/fix-readme
Correct example commands and output in README to reflect actual behavior of tool
2 parents 465fe1b + e7d7cec commit a977a70

File tree

1 file changed

+154
-57
lines changed

1 file changed

+154
-57
lines changed

README.md

+154-57
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ The response to the command is:
3131
```json
3232
{
3333
"eventType": "hello",
34-
"protocolVersion": 1,
35-
"message": "OK"
34+
"message": "OK",
35+
"protocolVersion": 1
3636
}
3737
```
3838

@@ -42,17 +42,18 @@ The response to the command is:
4242

4343
The `DESCRIBE` command returns a description of the communication port. The description will have metadata about the port configuration, and which parameters are available:
4444

45+
<!-- prettier-ignore -->
4546
```json
4647
{
47-
"event": "describe",
48-
"message": "ok",
48+
"eventType": "describe",
49+
"message": "OK",
4950
"port_description": {
5051
"protocol": "serial",
5152
"configuration_parameters": {
5253
"baudrate": {
5354
"label": "Baudrate",
5455
"type": "enum",
55-
"values": [
56+
"value": [
5657
"300",
5758
"600",
5859
"750",
@@ -73,22 +74,38 @@ The `DESCRIBE` command returns a description of the communication port. The desc
7374
],
7475
"selected": "9600"
7576
},
76-
"parity": {
77-
"label": "Parity",
78-
"type": "enum",
79-
"values": ["None", "Even", "Odd", "Mark", "Space"],
80-
"selected": "None"
81-
},
8277
"bits": {
8378
"label": "Data bits",
8479
"type": "enum",
85-
"values": ["5", "6", "7", "8", "9"],
80+
"value": [
81+
"5",
82+
"6",
83+
"7",
84+
"8",
85+
"9"
86+
],
8687
"selected": "8"
8788
},
89+
"parity": {
90+
"label": "Parity",
91+
"type": "enum",
92+
"value": [
93+
"None",
94+
"Even",
95+
"Odd",
96+
"Mark",
97+
"Space"
98+
],
99+
"selected": "None"
100+
},
88101
"stop_bits": {
89102
"label": "Stop bits",
90103
"type": "enum",
91-
"values": ["1", "1.5", "2"],
104+
"value": [
105+
"1",
106+
"1.5",
107+
"2"
108+
],
92109
"selected": "1"
93110
}
94111
}
@@ -100,7 +117,7 @@ Each parameter has a unique name (`baudrate`, `parity`, etc...), a `type` (in th
100117

101118
The parameter name can not contain spaces, and the allowed characters in the name are alphanumerics, underscore `_`, dot `.`, and dash `-`.
102119

103-
The `enum` types must have a list of possible `values`.
120+
The `enum` types must have a list of possible `value`.
104121

105122
The client/IDE may expose these configuration values to the user via a config file or a GUI, in this case the `label` field may be used for a user readable description of the parameter.
106123

@@ -114,18 +131,18 @@ The response to the command is:
114131

115132
```JSON
116133
{
117-
"event": "configure",
118-
"message": "ok",
134+
"eventType": "configure",
135+
"message": "OK"
119136
}
120137
```
121138

122139
or if there is an error:
123140

124141
```JSON
125142
{
126-
"event": "configure",
127-
"error": true,
128-
"message": "invalid value for parameter baudrate: 123456"
143+
"eventType": "configure",
144+
"message": "invalid value for parameter baudrate: 123456",
145+
"error": true
129146
}
130147
```
131148

@@ -150,16 +167,16 @@ The answer to the `OPEN` command is:
150167

151168
```JSON
152169
{
153-
"event": "open",
154-
"message": "ok"
170+
"eventType": "open",
171+
"message": "OK"
155172
}
156173
```
157174

158175
If the monitor tool cannot communicate with the board, or if the tool can not connect back to the TCP port, or if any other error condition happens:
159176

160177
```JSON
161178
{
162-
"event": "open",
179+
"eventType": "open",
163180
"error": true,
164181
"message": "unknown port /dev/ttyACM23"
165182
}
@@ -171,17 +188,19 @@ Once the port is opened, it may be unexpectedly closed at any time due to hardwa
171188

172189
```JSON
173190
{
174-
"event": "port_closed",
175-
"message": "serial port disappeared!"
191+
"eventType": "port_closed",
192+
"message": "serial port disappeared!",
193+
"error": true
176194
}
177195
```
178196

179197
or
180198

181199
```JSON
182200
{
183-
"event": "port_closed",
184-
"message": "lost TCP/IP connection with the client!"
201+
"eventType": "port_closed",
202+
"message": "lost TCP/IP connection with the client!",
203+
"error": true
185204
}
186205
```
187206

@@ -191,16 +210,16 @@ The `CLOSE` command will close the currently opened port and close the TCP/IP co
191210

192211
```JSON
193212
{
194-
"event": "close",
195-
"message": "ok"
213+
"eventType": "close",
214+
"message": "OK"
196215
}
197216
```
198217

199218
or in case of error
200219

201220
```JSON
202221
{
203-
"event": "close",
222+
"eventType": "close",
204223
"error": true,
205224
"message": "port already closed"
206225
}
@@ -227,7 +246,7 @@ If the client sends an invalid or malformed command, the monitor should answer w
227246
{
228247
"eventType": "command_error",
229248
"error": true,
230-
"message": "Unknown command XXXX"
249+
"message": "Command XXXX not supported"
231250
}
232251
```
233252

@@ -247,33 +266,70 @@ DESCRIBE
247266
"eventType": "describe",
248267
"message": "OK",
249268
"port_description": {
250-
"protocol": "test",
269+
"protocol": "serial",
251270
"configuration_parameters": {
252-
"echo": {
253-
"label": "echo",
254-
"type": "enum",
255-
"value": [
256-
"on",
257-
"off"
258-
],
259-
"selected": "on"
260-
},
261-
"speed": {
271+
"baudrate": {
262272
"label": "Baudrate",
263273
"type": "enum",
264274
"value": [
275+
"300",
276+
"600",
277+
"750",
278+
"1200",
279+
"2400",
280+
"4800",
265281
"9600",
266282
"19200",
267283
"38400",
268284
"57600",
269-
"115200"
285+
"115200",
286+
"230400",
287+
"460800",
288+
"500000",
289+
"921600",
290+
"1000000",
291+
"2000000"
270292
],
271293
"selected": "9600"
294+
},
295+
"bits": {
296+
"label": "Data bits",
297+
"type": "enum",
298+
"value": [
299+
"5",
300+
"6",
301+
"7",
302+
"8",
303+
"9"
304+
],
305+
"selected": "8"
306+
},
307+
"parity": {
308+
"label": "Parity",
309+
"type": "enum",
310+
"value": [
311+
"None",
312+
"Even",
313+
"Odd",
314+
"Mark",
315+
"Space"
316+
],
317+
"selected": "None"
318+
},
319+
"stop_bits": {
320+
"label": "Stop bits",
321+
"type": "enum",
322+
"value": [
323+
"1",
324+
"1.5",
325+
"2"
326+
],
327+
"selected": "1"
272328
}
273329
}
274330
}
275331
}
276-
CONFIGURE speed 19200
332+
CONFIGURE baudrate 19200
277333
{
278334
"eventType": "configure",
279335
"message": "OK"
@@ -283,33 +339,70 @@ DESCRIBE
283339
"eventType": "describe",
284340
"message": "OK",
285341
"port_description": {
286-
"protocol": "test",
342+
"protocol": "serial",
287343
"configuration_parameters": {
288-
"echo": {
289-
"label": "echo",
290-
"type": "enum",
291-
"value": [
292-
"on",
293-
"off"
294-
],
295-
"selected": "on"
296-
},
297-
"speed": {
344+
"baudrate": {
298345
"label": "Baudrate",
299346
"type": "enum",
300347
"value": [
348+
"300",
349+
"600",
350+
"750",
351+
"1200",
352+
"2400",
353+
"4800",
301354
"9600",
302355
"19200",
303356
"38400",
304357
"57600",
305-
"115200"
358+
"115200",
359+
"230400",
360+
"460800",
361+
"500000",
362+
"921600",
363+
"1000000",
364+
"2000000"
306365
],
307366
"selected": "19200"
367+
},
368+
"bits": {
369+
"label": "Data bits",
370+
"type": "enum",
371+
"value": [
372+
"5",
373+
"6",
374+
"7",
375+
"8",
376+
"9"
377+
],
378+
"selected": "8"
379+
},
380+
"parity": {
381+
"label": "Parity",
382+
"type": "enum",
383+
"value": [
384+
"None",
385+
"Even",
386+
"Odd",
387+
"Mark",
388+
"Space"
389+
],
390+
"selected": "None"
391+
},
392+
"stop_bits": {
393+
"label": "Stop bits",
394+
"type": "enum",
395+
"value": [
396+
"1",
397+
"1.5",
398+
"2"
399+
],
400+
"selected": "1"
308401
}
309402
}
310403
}
311404
}
312-
OPEN 127.0.0.1:5678 "test"
405+
OPEN 127.0.0.1:5678 /dev/ttyACM0
313406
{
314407
"eventType": "open",
315408
"message": "OK"
@@ -320,10 +413,14 @@ CLOSE
320413
"message": "OK"
321414
}
322415
QUIT
416+
{
417+
"eventType": "quit",
418+
"message": "OK"
419+
}
323420
$
324421
```
325422

326-
On another terminal tab to test it you can run `nc -l -p 5678` before running the `OPEN 127.0.0.1:5678 "test"` command. After that you can write messages in that terminal tab and see them being echoed.
423+
On another terminal tab to test it you can run `nc -l -p 5678` before running the `OPEN 127.0.0.1:5678 /dev/ttyACM0` command. After that you can write messages in that terminal tab and see them being echoed.
327424

328425
## Security
329426

0 commit comments

Comments
 (0)