python - 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)
这是错误:
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))
提前致谢
解决方案
推荐阅读
- kotlin - 为什么我可以在 Kotlin 中使用 Observer(adapter::submitList) 而不是 Observer { adapter.submitList(it)?
- python-3.x - 模块“tensorflow”在 Colab 中没有带有 TFANN 的属性“variable_scope”
- java - 具有自定义注释的字段的 Gson 自定义序列化
- c - typedef struct变量赋值中的typedef struct在c中不起作用
- python - 在 for 循环中使用 pandas csv_read 读取 csv 文件
- python - 如何从特定索引之前的列表中找到最大的数字?
- ffmpeg - ffmpeg:加入+交叉淡入淡出5个输入文件(视频+音频)到一个输出文件
- flutter - 用户单击后退按钮后颤振重新开始
- javascript - 环境变量反应
- python-3.x - 如何使用 Python3 以高效的方式将 .csv 文件从 S-3 存储桶上传到 Redshift 作为特定模式下的新表?