litepoint IQXEL80 使用Ctype 与仪器键实现scpi通信
from ctypes import *
iq = cdll.LoadLibrary(r"IQmeasure.dll")
# how to using logger for test iqmeasure
# test iqmeasure_scpi test command
#
# 调用方法
init_result = iq.LP_Init(c_int(1), c_int(1)) #SCPI
print('init_result:', init_result) # init_result: 0
# 该方法中,返回0为成功
# 原C++文档中,该方法如下:
# int LP_Init(int IQtype = IQTYPE_XEL,int testerControlMethod = 1);
# 有返回值
# 设置返回值类型
# iq.LP_GetErrorString.restype = c_char_p
# # # 设置初始值类型
# iq.LP_GetErrorString.argtypes = [c_int]
# msg = iq.LP_GetErrorString(c_int(10))
# print(msg) # b'Invalid analysis type'
# # # 转换为string
# str_msg = msg.decode("utf-8")
# print(str_msg) # VSA number is out of range. Try 1-4.
# 原C++文档中,该方法如下:
# char* LP_GetErrorString(int err)
ip = b"192.168.10.250"
rc = iq.LP_InitTester(c_char_p(ip))
print(rc)
print("LP_InitTesterN")
# 参数值为*类型
# 使用byref(),包装对应类型即可
# iq.LP_SetTesterMode(c_int(0), byref(c_int(1)), c_int(1))
# 原C++文档中,该方法如下:
# int LP_SetTesterMode( int signalMode = UP_TO_80MHZ_SIGNAL, int *selectedModules = NULL, int numOfSelectedModules = 1 );
version = create_string_buffer(255)
# print("get ver", version)
rc = iq.LP_GetVersion(version, 255)
version_result = version.value.decode("utf-8")
print("get ver",version_result)