【问题标题】:Coherent FieldMax2 ActiveX .dll works in LabView but not in PythonCoherent FieldMax2 ActiveX .dll 在 LabView 中有效,但在 Python 中无效
【发布时间】:2021-08-28 06:40:36
【问题描述】:

我正在努力将 Coherent FieldMax2(通过 USB 连接的光功率计)集成到 Python 中的自动测量程序中。供应商提供的唯一信息是 LabView 示例 (.vi) 和 ActiveX .dll(根据可用的文档)。

从 LabView 示例中,我可以访问 .dll 中可用的各种功能。 到目前为止,我已经尝试了以下方法的变体来连接到功率计,方法与可用的 LabView 示例中的方法相同:

import ctypes

mydll =ctypes.WinDLL("C:\Windows\System32\FieldMax2Lib.dll")

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)

但是,无论我如何处理,我只是得到响应“-1”,根据有限的文档,这意味着 .dll 文件找不到任何功率计。 LabView分块方案可以找到

对于如何解决问题的任何建议,我将不胜感激

【问题讨论】:

    标签: python python-3.x dll labview


    【解决方案1】:

    我无法重现此问题,我的版本是:
    sys.version : v3.7.1rc2 [MSC v.1914 64 位 (AMD64)]
    ctypes.__version__ : 1.1.0
    FieldMaxII : v3.3.2.9_rc1
    我的代码正在使用安装程序目录中的 dll:

    import ctypes as c
    
    mydll = c.WinDLL(r'C:\Program Files (x86)\Coherent\FieldMaxII PC\Drivers\Win10\FieldMax2Lib\x64\FieldMax2Lib.dll')
    
    py_connect=mydll.fm2LibOpenDriver
    py_connect.restype=c.c_int32
    py_connect.argtypes=[c.c_int16]
    response=py_connect(0) # arg 0 = 1 available power meter
    print(response)
    

    并且返回“0”,FieldMaxII 的额外通信/读出也是可能的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-18
      • 1970-01-01
      • 2018-11-01
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 2019-03-20
      • 1970-01-01
      相关资源
      最近更新 更多