Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB CDC/ACM: hangs on non implemented optional class-specific request codes in Win10 #739

Open
kimstik opened this issue Feb 6, 2024 · 2 comments

Comments

@kimstik
Copy link

kimstik commented Feb 6, 2024

I have my own minimalistic implementation of a USB CDC device stack.
It does not implement any optional (as per ACM) class-specific request codes such as GET_LINE_CODING.
The caps fields of ACM Functional Descriptor are set to zero accordingly.

There are no visible problems under Linux. Under Win10 it only works with the Bray terminal.

Simple code

import serial
ser = serial.Serial('com3')

hangs with error

  File "C:\test\test.py", line 2, in <module>
    ser = serial.Serial('com3')
  File "C:\Python\lib\site-packages\serial\serialwin32.py", line 33, in __init__
    super(Serial, self).__init__(*args, **kwargs)
  File "C:\Python\lib\site-packages\serial\serialutil.py", line 244, in __init__
    self.open()
  File "C:\Python\lib\site-packages\serial\serialwin32.py", line 80, in open
    self._reconfigure_port()
  File "C:\Python\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
    raise SerialException(
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)

image

@kimstik
Copy link
Author

kimstik commented Feb 7, 2024

Since the system is throwing unexpected requests, it looks like the problem is a little deeper in the stack.

In the code of serialwin32.py file, the GetCommState return code is not checked.
But the return of SetCommState is checked and returns 0.
Is it appropriate to throw SerialException in this case?

@kimstik
Copy link
Author

kimstik commented Feb 7, 2024

It seems "USB/CDC with unimplemented optional features" issue is know quite long time:
SetCommState() returns FALSE
GetLastError() returns 31 which is "A device attached to the system is not functioning".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant