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.
Solved! Go to Solution.
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.
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.
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.
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.
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.