Skip to content

Commit 2773e7d

Browse files
committed
Merge pull request #13 from arduino/Language_content
ADD Serial.readString(), Serial.readStringUntil(), UPDATE Serial.parseInt() and Stream.parseInt()
2 parents c8d7e78 + c9afdce commit 2773e7d

File tree

5 files changed

+153
-9
lines changed

5 files changed

+153
-9
lines changed

Language/Functions/Communication/Serial/parseInt.adoc

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212

1313
[float]
1414
=== Description
15-
Looks for the next valid integer in the incoming serial stream. `parseInt()` inherits from the link:stream{ext-relative}[Stream] utility class.
15+
Looks for the next valid integer in the incoming serial `stream.parseInt()` inherits from the link:stream{ext-relative}[Stream] utility class.
1616

17-
If no valid integer is found within one second (adjustable through link:serialTimeout{ext-relative}[Serial.setTimeout()] ) a default value of 0 will be returned.
17+
18+
In particular:
19+
20+
* Initial characters that are not digits or a minus sign, are skipped; +
21+
* Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read; +
22+
* If no valid digits were read when the time-out (see Serial.setTimeout()) occurs, 0 is returned;
1823
[%hardbreaks]
1924

2025

2126
[float]
2227
=== Syntax
2328
`Serial.parseInt()`
24-
29+
`Serial.parseInt(char skipChar)`
2530

2631
_Arduino Mega only:_
2732

@@ -32,11 +37,11 @@ _Arduino Mega only:_
3237

3338
[float]
3439
=== Parameters
35-
Nothing
40+
`skipChar`: used to skip the indicated char in the search. Used for example to skip thousands divider.
3641

3742
[float]
3843
=== Returns
39-
`int` : the next valid integer
44+
`long` : the next valid integer
4045

4146
--
4247
// OVERVIEW SECTION ENDS

Language/Functions/Communication/Serial/readBytesUntil.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Serial.readBytesUntil() reads characters from the serial buffer into an array. T
5353
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
5454
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
5555
[role="language"]
56-
* #LANGUAGE# link:../stream{ext-relative}[stream] +
57-
* #LANGUAGE# link:../Stream/streamReadByteUntil{ext-relative}[stream.readByteUntil()]
56+
* #LANGUAGE# link:../stream{ext-relative}[Stream] +
57+
* #LANGUAGE# link:../Stream/streamReadByteUntil{ext-relative}[Stream.readByteUntil()]
5858
--
5959
// HOW TO USE SECTION ENDS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= readString()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
`Serial.readString()` reads characters from the serial buffer into a string. The function terminates if it times out (see link:setTimeout{ext-relative}[setTimeout()]).
16+
17+
This function is part of the Stream class, and is called by any class that inherits from it (Wire, Serial, etc). See the link:stream{ext-relative}[Stream class] main page for more information.
18+
19+
[%hardbreaks]
20+
21+
22+
[float]
23+
=== Syntax
24+
`Serial.readString()`
25+
26+
27+
[float]
28+
=== Parameters
29+
Nothing
30+
31+
[float]
32+
=== Returns
33+
A string read from the serial buffer
34+
35+
--
36+
// OVERVIEW SECTION ENDS
37+
38+
39+
40+
41+
// HOW TO USE SECTION STARTS
42+
[#howtouse]
43+
--
44+
45+
[float]
46+
=== See also
47+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
48+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
49+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
50+
[role="language"]
51+
* #LANGUAGE# link:../serial{ext-relative}[Serial] +
52+
* #LANGUAGE# link:begin{ext-relative}[begin()] +
53+
* #LANGUAGE# link:end{ext-relative}[end()] +
54+
* #LANGUAGE# link:available{ext-relative}[available()] +
55+
* #LANGUAGE# link:read{ext-relative}[read()] +
56+
* #LANGUAGE# link:peek{ext-relative}[peek()] +
57+
* #LANGUAGE# link:flush{ext-relative}[flush()] +
58+
* #LANGUAGE# link:print{ext-relative}[print()] +
59+
* #LANGUAGE# link:println{ext-relative}[println()] +
60+
* #LANGUAGE# link:write{ext-relative}[write()] +
61+
* #LANGUAGE# link:serialEvent{ext-relative}[SerialEvent()] +
62+
* #LANGUAGE# link:../Stream/streamParsefloat{ext-relative}[Stream.parseFloat()]
63+
64+
--
65+
// HOW TO USE SECTION ENDS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= readStringUntil()
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
`readStringUntil()` reads characters from the serial buffer into a string. The function terminates if it times out (see link:setTimeout{ext-relative}[setTimeout()]).
16+
17+
This function is part of the Stream class, and is called by any class that inherits from it (Wire, Serial, etc). See the link:stream{ext-relative}[Stream class] main page for more information.
18+
19+
[%hardbreaks]
20+
21+
22+
[float]
23+
=== Syntax
24+
`Serial.readString(terminator)`
25+
26+
27+
[float]
28+
=== Parameters
29+
`terminator` : the character to search for (`char`)
30+
31+
[float]
32+
=== Returns
33+
The entire string read from the serial buffer, until the terminator character is detected
34+
35+
--
36+
// OVERVIEW SECTION ENDS
37+
38+
39+
40+
41+
// HOW TO USE SECTION STARTS
42+
[#howtouse]
43+
--
44+
45+
[float]
46+
=== See also
47+
// Link relevant content by category, such as other Reference terms (please add the tag #LANGUAGE#),
48+
// definitions (please add the tag #DEFINITION#), and examples of Projects and Tutorials
49+
// (please add the tag #EXAMPLE#) ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
50+
[role="language"]
51+
* #LANGUAGE# link:../serial{ext-relative}[Serial] +
52+
* #LANGUAGE# link:begin{ext-relative}[begin()] +
53+
* #LANGUAGE# link:end{ext-relative}[end()] +
54+
* #LANGUAGE# link:available{ext-relative}[available()] +
55+
* #LANGUAGE# link:read{ext-relative}[read()] +
56+
* #LANGUAGE# link:peek{ext-relative}[peek()] +
57+
* #LANGUAGE# link:flush{ext-relative}[flush()] +
58+
* #LANGUAGE# link:print{ext-relative}[print()] +
59+
* #LANGUAGE# link:println{ext-relative}[println()] +
60+
* #LANGUAGE# link:write{ext-relative}[write()] +
61+
* #LANGUAGE# link:serialEvent{ext-relative}[SerialEvent()] +
62+
* #LANGUAGE# link:../Stream/streamParsefloat{ext-relative}[Stream.parseFloat()]
63+
64+
--
65+
// HOW TO USE SECTION ENDS

Language/Functions/Communication/Stream/streamParseInt.adoc

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
[float]
1414
=== Description
15-
`parseInt()` returns the first valid (long) integer number from the current position. Initial characters that are not integers (or the minus sign) are skipped. `parseInt()` is terminated by the first character that is not a digit.
15+
`parseInt()` returns the first valid (long) integer number from the current position. Initial characters that are not integers (or the minus sign) are skipped.
16+
17+
In particular:
18+
19+
* Initial characters that are not digits or a minus sign, are skipped; +
20+
* Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read; +
21+
* If no valid digits were read when the time-out (see link:setTimeout{ext-relative}[Stream.setTimeout()]) occurs, 0 is returned;
1622

1723
This function is part of the Stream class, and is called by any class that inherits from it (Wire, Serial, etc). See the link:stream{ext-relative}[Stream class] main page for more information.
1824
[%hardbreaks]
@@ -22,16 +28,19 @@ This function is part of the Stream class, and is called by any class that inher
2228
=== Syntax
2329
`stream.parseInt(list)`
2430

31+
`stream.parseInt(''list', char skipchar')`
2532

2633
[float]
2734
=== Parameters
2835
`stream` : an instance of a class that inherits from Stream.
2936

3037
`list` : the stream to check for ints (`char`)
3138

39+
`skipChar`: used to skip the indicated char in the search. Used for example to skip thousands divider.
40+
3241
[float]
3342
=== Returns
34-
`int`
43+
`long`
3544

3645
--
3746
// OVERVIEW SECTION ENDS

0 commit comments

Comments
 (0)