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函式指標引數呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/205019.html
