Skip to content

Commit cf6daa0

Browse files
committed
docs: Explicitly specify behavior of UART stream protocol methods on timeout.
1 parent 4a9c60c commit cf6daa0

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

docs/library/machine.UART.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,34 @@ Methods
9898

9999
Read characters. If ``nbytes`` is specified then read at most that many bytes.
100100

101-
Return value: a bytes object containing the bytes read in. Returns ``b''``
101+
Return value: a bytes object containing the bytes read in. Returns ``None``
102102
on timeout.
103103

104104
.. method:: uart.readall()
105105

106106
Read as much data as possible.
107107

108-
Return value: a bytes object.
108+
Return value: a bytes object or ``None`` on timeout.
109109

110110
.. method:: uart.readinto(buf[, nbytes])
111111

112112
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
113113
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
114114

115-
Return value: number of bytes read and stored into ``buf``.
115+
Return value: number of bytes read and stored into ``buf`` or ``None`` on
116+
timeout.
116117

117118
.. method:: uart.readline()
118119

119120
Read a line, ending in a newline character.
120121

121-
Return value: the line read.
122+
Return value: the line read or ``None`` on timeout.
122123

123124
.. method:: uart.write(buf)
124125

125126
Write the buffer of bytes to the bus.
126127

127-
Return value: number of bytes written.
128+
Return value: number of bytes written or ``None`` on timeout.
128129

129130
.. method:: uart.sendbreak()
130131

docs/library/pyb.UART.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ Methods
119119
*Note:* for 9 bit characters each character takes two bytes, ``nbytes`` must
120120
be even, and the number of characters is ``nbytes/2``.
121121

122-
Return value: a bytes object containing the bytes read in. Returns ``b''``
122+
Return value: a bytes object containing the bytes read in. Returns ``None``
123123
on timeout.
124124

125125
.. method:: uart.readall()
126126

127127
Read as much data as possible.
128128

129-
Return value: a bytes object.
129+
Return value: a bytes object or ``None`` on timeout.
130130

131131
.. method:: uart.readchar()
132132

@@ -139,13 +139,14 @@ Methods
139139
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
140140
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
141141

142-
Return value: number of bytes read and stored into ``buf``.
142+
Return value: number of bytes read and stored into ``buf`` or ``None`` on
143+
timeout.
143144

144145
.. method:: uart.readline()
145146

146147
Read a line, ending in a newline character.
147148

148-
Return value: the line read.
149+
Return value: the line read or ``None`` on timeout.
149150

150151
.. method:: uart.write(buf)
151152

@@ -156,7 +157,7 @@ Methods
156157
bytes are used for each character (little endian), and ``buf`` must contain
157158
an even number of bytes.
158159

159-
Return value: number of bytes written.
160+
Return value: number of bytes written or ``None`` on timeout.
160161

161162
.. method:: uart.sendbreak()
162163

0 commit comments

Comments
 (0)