LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read for serial not collecting all of the port data

Solved!
Go to solution
Highlighted

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)

at&t1?


&T1:259

 

OK

 

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.

 

Thanks

0 Kudos
Message 1 of 6
(162 Views)

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):

Example_VI_BD.png

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

GCentral
0 Kudos
Message 2 of 6
(121 Views)

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 6
(70 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 4 of 6
(54 Views)
Solution
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.

GCentral
0 Kudos
Message 5 of 6
(51 Views)

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.

 

Cheers

0 Kudos
Message 6 of 6
(42 Views)