Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-VISA 19.0 and MessageBasedSessions -

I am writing a VB NET program for my Siglent spectrum analyzer.  Admittedly I am a VB Net newbie but I have communications working well.  Next I wanted to start playing with trace data.   For example I use a Siglent command for getting screen trace data:  

 

mbSession.RawIO.Write(":TRACe?")
str As String = mbSession.RawIO.ReadString()

 

I am only getting str lengths of 1024 bytes.  Using NI Max and checking by adjusting buffer size, the TRACe? command returns about 20,000 bytes of data and the size will vary depending on the spectrum analyzer function. Is there some method to use RawIO.ReadString() to read the entire  data string stream?  In VB Net declaring str as string should allow it to become any string length up to >1 Mbyte.   Is the 1024 byte limit a RawIO.ReadString() issue?? 

 

Any advice would be greatly appreciated.

 

Jerry 

0 Kudos
Message 1 of 4
(3,581 Views)

I realized I wasn't being clear.  Per the IVI specs, str = mbSession.RawIO.ReadString() should be Synchronous and read the entire string before completing.  I found that I can set the read length arbitrarily by including a length int64:

 

str = mbSession.RawIO.ReadString(21000)

 

My problem is the length will vary substantially.  Whats the most efficient and fastest way of doing this?  For a real time instrument interface, I would want to read the trace data and display it graphically many times a second.

0 Kudos
Message 2 of 4
(3,541 Views)

Hi, sorry to bother, I am extremely new to this Visa programming in VB (I have done it in python but this is way different) and I am having a lot of problems getting queries from the device, I have been able to connect to it and (I think) open the session but I am not able to send any command to it (I am just trying with the "*IDN?"), this is some of my code
Imports NationalInstruments.Visa

Public rm As New ResourceManager

      I am able to find the device and put it on a Combo Box

Dim lista1() As String = rm.Find("(ASRL|GPIB|TCPIP|USB)?*")

      I take the selected device from the Combo Box

Dim aparato As String = ComboBox1.Text()

      "Open" the device (I don't know if it is correctly defined)

Dim el_aparato As Object = rm.Open(aparato)

      And then I try to get the response from it 

Dim respuesta As String = el_aparato.Parse("*IDN?")

 

I really, really appreciate if you could help me out

For any reply thanks.

 

0 Kudos
Message 3 of 4
(3,248 Views)

Just a thought, have you set the termination character?

i.e. mbSession.TerminationCharacter = TermChar

       where TermChar As Byte = 63 for a "?" as it appears in your example.

Hope that helps.

0 Kudos
Message 4 of 4
(3,138 Views)