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

Method read

src/ext/makerbot_pyserial/serialcli.py:152–167  ·  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._port_handle.BytesToRead
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._port_handle: raise portNotOpenError
157 # must use single byte reads as this is the only way to read
158 # without applying encodings
159 data = bytearray()
160 while size:
161 try:
162 data.append(self._port_handle.ReadByte())
163 except System.TimeoutException, e:
164 break
165 else:
166 size -= 1
167 return bytes(data)
168
169 def write(self, data):
170 """Output the given string over the serial port."""

Callers

nothing calls this directly

Calls 2

bytearrayClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected