LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Termination character for visa reads

We have an instrument that puts out a very long string. (2.8kB) There is a \nl\cr at the end of each of the 109 lines. An issue occurs during the read where the time to fill the buffer and the read are not in sync and nulls \00 are introduced to the string.

I was experimenting with the termination character while setting up the com port but ran into problems with the writes. I tried an experiment with disabling the termination character just for this read and enabling it after the read. 

Is it possible to ignore the termination character for specific reads? I didn't try sequencing the disable, read, enable, could this be the answer?

Is anyone willing to share insight on this?

0 Kudos
Message 1 of 14
(926 Views)

The purpose of defining a termination character is exactly to avoid these problems. You are either reading too few characters or there is a timeout occurring, both can be avoided by more appropriate settings.

 

This forums has some excellent experts in serial communication (I am not one of them!), so start with providing significantly more information and maybe even showing some code.

0 Kudos
Message 2 of 14
(915 Views)

Have you watched this video? VIWeek 2020/Proper way to communicate over serial

 

Also we need to see your code to make sure you are not falling into the "Bytes at Port" trap.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 14
(894 Views)

Thank you for the replies.

I will review the video. Thank you RTSLVU!
I do use bytes at port, as I've not read a courteous and concise explanation as to why it shouldn't be done. Please provide a link?

Interestingly enough, reading and writing are not the issue, as these functions do work as intended. Working well is a matter for debate after review. These were originally written in 6i and morphed as I updated versions. I suppose it could be time for a full rewrite. Which may happen after I watch the video.


My original inquiry is whether there is a method to ignore the termination character only on specific reads. I experimented with the property node but the results were not as beneficial as I had hoped.
Please ask any questions you may have. I am slightly dyslexic and sometimes cannot convey my thoughts properly for the 80%.

Download All
0 Kudos
Message 4 of 14
(826 Views)

@SPC_NH wrote:

We have an instrument that puts out a very long string. (2.8kB)


What instrument are you trying to read from?  Most instruments have protocol for reading the large data string.  We need to better understand that protocol.


GCentral
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
0 Kudos
Message 5 of 14
(868 Views)

Why isn't my reply on the board? 

0 Kudos
Message 6 of 14
(855 Views)

Okay, I will try this again... thankfully some of this was in the clipboard

Thank you all for the replies.
Thank you for the link RTSLVU! I will review the video.
I do use bytes at port, as I've not read a courteous and concise explanation as to why it shouldn't be done. Please provide a link?

Interestingly enough, reading and writing are not the issue, as these functions do work as intended. Working well is a matter for debate after review. These were originally written in 6i and morphed as I updated versions. I may do a complete rewrite after I review the video.

My original inquiry is whether there is a method to ignore the termination character only on specific reads.

The instrument is ours. We use a USB connection to the instrument that uses the MS com port driver.
Please ask any questions you have. I am slightly dyslexic, so I do not always convey my thoughts properly for the 80%.

Download All
0 Kudos
Message 7 of 14
(845 Views)

@SPC_NH wrote:

Okay, I will try this again... thankfully some of this was in the clipboard

Thank you all for the replies.
Thank you for the link RTSLVU! I will review the video.
I do use bytes at port, as I've not read a courteous and concise explanation as to why it shouldn't be done. Please provide a link?

 


The video pretty much covers why you usually should not use Bytes at Port, also search the forum there are numerous discussions on this very topic. 

 


@SPC_NH wrote:

 

My original inquiry is whether there is a method to ignore the termination character only on specific reads.

 


I guess you could use a VISA Property Node to enable and disable the termination character.

 

But honestly that's just putting a Band-Aid on a bullet wound. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 14
(835 Views)

Why are you only writing 1 byte at a time?  Just give the whole string to the VISA Write and it should be just fine.

 

Your error handling is kind of scary.  What if there was an error before your Write.vi?  You will overwrite it and you will be searching for an issue in your write instead of where the error actually occurred.

 

Looking at your Read.vi, you will not do a proper read even though there is data if it shows up on the fifth attempt to look for data to come in (this is with the first loop).  You should bring out the result of the Not Equal To Zero out of the loop instead of the Greater.

 

General comment: If you are going to use a display style other than "Normal", you need the display style displayed.  Right-click on your string constants and choose Visible Items->Display Style.  For you hex style constants, you will see a little x display telling you that it is using Hex Display.

 

Still after looking through your code, I am not sure on the protocol.  How much detail on the messaging protocol can you share?


GCentral
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
0 Kudos
Message 9 of 14
(825 Views)

@RTSLVU wrote:

@SPC_NH wrote:

Okay, I will try this again... thankfully some of this was in the clipboard

Thank you all for the replies.
Thank you for the link RTSLVU! I will review the video.
I do use bytes at port, as I've not read a courteous and concise explanation as to why it shouldn't be done. Please provide a link?

 


The video pretty much covers why you usually should not use Bytes at Port, also search the forum there are numerous discussions on this very topic. 

 


@SPC_NH wrote:

 

My original inquiry is whether there is a method to ignore the termination character only on specific reads.

 


I guess you could use a VISA Property Node to enable and disable the termination character. But honestly that is putting a Band-Aid on a bullet wound. 


1. The OP is actually using the Bytes At Port properly: to tell if there is any data to read.  They are not using it to tell the VISA Read how many bytes to read.

2. Keysight instruments (the ones I know at the top of my head) have a data block protocol where it is actually desirable to temporarily turn off the termination character as the data block is a binary message instead of the normal ASCII based (SCPI) messages.  But there is header data in the protocol so you know large the block is so you can make sure you got the full block.  And, yes, this turning the termination character off and on is done through the VISA Property Node.


GCentral
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
Message 10 of 14
(816 Views)