调用应该通过ctype返回None且返回整数的函数

时间:2019-04-30 10:37:34

标签: python

我正在编写一个ctypes代码以从DLL调用函数。功能之一是传感器的连接功能。此函数应将处理程序返回到传感器(void *),但如果失败,则应返回Null。

该功能通过IP和端口连接到传感器。问题在于它不断返回整数,如(45940800),该整数会更改每次执行。无论输入IP还是端口,都始终返回整数。这个整数是多少?是指向轮廓传感器的处理程序还是指针?为什么当我完全未连接到传感器时,该函数为什么不显示NULL指针?

from ctypes import*


lib=windll.LoadLibrary("c:\\weCat3D\\weCat3D\\EthernetScanner\\EthernetScanner")
EthernetScanner_Connect = lib.EthernetScanner_Connect
EthernetScanner_Connect.restype=c_void_p
EthernetScanner_Connect.argtypes =[c_char_p,c_char_p,c_int]
x=EthernetScanner_Connect(b'192.168.100.1',b'32001\0',0)
print(x)


The function takes an IP and Port to connect to a sensor. The problem is that it keeps returning integer like(45940800) which change every time i run. Whatever the input IP or Port the integer is always returned. What is this integer? is it the handler or the pointer to profile sensor? why is the function not showing the NULL pointer while i am totally not connected to the sensor?

0 个答案:

没有答案