LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help Reading all the data returned to the serial port

In am writing a vi to read and control a temperature controller. However how do I setup my VISA to wait and read all the bytes that are return after each of my writes. I tried setting a loop after my write that will only read the port if the bytes at port are greater than 0. This does not always clear the port.
With every command that is sent to the instrument it sends back a response. If the command is a setting the response is:

If the command is a request the response is:

Knowing what is to be returned what is the best way to ensure I am getting all the information after each write.

Terry Sopkow
0 Kudos
Message 1 of 5
(2,489 Views)
This can easily be done by using the "Number of Bytes at Serial Port" property. Add a timeout in case no correct answer is sent.

Don't forget to disable the use of a termination char (VISA Property Node --> Message based settings --> Termination char enable). Otherwise the "VISA Read" function may return before the specified number of bytes is read.
0 Kudos
Message 2 of 5
(2,489 Views)
If the answer is variable in length and possibly unknown then it is probably best to use the termination character set to and call read twice first to get and then to get . just set the # of char to read greater than the maximum possible (ie if you set it to 100, the 2nd read will still only read and return if is setup as the termination character.)
Message 3 of 5
(2,489 Views)
If I setup the termination character using the attached VI my first read is
\s\s20.00\r\n
the second read (which takes a long time) is
0\r
If the termination character was set to then the first read should end at \r.

Could you help me with setting up the termination properly.

Terry S.
0 Kudos
Message 4 of 5
(2,489 Views)
You set the termination character to 10 decimal (x0A hex) or LineFeed. The proper value for the termination character is 13 decimal (x0D hex).

Mike...

This why the first read terminates on a LF and the second one has to timeout... BTW if you weren't seeing a timeout error, you should have been. You need to check your code for where the error message was getting lost. That error would have been an immediate tip-off that the termination was set wrong...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(2,489 Views)