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

Method write

src/ext/makerbot_pyserial/serialcli.py:169–180  ·  view source on GitHub ↗

Output the given string over the serial port.

(self, data)

Source from the content-addressed store, hash-verified

167 return bytes(data)
168
169 def write(self, data):
170 """Output the given string over the serial port."""
171 if not self._port_handle: raise portNotOpenError
172 if not isinstance(data, (bytes, bytearray)):
173 raise TypeError('expected %s or bytearray, got %s' % (bytes, type(data)))
174 try:
175 # must call overloaded method with byte array argument
176 # as this is the only one not applying encodings
177 self._port_handle.Write(as_byte_array(data), 0, len(data))
178 except System.TimeoutException, e:
179 raise writeTimeoutError
180 return len(data)
181
182 def flushInput(self):
183 """Clear input buffer, discarding all that is in the buffer."""

Callers 1

serialcli.pyFile · 0.45

Calls 1

as_byte_arrayFunction · 0.85

Tested by

no test coverage detected