首页 > 解决方案 > 调用一个应该通过 ctype 返回 None 的函数,它返回整数

问题描述

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

该函数采用 IP 和端口连接到传感器。问题是它不断返回整数 like(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?

标签: python

解决方案


推荐阅读