parameters: (self, data)
return_statement: return len(data)
docstring: Output the given string over the serial port.
docstring_summary: Output the given string over the serial port.
docstring_tokens: Output the given string over the serial port .
function: def write(self, data):
          """Output the given string over the serial port."""
          if not self._isOpen: raise portNotOpenError
          d = to_bytes(data)
          tx_len = len(d)
          if self._writeTimeout is not None and self._writeTimeout > 0:
              timeout = time.time() + self._writeTimeout
          else:
              timeout = None
          while tx_len > 0:
              try:
                  n = os.write(self.fd, d)
                  if timeout:
                      # when timeout is set, use select to wait for being ready
                      # with the time left as timeout
                      timeleft = timeout - time.time()
                      if timeleft < 0:
                          raise writeTimeoutError
                      _, ready, _ = select.select([], [self.fd], [], timeleft)
                      if not ready:
                          raise writeTimeoutError
                  else:
                      # wait for write operation
                      _, ready, _ = select.select([], [self.fd], [], None)
                      if not ready:
                          raise SerialException('write failed (select)')
                  d = d[n:]
                  tx_len -= n
              except OSError, v:
                  if v.errno != errno.EAGAIN:
                      raise SerialException('write failed: %s' % (v,))
          return len(data)
function_tokens: def write ( self , data ) : if not self . _isOpen : raise portNotOpenError d = to_bytes ( data ) tx_len = len ( d ) if self . _writeTimeout is not None and self . _writeTimeout > 0 : timeout = time . time ( ) + self . _writeTimeout else : timeout = None while tx_len > 0 : try : n = os . write ( self . fd , d ) if timeout : # when timeout is set, use select to wait for being ready # with the time left as timeout timeleft = timeout - time . time ( ) if timeleft < 0 : raise writeTimeoutError _ , ready , _ = select . select ( [ ] , [ self . fd ] , [ ] , timeleft ) if not ready : raise writeTimeoutError else : # wait for write operation _ , ready , _ = select . select ( [ ] , [ self . fd ] , [ ] , None ) if not ready : raise SerialException ( 'write failed (select)' ) d = d [ n : ] tx_len -= n except OSError , v : if v . errno != errno . EAGAIN : raise SerialException ( 'write failed: %s' % ( v , ) ) return len ( data )