Communicating with serial port

Werner Schiendl ws-news at gmx.at
Fri Mar 2 10:29:21 EST 2001


last time i needed serial comm's on Windows (NT in my case) i opened the
interface as follows

        import win32file

        portname = 'COM2'
        paramstring = "baud=38400 parity=N data=8 stop=1 xon=on"
        self._hFile = win32file.CreateFile(portname, win32file.GENERIC_READ
| win32file.GENERIC_WRITE,
                                           0, None, win32file.OPEN_ALWAYS,
0,0)
        if paramstring:
            dcb = win32file.GetCommState(self._hFile)
            win32file.BuildCommDCB(paramstring, dcb)
            win32file.SetCommState(self._hFile, dcb)

afterwards you can use win32file.WriteFile and win32file.ReadFile to access
the port
dont forget to close the handle with win32file.CloseHandle

i'm afraid i do not know your library
but maybe you come along with that
there is also a demo that comes with the win extensions for serial comm's

hth
werner


Peter Blom <pet-blo at online.no> wrote in message
news:ndNn6.5161$t21.152593 at news3.oke.nextra.no...
> I shall write a python program for downloading data from a memory card in
a
> measuring instrument, via a serial port.
> For this purpose, I have downloaded SioModule.zip - a serial comm
extension
> for windows 95, upgraded to Python 1.5.1.
> This does not seem to work - when importing the module 'serial.py', my
> system hangs (Windows 98, Activestate Python 2.0).
> Could anybody give a hint?
>
> Peter (a newbie)
>
>





More information about the Python-list mailing list