Until recently I was happily using Win 7 + Python.x and PySerial.
Lately I upgraded to Win 10, now I have a problem running some Python serial code, which I had working on Win 7.
However, I can even run the simple example from: Full examples of using pySerial package
What I get is the same error, on all PySerial related codes:
Traceback (most recent call last):
File ".\t.py", line 10, in <module>
bytesize=serial.SEVENBITS
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 31, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "C:\Python37\lib\site-packages\serial\serialutil.py", line 240, in __init__
self.open()
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 78, in open
self._reconfigure_port()
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
'Original message: {!r}'.format(ctypes.WinError()))
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: OSError(22, 'The parameter is incorrect.', None, 87)
However, I found out that the reason for this is the exception raised by a call win32.SetCommState(self._port_handle, ctypes.byref(comDCB)):
from serialwin32.py
This call returns 0, indicating something is wrong, but when I comment it out, then I can get the serial communication working again.
Anyone else experienced this?
with serial.Serial("COM4", baudrate=115200, timeout=1) as ser:
– Teammate