MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / read

Method read

src/ext/makerbot_pyserial/serialjava.py:152–166  ·  view source on GitHub ↗

Read size bytes from the serial port. If a timeout is set it may return less characters as requested. With no timeout it will block until the requested number of bytes is read.

(self, size=1)

Source from the content-addressed store, hash-verified

150 return self._instream.available()
151
152 def read(self, size=1):
153 """Read size bytes from the serial port. If a timeout is set it may
154 return less characters as requested. With no timeout it will block
155 until the requested number of bytes is read."""
156 if not self.sPort: raise portNotOpenError
157 read = bytearray()
158 if size > 0:
159 while len(read) < size:
160 x = self._instream.read()
161 if x == -1:
162 if self.timeout >= 0:
163 break
164 else:
165 read.append(x)
166 return bytes(read)
167
168 def write(self, data):
169 """Output the given string over the serial port."""

Callers 1

serialjava.pyFile · 0.45

Calls 2

bytearrayClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected