Skip to content

Commit 401037a

Browse files
committed
Change stop to False and throw error if True.
It will be removed from libraries and then from here. See adafruit/circuitpython#2082 for details.
1 parent b9280af commit 401037a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

adafruit_bus_device/i2c_device.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,11 @@ def write(self, buf, **kwargs):
113113

114114
#pylint: disable-msg=too-many-arguments
115115
def write_then_readinto(self, out_buffer, in_buffer, *,
116-
out_start=0, out_end=None, in_start=0, in_end=None, stop=True):
116+
out_start=0, out_end=None, in_start=0, in_end=None, stop=False):
117117
"""
118118
Write the bytes from ``out_buffer`` to the device, then immediately
119119
reads into ``in_buffer`` from the device. The number of bytes read
120120
will be the length of ``in_buffer``.
121-
Transmits a stop bit after the write, if ``stop`` is set.
122121
123122
If ``out_start`` or ``out_end`` is provided, then the output buffer
124123
will be sliced as if ``out_buffer[out_start:out_end]``. This will
@@ -136,21 +135,23 @@ def write_then_readinto(self, out_buffer, in_buffer, *,
136135
:param int out_end: Index to read up to but not include
137136
:param int in_start: Index to start writing at
138137
:param int in_end: Index to write up to but not include
139-
:param bool stop: If true, output an I2C stop condition after the buffer is written
138+
:param bool stop: Deprecated
140139
"""
141140
if out_end is None:
142141
out_end = len(out_buffer)
143142
if in_end is None:
144143
in_end = len(in_buffer)
144+
if stop:
145+
raise ValueError("Stop must be False. Use writeto instead.")
145146
if hasattr(self.i2c, 'writeto_then_readfrom'):
146147
# In linux, at least, this is a special kernel function call
147148
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
148149
out_start=out_start, out_end=out_end,
149-
in_start=in_start, in_end=in_end, stop=stop)
150+
in_start=in_start, in_end=in_end)
150151

151152
else:
152153
# If we don't have a special implementation, we can fake it with two calls
153-
self.write(out_buffer, start=out_start, end=out_end, stop=stop)
154+
self.write(out_buffer, start=out_start, end=out_end, stop=False)
154155
self.readinto(in_buffer, start=in_start, end=in_end)
155156

156157
#pylint: enable-msg=too-many-arguments

0 commit comments

Comments
 (0)