Showing results for 
Search instead for 
Did you mean: 

VISA read for serial not collecting all of the port data

Go to solution

This should be a simple task and I have read through many solutions and tried implementing a few different things but to no avail.  I am pulling data from a device over serial.  When I send it it a command over say putty it echos back the command and then returns the response which has a bunch of new lines and then a data response to the query.  Everything I do in labview only seems to lets me read the echoed back command regardless of disabling termination characters or just trying to read more bytes that VISA sees (the bytes at port function only ever shows 6 bytes which is the "echo".  Reading more than 6 bytes generates a LV read error and invokes the 10 second timeout.


If I send the command over putty it comes back in this format:


at&t1? (type this then hit enter)






But as mentioned in Labview I can only seem to read "at&t1?" and as mentioned only ever shows 6 bytes at port instead of the 23.  I have tried setting enable termination character to False using the VISA configure serial port and also with a property node.  Attached is a messy block diagram full of random property nodes that I am chugging through at this point hoping to see 23 bytes at port instead of 6.  Curious if anyone has ever had a problem like this in the past, I think the issue is it immediately echo's the at&t1? command then quite quickly fills in a payload with the response, but I think its filled in too slow to show up on labviews "bytes" at port function, but then gone if you just set a while loop up to continually read (though not sure why setting the read function to 23 bytes would not just grab it?)


Hoping that someone can look at my block diagram and just see a boneheaded setup item that I missed.



Download All
0 Kudos
Message 1 of 7

If you know how many lines will be printed in response to a given command (hopefully the same number for any command, but not necessary, just helpful) then you can use the Read in a nested For loop to get each line (using the TermChar).


Alternatively, you can repeatedly read with a short timeout until you no longer get data.

Examples for these options are below (approximately in order of preference):


As a side note, you usually don't use VISA Open when you're using VISA Configure Serial Port.

0 Kudos
Message 2 of 7

Thanks for the response,  I tried these versions but it comes up the same issue.  On the first example there is only 6 bytes read from the first iteration of the for loop and then there is a read error and nothing for subsequent lines. 

0 Kudos
Message 3 of 7

@labstew wrote:

On the first example there is only 6 bytes read from the first iteration of the for loop and then there is a read error and nothing for subsequent lines. 

That is because the device is not sending a response.  Why?  Because you did not terminate your command.  Right-click on your command string and choose "Visible Items->Display Style".  You will see a little "n" appear, indicating "Normal" display.  Click on that "n" and choose "\ Codes".  Now add "\n" to the end of your string.  Now your string will include a new line constant.  Your command will now be terminated and your device will respond.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 4 of 7
Accepted by topic author labstew

Can you check that the serial settings are the same for Putty and LabVIEW? I checked my Putty installation and it appears by default there is flow control, for example (in LabVIEW, the default is none).


Posts about similar issues also reflect on the termination characters - apparently some command-line/terminal tools add CR/LF and LabVIEW doesn't add anything by default (so you need to concatenate string and add the CR, LF or CR LF as needed for your device.

0 Kudos
Message 5 of 7

Yes I just added a carriage return and it worked.  I will have to remember that for future reference if I see visa just read back the sent message its not necessarily an echo or ack even if that is the normal device behavior.



Message 6 of 7



I have made the code to detect mass from port after certain interval. The problem is that it is not taking all the data from port, it takes 163.4, 173.4, 183.4 etc. I want the numeric data after every 1 min. Where am I going wrong?

Download All
0 Kudos
Message 7 of 7