Jump to content
  • 0

Logic Analyzer API: Is it possible to put a UInt16 value in a Byte Array?


Lesiastas

Question

Greetings! I'm currently working on a project involving the use of the Analog Discovery 2's Logic Analyzer. I was tasked to created a VB6 Wrapper to replicate the functions of the Logic Analyzer WaveForms GUI. I'm not very knowledgeable in coding so I was wondering how to translate this python variable from the DigitalIn_Acquisition sample code into its VB6 equivalent:

image.png.3623760a9d24c4c3acbe9664ba589221.png

Here's the VB6 code that I made:

image.png.e5fc7cc8bcea7c265b873c8346a3ea9c.png

image.png.165ddd2bf83ed8c31a3832374e9782e4.png

Again, I'm very sorry, but I'm still a novice at coding. Though I understand that you can't insert a UShort value in a 1-Dimensional Byte Array, I can't think of a way to declare it in order to agree with the Byte Array Data Type. 

Any advice guys? 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi @Lesiastas

You could change the declaration in the wrapper to UInt16:

<DllImport("dwf.dll", EntryPoint:="FDwfDigitalInStatusData", CallingConvention:=CallingConvention.Cdecl)>
  Function FDwfDigitalInStatusData(ByVal hdwf As Integer, <MarshalAs(UnmanagedType.LPArray)> rgData() As UInt16, ByVal countOfDataBytes As Integer) As Integer
  End Function

And use as:

Dim samples = 1000
Dim rgwData(samples) As UInt16
FDwfDigitalInStatusData(hdwf, rgwData, 2 * samples)

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...