[python-win32] win32file.SetupComm Error Using PySerial in new Python 2.5.2 installation on 32 bit XP

Tim Roberts timr at probo.com
Mon Mar 10 19:14:08 CET 2008

Ron Jackson wrote:
> I am setting up Python on a newly upgraded computer (AMD 64 X2 dual 
> core) running 32 bit XP home. I installed the following packages:
> ...
> Traceback (most recent call last):
> ...
>    File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 57, 
> in open
>      win32file.SetupComm(self.hComPort, 4096, 4096)
> error: (1, 'SetupComm', 'Incorrect function.')
> Lines 56-57 in serialwin32.py are:
>          # Setup a 4k buffer
>          win32file.SetupComm(self.hComPort, 4096, 4096)
> This works just fine on my laptop computer, which was set up some time 
> ago and has a slightly older version of Python.
> So, why am I getting this error? I don't think PySerial has changed in a 
> long time, but was there some recent change in pywin32? Some change in 
> Python 2.5.2 that would account for this error? Something in the 
> installation that I haven't properly done?

Are the serial ports on your AMD 64X2 actually enabled in the BIOS?  
"Incorrect function" usually means that the system sent a request into 
the serial driver, and the particular request it sent is not one that 
the driver supports.  If the serial ports were disabled in the BIOS (and 
many machines are so configured these days), or if you had a serial 
mouse in that port (which almost no one has any more), or if you were 
talking to a USB-to-serial converter, this kind of thing can happen.

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the python-win32 mailing list