I'm trying to communicate with a device through a DLL with python, but I'm getting "OSError: exception: access violation reading 0x00000000". I've read other topics, tried the solutions there, but nothing worked.
Here is the code:
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)
This is the error:
error = ACQ_setup(c_long(n_chans), chans_array(*chans))
OSError: exception: access violation reading 0x00000000
The error doesn't occur when the array is empty.
I have this from the documentation:
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.
And I'm following this example in VB5, provided by the manufacturer:
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))
Thanks in advance
User contributions licensed under CC BY-SA 3.0