How to get PySerial to accept 921600 Baud rate

情到浓时终转凉″ 提交于 2019-12-14 03:00:28

问题


We have a motor controller that implements a USB->Virtual COM port that has a fixed baud rate of 921600 (the manual even states that the baud rate cannot be changed). I found that if I use a terminal program like Terminal, I can pass the custom baud rate of 921600 and communicate with the instrument with no issues. We are using Windows 7 pro, 64-bit version.

However, when I tried to do this in PySerial (v.2.7) using Python 2.7.10 (32 bit) like this:

import serial
ser = serial.Serial("COM3",921600)

I always encounter error saying that parameter is incorrect.

File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 202, in _reconfigurePort raise ValueError("Cannot configure port, some setting was wrong. Original message: %r" % ctypes.WinError()) ValueError: Cannot configure port, some setting was wrong. Original message: WindowsError(87, 'The parameter is incorrect.')

The valid Baudrates seem to be the one listed in serialwin32.py

BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
             9600, 19200, 38400, 57600, 115200)

When I use any of the baud rate from the list there I can open the serial port (but not necessary able to communicate with the instrument).

Just adding 921600 hundred to this list in serialwin32.py doesn't do anything. I have searched several forums and websites and so far nobody seems to have an answer on how to set this higher baud rate in Windows. The baudrate above 115200 used to be unreliable in older versions of Windows, but I assume that Windows 7 should be able to handle a much higher transfer rate now especially that many USB IC like FTDI and CH430 can handle a much higher baud rate than 115200.

Does anyone know a way to get pySerial to accept a higher baudrate than 115200 in Windows?


回答1:


I try 921600 and haven't any problem.

Your adapter not supported high speed rs232.

You need buy a CP21XX or equal converter.

Moxa or Lantronix is good brand(test & using).

Try on: win7x64,Python2.7x32



来源:https://stackoverflow.com/questions/31420390/how-to-get-pyserial-to-accept-921600-baud-rate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!