title: Coherent FieldMax2 ActiveX .dll works in LabView but not in Python
body: <p>I'm working on integrating a Coherent FieldMax2 (an optical power meter connected via USB) into an automated measurement program in Python. The only information the vendor provides are LabView examples (.vi's) and an ActiveX .dll (according to the documentation available).</p>
  <p>From the LabView examples I can access the various functions available in the .dll.
  So far I've tried variations of the following approach to connect to the power meter, in just the same way as in the LabView examples available:</p>
  <pre><code>import ctypes
  
  mydll =ctypes.WinDLL(&quot;C:\Windows\System32\FieldMax2Lib.dll&quot;)
  
  py_connect=mydll.fm2LibOpenDriver
  py_connect.restype=c_int32
  py_connect.argtypes=[c_int16]
  response=py_connect(0) # arg 0 = 1 available power meter
  print(response)
  </code></pre>
  <p>However, no matter how I go about it, I simply get the response '-1' which according to the limited documentation means the .dll-file cannot find any power meter.
  The LabView block scheme can be found</p>
  <p><a href="https://i.stack.imgur.com/APXAR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/APXAR.png" alt="LabView block scheme" /></a></p>
  <p>I'd greatly appreciate any suggestions on how to go about the problem</p>