LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to know the buffer size before calling VISA Read function?

 Dear all,

I am using a USB interface to acquire data throug LabVIEW.

The interface has 2 buttons in it. One for sending the waveform data(992 bytes) and another using DSR request for sending the value of Current(62 bytes).

 

I want to detect between the waveform data and the DSR request. If the waveform data is recieced, it should be plotted on the Graph and if the DSR request is recieved, the value of the current should be updated.

 

The method which i think is suitable to achieve the goal is to get the size of the buffer before calling the VISA Read function and depending upon that do an appropriate operation.

 

I wrote a VI to perform the same but could not get it working. Pls have a look at it also, let me know how to tackle this problem.

 

Thanks,

Ritesh

0 Kudos
Message 1 of 16
(7,621 Views)

hi,

 

         I am not sure that we have direct icon for reading buffer size in VISA. I just checked with the properties i found this just check it out this may help.

 

 

0 Kudos
Message 2 of 16
(7,606 Views)

The serial VISA connection has a property for that:

http://zone.ni.com/reference/en-XX/help/371361D-01/lvinstio/visa_bytes_at_serial_port/

 

Daniel

 

0 Kudos
Message 3 of 16
(7,602 Views)
In your vi you have defined the input buffer size.By doing so you have a predefined buffer allocated no matter your data is filling it or not.So no matter you get your waveform data or dsr request you will get a return value of the buffer size you have allocated.Isnt it?
0 Kudos
Message 4 of 16
(7,599 Views)

Dear All,

Thanks for your replies.

"Bytes at Port" was the fnction i was lookin for. 

 

But, now the scenerio of problem has changed.

How to set multiple event detect in VISA functions ?

Like the waveform data comes as 1054 bytes. But the other switch when pressed, sends 62 bytes with DSR event.

I want to differentiate between the waveform data and theDSR event.

 

In Visual basic, there is an event handling like OnCommevent and various status can be read like : Comevrecieve or ComevDSR.

 

How can we detect recieve threshold event similar to Comevrecieve ?

 

Thanks,

Ritesh

 

0 Kudos
Message 5 of 16
(7,581 Views)
These buttons are on the USB device? And by DSR, are you talking about the DSR line of the serial interface? If it's the serial interface control line, you can read that. There is the Serial DSR event or you can have a VISA property node set for Serial Settings>Modem Line Settings>DSR State. Seems to me though, that it would just as easy to update the indicators based on the size of the data. All that would take is a case statement.
0 Kudos
Message 6 of 16
(7,551 Views)

Hi Dennis,

I implemented a VI with a case structure checking the number of bytes at the port.

Just have a look at it and let me know if this was thing you asked to do.

 

Thanks,

Ritesh

0 Kudos
Message 7 of 16
(7,507 Views)

Hi Dennis,

I just figured out that the case structre with "bytes at the port" function wont solve my problem.

 

Thing is my H/W is sending me chunks of 62 bytes. If Button 1 is pressed, it will only send the waveform data, i.e it will only send the chunks of 62 bytes. But, if Button 2 is pressed, it will send 62 bytes with DSR request.

and the waveform data will only be read when the Buffer size = 1054.

 

So, i need to differentiate between the DSR request and the waveform data(without any request).

 

I have created a VI with a logic to chk for request or not. but, still its not giving out the perfect result. it does recognizes the request, but isn't able to detect the data.

Just have a look at the VI to understand better of what i want to convey.

N let me know if there's any wayout to perform it.

 

Thanks,

Ritesh 

 

0 Kudos
Message 8 of 16
(7,481 Views)

Sort of. What wasn't clear from your first post was whether the instrument only sent data as a response to a write. This last example implies that the instrument is always sending data on it's own. Your simple case statement will probably not work. Say, for example, the instrument is sending waveform data. Your VI reads the number of bytes before the instrument is finished sending. The number of bytes available will not match what you expect for a waveform.

 

Without seeing the documentation for the instrument, it's hard to say what needs to be done to make your program more robust. You never really answered my question about the serial DSR line. If it's true that the DSR line is only asserted for one type of data, then you might be better off using that. For example, you could check if number of bytes is greater than 0 and DSR asserted. Or them together to determine the type of read.

Message 9 of 16
(7,462 Views)
I guess we posted at the same time. The last example is more like I was talking about. I'm not sure that checking for equal to 1054 is the way to go. I would first try checking for greater than zero.
0 Kudos
Message 10 of 16
(7,460 Views)