Python ctypes访问冲突读取

时间:2019-04-25 13:57:46

标签: python ctypes

我正在尝试使用python通过DLL与设备进行通信,但出现“ OSError:异常:访问冲突读取为0x00000000”。我读过其他主题,在那里尝试了解决方案,但没有任何效果。

代码如下:

from ctypes import *

Papo32 = WinDLL("lib\\Papo32.dll")
Interlnk = WinDLL("lib\\Interlnk.dll")
Intfac32 = WinDLL("lib\\Intfac32.dll")
Spider32 = WinDLL("lib\\Spider32.dll")

ACQ_setup = Spider32.S8_ACQSetup
ACQ_setup.argtypes = [c_long, POINTER(c_long)]
ACQ_setup.restype = c_long

chans = [1]
n_chans = len(chans)
chans = (c_long * 8)(*chans)

error = ACQ_setup(n_chans, chans)
print(error)

这是错误:
错误= ACQ_setup(c_long(n_chans),chans_array(* chans))
OSError:异常:访问冲突读取为0x00000000

当数组为空时不会发生错误。

我从文档中得到了这个

S8_ACQSetup

Syntax:
    result = S8_ACQSetup(Num, *Chans);

Parameters:
    Input:
        • Num - long
          Number of measured values per channels
        • Chans - long
          List of measured channels

    Output:
        Result of the function (long):
        If the result of the function is non-zero, an error has occurred.

Description:
    The desired channels will be activated for measuring.

我正在遵循制造商提供的VB5中的此示例:

Declare Function S8_ACQSetup& Lib "SPIDER32.DLL" (ByVal num As Long, Chans As Long)

Dim ChanArray(10) As Long

ChanArray(1) = 0
S8_Error = S8_ACQSetup(1, ChanArray(1))

预先感谢

0 个答案:

没有答案