BSTR

A

Aleksandar Cikota

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.

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.
---------


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')



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top