#3 Handling VARIANT [in,out] arrays

open
nobody
None
5
2005-07-25
2005-07-25
Anonymous
No

How is such a COM-Function called from Python?

[id(0x000003f7), helpstring("Call the VI as
a subVI"), helpcontext(0x000029a6)]
void Call(
[in, out, optional]
VARIANT* paramNames,
[in, out, optional]
VARIANT* paramVals);

I tried the following:
VARIANT5 = VARIANT *5
parmNames = VARIANT5()
v=VARIANT()
v.value = c_char_p("hostname42")
parmNames[0]=v
v=VARIANT()
v.value = "port"
parmNames[1]=v
v=VARIANT()
v.value = "Model VI Path"
parmNames[2]=v
v=VARIANT()
v.value = "Model DLL Path"
parmNames[3]=v
v=VARIANT()
v.value = "MDL_Path"
parmNames[4]=v
result = VARIANT5()
for i in range(0,4):
v=VARIANT()
result[i]=v

self.initVI.Call(byref(parmNames),byref(result))
However i got the following exception:
Traceback (most recent call last):
File
"c:\Programme\eclipse\plugins\org.python.pydev.debug_0.9.2\pysrc\pydevd.py",
line 811, in ?
debugger.run(setup['file'], None, None)
File
"c:\Programme\eclipse\plugins\org.python.pydev.debug_0.9.2\pysrc\pydevd.py",
line 748, in run
execfile(file, globals, locals);
File
"D:\compacthilpython\pythonInterface\LabVIEWInterfaceTest.py",
line 38, in ?
lvi.initialize();
File
"D:\compacthilpython\pythonInterface\LabVIEWInterface.py",
line 266, in initialize
self.initVI.Call(byref(parmNames),byref(result))
File
"C:\Python23\Lib\site-packages\ctypes\com\client.py",
line 383, in __call__
parms = self._build_parms(*args, **kw)
File
"C:\Python23\Lib\site-packages\ctypes\com\client.py",
line 369, in _build_parms
rgvarg[i].value = a
File
"C:\Python23\Lib\site-packages\ctypes\com\automation.py",
line 404, in _set_value
raise TypeError, "don't know how to store %r in a
VARIANT" % value
TypeError: don't know how to store <cparam 'P'
(00aa2e98)> in a VARIANT
Exception exceptions.AttributeError: "'NoneType' object
has no attribute 'currentThread'" in <bound method
_Cleaner.__del__ of <ctypes.com._Cleaner object at
0x00973C70>> ignored

What did I make wrong?

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks