Jump to content
  • 0

Digilent Analog Discovery 2 .dll driver for VB.net and C# in visual studio 2017


sib

Question

Dear Diligent AD2 team

Please can you update your companies notes supporting Microsoft .net drivers which work with C# and VB.net and F#
for the Analog Discovery 2 tool. It is a an excellent tool , but be even more excellent if could work and be used in the microsoft .net environment.
This is a link to a previous forum post on the subject which used visual basic 6 from a while back.

https://forum.digilentinc.com/topic/3049-vbnet-andor-cnet-wrapper-for-dwfdll/

The original visual basic 6 example .   From the time before .net happened

      https://forum.digilentinc.com/applications/core/interface/file/attachment.php?id=1450    >> 160314_dwf_wrapper.zip

I have taken this worked example and updated to get it to run with vb.net in visual studio 2017 .See enclosed attachment-

It is failing to work properly due a. dll memory project fault in  the .dll driver. The C++ source code for the .dll driver is also 
included in the attachment.

My request is can Digilent fix the driver so that is usable in .net assemblies and is Memory safe .

This is the reported run time fault when trying to access FDwfDeviceOpen in vb.net 

line of code :   nRet = FDwfDeviceOpen(-1, hdwf)

Fault report : 

System.AccessViolationException
  HResult=0x80004003
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Thank you for considering this request

Digilent_AD2_try2_vb.net.zip

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hi @sib

Here you have VB wrapp er, converted from the old C# wrapper: dwf.vb

I have not tested all the functions only the following:

Imports System.Text

Module Module1

    Sub Main()

        Dim hdwf As Integer
        dwf.FDwfDeviceOpen(-1, hdwf)
        Console.WriteLine(CStr(hdwf))

        Dim str As StringBuilder = New StringBuilder(512)
        dwf.FDwfGetLastErrorMsg(str)
        Console.WriteLine(str.ToString())

        dwf.FDwfAnalogInConfigure(hdwf, 1, 1)

        Dim sts As Byte
        dwf.FDwfAnalogInStatus(hdwf, 1, sts)
        Console.WriteLine(CStr(sts))

        Dim rg(8192) As Double
        dwf.FDwfAnalogInStatusData(hdwf, 0, rg, 8192)
        Console.WriteLine(CStr(rg(0)))
        Console.WriteLine(CStr(rg(1)))
        Console.WriteLine(CStr(rg(8191)))

    End Sub

End Module

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...