how to pass by reference??

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Feb 3 23:00:03 EST 2002


----- Original Message -----
From: "Spencer Doidge" <spencer at spencerdoidge.com>


> Thanks for all your patient help, Chris. Now I have run into an apparent
> contradiction:
>
> This is a method within SerialPort_win.py from Isaac Barona's
site-package,
> modified by myself because his 2nd ReadFile(..) parameter was an integer,
> and I want the buffer instead. I need to see what was read...

[[ code block omitted ]]

> After I have run the script that defines read(...), the other methods
> defined by the script work fine, but with read(..) I get this result:
>
> >>> tty = SerialPort("COM1",None,None,None)
> >>> b = [0] * 256
> >>> tty.read(1,b)
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File "C:\Python22\Lib\site-packages\MyScripts\MySerialPort_win.py", line
> 238, in read
>     hr, bfr = ReadFile(self.__handle, bfr, overlapped)
> TypeError: Second param must be an integer or a buffer object
>
> If bfr isn't a "buffer object," then what is?

According to the help file, you need a PyOVERLAPPEDReadBuffer object here,
whatever that is... Mark Hammond, are you out there?

I've lost track; why are you passing in a buffer?  Don't you get the bytes
read as the second return value from ReadFile?  Have you read the help
file yet?







More information about the Python-list mailing list