【发布时间】:2016-09-07 18:16:53
【问题描述】:
我正在尝试使用 API 控制 Tektronix RSA306 频谱分析仪。程序找到了 RSA300API.dll 文件,但在搜索和连接到设备时抛出错误。我正在运行的程序是 Tektronix 的一个示例。我目前使用的设置是 64 位 Windows 7 上的 Python 2.7.12 x64(Anaconda 4.1.1)。
from ctypes import *
import numpy as np
import matplotlib.pyplot as plt
我正在查找 .dll 文件:
rsa300 = WinDLL("RSA300API.dll")
执行搜索功能时出现错误:
longArray = c_long*10
deviceIDs = longArray()
deviceSerial = c_wchar_p('')
numFound = c_int(0)
serialNum = c_char_p('')
nomenclature = c_char_p('')
header = IQHeader()
rsa300.Search(byref(deviceIDs), byref(deviceSerial), byref(numFound))
if numFound.value == 1:
rsa300.Connect(deviceIDs[0])
else:
print('Unexpected number of instruments found.')
exit()
运行时出现以下错误信息:
C:\Anaconda2\python.exe C:/Tektronix/RSA_API/lib/x64/trial
<WinDLL 'RSA300API.dll', handle e47b0000 at 3ae4e80>
Traceback (most recent call last):
File "C:/Tektronix/RSA_API/lib/x64/trial", line 44, in <module>
rsa300.Search(byref(deviceIDs), byref(deviceSerial), byref(numFound))
File "C:\Anaconda2\lib\ctypes\__init__.py", line 376, in __getattr__
func = self.__getitem__(name)
File "C:\Anaconda2\lib\ctypes\__init__.py", line 381, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Search' not found
我遇到的问题是找不到“搜索”功能。有什么办法可以解决这个问题?
【问题讨论】:
-
您确定打开 dll 的方式吗?也许你应该这样试试:stackoverflow.com/a/3173926/5920310 你确定 dll 里面有一个
Search函数吗? -
我假设 dll 中有一个“搜索”功能。该 dll 直接从 Tektronix 网站下载,示例程序也从那里下载。 @XavierC。
-
你能提供
dir(rsa300)和help(rsa300)的输出吗?这会有所帮助。
标签: python windows anaconda ctypes