You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bulk transfer is complete when the endpoint does one of the following:
• Has transferred exactly the amount of data expected
• Transfers a packet with a payload size less than wMaxPacketSize or transfers a zero-length packet
When a bulk transfer is complete, the Host Controller retires the current IRP and advances to the next IRP.
If a data payload is received that is larger than expected, all pending bulk IRPs for that endpoint will be
aborted/retired.
If a ZLP is not sent, the device layer could wait for more data.
A workaround for Windows is in pyserialwin32.py:
defwrite(self, data):
"""Output the given byte string over the serial port."""ifnotself.is_open:
raisePortNotOpenError()
#~ if not isinstance(data, (bytes, bytearray)):#~ raise TypeError('expected %s or bytearray, got %s' % (bytes, type(data)))# convert data (needed in case of memoryview instance: Py 3.1 io lib), ctypes doesn't like memoryviewdata=to_bytes(data)
#~ win32event.ResetEvent(self._overlapped_write.hEvent)n=win32.DWORD()
ifdata:
success=win32.WriteFile(self._port_handle, data, len(data), ctypes.byref(n), self._overlapped_write)
else:
success=win32.WriteFile(self._port_handle, 0, 0, ctypes.byref(n), self._overlapped_write)
ifself._write_timeout!=0: # if blocking (None) or w/ write timeout (>0)ifnotsuccessandwin32.GetLastError() notin (win32.ERROR_SUCCESS, win32.ERROR_IO_PENDING):
raiseSerialException("WriteFile failed ({!r})".format(ctypes.WinError()))
# Wait for the write to complete.#~ win32.WaitForSingleObject(self._overlapped_write.hEvent, win32.INFINITE)win32.GetOverlappedResult(self._port_handle, self._overlapped_write, ctypes.byref(n), True)
ifwin32.GetLastError() ==win32.ERROR_OPERATION_ABORTED:
returnn.value# canceled IO is no errorifn.value!=len(data):
raiseSerialTimeoutException('Write timeout')
returnn.valueelse:
errorcode=win32.ERROR_SUCCESSifsuccesselsewin32.GetLastError()
iferrorcodein (win32.ERROR_INVALID_USER_BUFFER, win32.ERROR_NOT_ENOUGH_MEMORY,
win32.ERROR_OPERATION_ABORTED):
return0eliferrorcodein (win32.ERROR_SUCCESS, win32.ERROR_IO_PENDING):
# no info on true length provided by OS function in async modereturnlen(data)
else:
raiseSerialException("WriteFile failed ({!r})".format(ctypes.WinError()))
The text was updated successfully, but these errors were encountered:
From USB 2.0 specification:
If a ZLP is not sent, the device layer could wait for more data.
A workaround for Windows is in
pyserialwin32.py
:The text was updated successfully, but these errors were encountered: