'Output the given byte string over the serial port. Can block if the
connection is blocked. May raise SerialException if the connection is
closed.'

def write(self, data):

    if (not self.is_open):
        raise portNotOpenError
    try:
        self._socket.sendall(to_bytes(data))
    except socket.error as e:
        raise SerialException('socket    connection    failed:    {}'.format(e))
    return len(data)
