[python-win32] Error message....
Tim Roberts
timr at probo.com
Wed Dec 21 22:31:26 CET 2005
On Tue, 20 Dec 2005 11:05:12 -0800, I wrote:
>On Mon, 19 Dec 2005 08:58:17 -0500, eric.powell at srs.gov wrote:
>
>
>>I am trying to use the OSISoft PI (Plant Information) API to collect data
>>about processes within our facility, however, when I try to connect to the
>>PI server using their API calls, I get the following error"
>>
>>
>>
>>
>>>>>>>>from ctypes import *
>>>>>>>>PiAPI=windll.piapi32
>>>>>>>>valid = 0
>>>>>>>>status = PiAPI.piut_setservernode(servername)
>>>>>>>>status = pi.piut_login("pidemo", "dorazio", valid
>>>>>>>>
>>Traceback (most recent call last):
>> File "<pyshell#10>", line 1, in ?
>> status = pi.piut_login("pidemo", "dorazio", valid)
>>WindowsError: exception: access violation writing 0x00000000
>>
>>
>>I THINK this means we are not licensed to make API calls against this dll,
>>but I am not sure.
>>
>No, that's not what it means. "Access violation" is an Intel processor
>term that mean you tried to access an invalid memory address. It is
>also called "general protection fault". In this particular instance, it
>tried to write to a null pointer.
>
>What is "servername"? What is "pi"? Neither is defined here. Is it
>possible that the third parameter to piut_login is an OUTPUT parameter
>-- that it is returning a "valid" state to you? In that case, you have
>to use ctypes magic to declare that the parameter is a pointer:
>
> pi.piut_login( "pidemo", "dorazio", ctypes.byref( valid ) )
>
We continued this discussion off-list. Had either one of us taken the
time to look at the examples, we would have seen that the proper answer was:
valid = ctypes.c_int( 0 )
pi.piut_login( "pidemo", "dorazio", ctypes.byref( valid ) )
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32
mailing list