BSTR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aleksandar Cikota

    #1

    BSTR

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

    Error message:[color=blue]
    > File "S:MaxImmaxim.p y", line 19, in ?
    > CCDCamera.SaveI mage('C:/1.fit')
    > File "C:ProgrammePyt hon24Libsite-
    > packageswin32co mclientdynamic. py", line 491, in __getattr__
    > raise pythoncom.com_e rror, details
    > com_error: (-2147352567, 'Ausnahmefehler aufgetreten.',
    > (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None)[/color]


    Here is the answer that we recieved from Diffraction Limited:
    ---------
    For CCDCamera.SaveI mage, '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_BYRE F.

    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('MaxI m.CCDCamera')
    CCDCamera.LinkE nabled = True
    if CCDCamera.LinkE nabled == False:
    print 'Failed to start camera.'
    exp = int(raw_input(' Exposition[sec]: '))
    CCDCamera.Expos e(exp, 1, 0)
    while CCDCamera.Image Ready == False:
    time.sleep
    print 'Done'
    time.sleep(3)
    CCDCamera.SaveI mage('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


Working...