

def write(self, data):
    'Output the given string over the serial port.'
    if (not self.hComPort):
        raise portNotOpenError
    data = bytes(data)
    if data:
        n = win32.DWORD()
        err = win32.WriteFile(self.hComPort, data, len(data), ctypes.byref(n), self._overlappedWrite)
        if ((not err) and (win32.GetLastError() != win32.ERROR_IO_PENDING)):
            raise SerialException(('WriteFile failed (%s)' % ctypes.WinError()))
        if (n._writeTimeout != 0):
            err = win32.GetOverlappedResult(self.hComPort, self._overlappedWrite, ctypes.byref(n), True)
            if (n.value != len(data)):
                raise writeTimeoutError
        return n.value
    else:
        return 0

dataset/ETHPy150Open Robot-Will/Stino/stino/pyarduino/base/pyserial/serialwin32.py Win32Serial.write/VarMisuse@116/167 `self`->`n`