<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def write(self, data, timeout_s=None):
        '''
        Write to serial port.

        Waits for serial connection to be established before writing.

        Parameters
        ----------
        data : str or bytes
            Data to write to serial port.
        timeout_s : float, optional
            Maximum number of seconds to wait for serial connection to be
            established.

            By default, block until serial connection is ready.
        '''
        self.connected.wait(timeout_s)
        self.protocol.transport.write(data)