Output the given string over the serial port.
(self, data)
| 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.""" |
no test coverage detected