We recently started accessing our Analog Discoveries with custom python scripts. We used to use matlab with direct dwf library calls using matlab's calllib() function, but are finding python to be a much more convenient option.
Here is my question: while I can cause the waveform generator to output custom or predefined waveforms and can read them with single shot, PC-triggered acquisitions, I can't retrieve Analog Discovery information such as device type, name, and serial number. Here is some sample code:
from __future__ import division from __future__ import print_function from ctypes import * from dwfconstants import * import collections
#load dwf library and declare ctype variables if sys.platform.startswith("win"): dwf = cdll.dwf DADinfo['sysplatform'] = sys.platform #print(sys.platform) else: print("THIS IS NOT A WINDOWS SYSTEM")
#print DWF version version = create_string_buffer(32) dwf.FDwfGetVersion(version) DADinfo['dwfversion'] = version.value print("DWF Version: "+version.value)
#make sure any attached Analog Discovery is in a known state dwf.FDwfDeviceCloseAll()
nDevice = c_int() result = dwf.FDwfEnum(enumfilterDiscovery, byref(nDevice)) print("Enum:", result, nDevice.value) isUsed = c_int() result = dwf.FDwfEnumDeviceIsOpened(c_int(1), byref(isUsed)) print("DeviceIsOpened:", result, isUsed.value) hdwf = c_int() result = dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) print("DeviceOpen:",result, hdwf.value) result = dwf.FDwfEnumDeviceIsOpened(hdwf, byref(isUsed)) print("DeviceIsOpened:", result, isUsed.value) sn = create_string_buffer(32) result = dwf.FDwfEnumSN(hdwf,sn) print("Serial number:", result, sn.value) dn = create_string_buffer(32) dwf.FDwfEnumDeviceName(hdwf,dn) print("Device name:", result, dn.value) deviceID = c_int() devicerevision = c_int() result = dwf.FDwfEnumDeviceType(hdwf, byref(deviceID), byref(devicerevision)) print("Device type:", result, deviceID.value, devicerevision.value)
And here is the output I get when I run this code:
Question
gregnordin
We recently started accessing our Analog Discoveries with custom python scripts. We used to use matlab with direct dwf library calls using matlab's calllib() function, but are finding python to be a much more convenient option.
Here is my question: while I can cause the waveform generator to output custom or predefined waveforms and can read them with single shot, PC-triggered acquisitions, I can't retrieve Analog Discovery information such as device type, name, and serial number. Here is some sample code:
from __future__ import division
from __future__ import print_function
from ctypes import *
from dwfconstants import *
import collections
#load dwf library and declare ctype variables
if sys.platform.startswith("win"):
dwf = cdll.dwf
DADinfo['sysplatform'] = sys.platform
#print(sys.platform)
else:
print("THIS IS NOT A WINDOWS SYSTEM")
#print DWF version
version = create_string_buffer(32)
dwf.FDwfGetVersion(version)
DADinfo['dwfversion'] = version.value
print("DWF Version: "+version.value)
#make sure any attached Analog Discovery is in a known state
dwf.FDwfDeviceCloseAll()
nDevice = c_int()
result = dwf.FDwfEnum(enumfilterDiscovery, byref(nDevice))
print("Enum:", result, nDevice.value)
isUsed = c_int()
result = dwf.FDwfEnumDeviceIsOpened(c_int(1), byref(isUsed))
print("DeviceIsOpened:", result, isUsed.value)
hdwf = c_int()
result = dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
print("DeviceOpen:",result, hdwf.value)
result = dwf.FDwfEnumDeviceIsOpened(hdwf, byref(isUsed))
print("DeviceIsOpened:", result, isUsed.value)
sn = create_string_buffer(32)
result = dwf.FDwfEnumSN(hdwf,sn)
print("Serial number:", result, sn.value)
dn = create_string_buffer(32)
dwf.FDwfEnumDeviceName(hdwf,dn)
print("Device name:", result, dn.value)
deviceID = c_int()
devicerevision = c_int()
result = dwf.FDwfEnumDeviceType(hdwf, byref(deviceID), byref(devicerevision))
print("Device type:", result, deviceID.value, devicerevision.value)
And here is the output I get when I run this code:
DWF Version: 2.7.5
Enum: 1 1
DeviceIsOpened: 0 0
DeviceOpen: 1 1
DeviceIsOpened: 0 0
Serial number: 0
Device name: 0
Device type: 0 0 0
Note that none of the requested information is returned. Any suggestions?
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.