我正在使用python脚本为Strand/Straus7导入他的DLL。你知道吗
我正在尝试调用一个函数来设置单位,名为St7SetUnits,遵循手册(Img.1),并观察我导入的DLL(Img.2)的.py脚本。函数要求ac\u long和actypes.指针(cu long),在脚本(Img.3)中指定
这里有完整的手册strand7.com/downloads/strand7%20R246%20API%20Manual%20目录.pdf你知道吗
这里是.py脚本https://www.dropbox.com/s/88plz2funjqy1vb/St7API.py?dl=0
如手册开头所述,我必须转换ctypes数组(Img.4)中的列表。 我调用的函数与示例相同,但我不能正确调用它。 我写作
import St7API as SA
import ctypes
SA.St7Init()
unitsArray = ctypes.c_int * SA.kLastUnit
units = unitsArray()
units[0] = 0
units[1] = 1
units[2] = 3
units[3] = 1
units[4] = 1
units[5] = 2
SA.St7SetUnits(1, units)
但返回错误
expected c_long, got c_long_Array_6
如果我尝试其他方法,例如数组中的int
SA.St7SetUnits(1, units[0])
错误发生了变化
expected LP_c_long, got int
我尝试了许多解决办法,但没有一个奏效。你知道吗
有人能帮我吗?你知道吗
多谢了
我知道已经有一段时间了,但这对我很有用:
从你的截图上看,你可能在用蚱蜢。如果是这样,您可能需要通过在脚本顶部添加以下行来显式地将units数组强制转换为指针:
每当您将数组从IronPython传递到St7API时,都要这样做:
This answer有稍微多的。你知道吗
相关问题 更多 >
编程相关推荐