python3调用汇川提供的dll文件:IMC100API.dll,可以成功调用 IMC100_Init_ETH 函数建立和机器人连接,
但在查询当前控制许可时,却总失败,返回值:-255,对于获取许可
函数原型为: IMC100_CurPermit(int *owner, unsigned int *ipAddr, unsigned short *ipPort, int comId=0)
对该函数在python3建立了相应的指针变量
owner=ctypes.pointer(ctypes.c_int(0))
ipaddr=ctypes.pointer(ctypes.c_uint(0))
port=ctypes.pointer(ctypes.c_ushort(0))
然后调用
result=IMC100_CurPermit(owner, ipaddr, port)
得到结果:result=-255
-----------------------------------------------------
或者改成:
owner=ctypes.c_int(0)
ownerAddr = ctypes.byref(owner)
ip = ctypes.c_uint(0)
ipAddr=ctypes.byref(ip)
port=ctypes.c_ushort(0)
portAddr = ctypes.byref(port)
然后调用
result=IMC100_CurPermit(ownerAddr, ipAddr, portAddr)
得到结果:result=-255
-----------------------------------------------------
以下是汇川的2个函数原型:
可以成功调用的函数
调用失败的函数
恳请做过类似应用的朋友指点下:以上的问题出在哪里?该如何在python中建立相应的C函数指针参数呢?