List Info

Thread: BSTR




BSTR
user name
2006-04-13 21:21:26
 Hi all,

I'm beginner in Python and need help. I'm writing software for a robotic
telescope. For CCD camera control we use MaxIm DL (Diffraction Limited). I
have a problem with CCDCamera.SaveImage.
 
Here is the code (Python):

import win32com.client, time
CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')
CCDCamera.LinkEnabled = True
if CCDCamera.LinkEnabled == False:
     print 'Failed to start camera.'
exp = int(raw_input('Exposition[sec]: '))
CCDCamera.Expose(exp, 1, 0)
while CCDCamera.ImageReady == False:
     time.sleep
print 'Done'
time.sleep(3)
CCDCamera.SaveImage('C:/1.fit')

Error message:
>    File "S:MaxImmaxim.py", line 19, in ?
>      CCDCamera.SaveImage('C:/1.fit')
>    File "C:ProgrammePython24Libsite-
>; packageswin32comclientdynamic.py", line 491, in __getattr__
;     raise pythoncom.com_error, details
> com_error: (-2147352567, 'Ausnahmefehler aufgetreten.',
> (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None)


Here is the answer that we recieved from Diffraction Limited:
---------
For CCDCamera.SaveImage, 'Invalid Input' is reported only if the argument is
not of an acceptable type. ; As you are probably aware from looking at the
type library, the filename argument is declared as a variant.  What the type
library doesn't tell you is that the variant must be either a BSTR (unicode
string with header) or a reference to a BSTR. ; Specifically, the 'vt' member
of the VARIANT must be either VT_BSTR or VT_BSTR|VT_BYREF.

Does python provide any way of influencing how arguments for COM methods are
created?  If so, you may be able to get this to work. ; It may be as simple
as assigning the string to a variable name instead of passing it as a
literal, or perhaps there's something equivalent to a C++ cast operator or a
VB 'type' function (CInt, CStr, etc.).

This problem is likely to affect any MaxIm DL automation method that takes a
string as an argument.
---------



The question is, how to convert a String in a BSTR (unicodestring with
header)?


For your prompt reply, I say thank you in advance.


Best regards,
Aleksandar Cikota

 
 
 
-----------------------------------------
Aleksandar Cikota
SkyPe: Aleksandar_Cikota
BSTR
user name
2006-04-13 22:35:08
> The question is, how to convert a String in a BSTR
(unicodestring with
> header)?

Python will *always* (unless an object's typelib indicated
otherwise) pass a
VT_BSTR when a string literal is specified.  I'm afraid I
can't speculate on
what the problem may otherwise be.

Mark

_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )