LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read isn't polling serial port

And just to preemt the calls to use \n instead of \r,  the code responds the same way.   

Serial Messages in2.png

0 Kudos
Message 11 of 29
(1,664 Views)

--

0 Kudos
Message 12 of 29
(1,663 Views)

To me, it looks like the second option (with \n as the termination character) is working fine? Each iteration of the loop (i.e. each VISA read) produces one array item which is a complete command string?

 

If you're getting timeout errors even with the second option, I'm not sure why it's waiting before returning the data, the VISA node should finish executing as soon as it sees the termination character (or 500 bytes).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 13 of 29
(1,653 Views)

Yes, the data is correct, but that's not the problem!

 

Please read the text of my previous post....

 

0 Kudos
Message 14 of 29
(1,647 Views)

The problem with using a carriage return as your termination character is that you are getting two of them in a row, followed by a line feed character.

 

VISA read reads to the termination character,  you get data and the CR.

Next iteration, VISA reads to the termination character, you get the second CR.

Next iteration, VISA reads to the termination character, you get the line feed, data, and the first CR.

 

Just use linefeed as the termination character.  Then you'll get data, 2 CR's and the linefeed.  You can use Clean white space, to eliminate the extra CR's.

 

If it takes 5 seconds for data to come in, then perhaps it is an issue with how fast the data is being sent.

0 Kudos
Message 15 of 29
(1,637 Views)

PLEASE READ:

 

I'm sorry to get fustrated, but my problem ISN'T the data itself coming in. 

 

I have RE-WRITTEN the code so that I use the line feed.   There is STILL my problem which is:

 

When I set the timeout to be 5000ms.   What happenes is that when the first Read is called, nothing happens because the buffer is empty. The code waits for 5000ms.

 

THIS IS THE PROBLEM:  The Read box doesn't poll the serial port, so even though data is arriving, it hangs on the Read box until timeout.  When it times out, it returns and empty string.

 

Then the while loop loops, and the read is called again.  In that 5000 ms, I've receieved 290 messages.   So when the read is called again, there is a termination charecter waiting in the que, so it returns instantly with the first message. And it cleans out the buffer by looping 290 times.   

 

Once the buffer is clear, then it tries to read the buffer with no termination charecter, and it waits the full 5 seconds for it to time out.

 

Once again, I do not think that the Read is checking the buffer after the initial check of the buffer.

 

Shouldn't the read box return AS SOON AS A TERMINATION CHARECTOR ARRIVES IN THE BUFFER?

 

Sorry to get all 'boldy and caps', but my problem isn't on how to use a termination charector.

 

 

 

0 Kudos
Message 16 of 29
(1,630 Views)

Samuel_Schweighart wrote:

Shouldn't the read box return AS SOON AS A TERMINATION CHARECTOR ARRIVES IN THE BUFFER?


I just went into the lab and do an experiment.  This is exactly how it behaved for me.  I waited for the VISA Read to start (timeout of 5 seconds) and then sent the command.  It immediately came back with the data I sent it.  I used two ports and a Null Modem cable.

 

Perhaps it is an issue with your serial ports?  Are you using USB-Serial adapters?  If so, do you know the chipset?


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 17 of 29
(1,615 Views)

 

@Samuel_Schweighart wrote:

 

Shouldn't the read box return AS SOON AS A TERMINATION CHARECTOR ARRIVES IN THE BUFFER?

 

 


Yes, as we have stated. I'm not sure why it doesn't. What Serial hardware are you using? 

 

Have you tried setting the timeout to a long period (e.g. 10s) and then in another while loop, check the 'bytes at port' property and see if the characters are actually appearing in the buffer?

 

You could also try changing the VISA read from asynchronous/synchronous to the other option (it's a right-click option) to see if that makes any difference?

 

(Remember, we are trying to help you. There was a problem with your termination character. If you're getting frustrated, go for a walk or take a coffee - it helps to calm me down and clear my head when I can't get something working!)

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 18 of 29
(1,615 Views)

Hi Sam,

 

I've used a PL2303 USB to Serial Converter, (which kept freezing). 

 

I'm currently using the serial port that is integrated into the DELL Laptop docking station. 

 

I haven't tried the long period, and then the other loop. I will do that. 

 

I have tried changing the asynch/synch without any change.

 

Thanks for sticking with this thread!

 

Sam

0 Kudos
Message 19 of 29
(1,603 Views)

When I add a seperate loop  to look at Bytes at Port, it does not show any bytes at port while the Read Block is 'hanging'.

 

I have verified that the loop running the Bytes at Port is looping through VERY fast. 

 

Once the read block times out, the Bytes at Port reads data (~4000 Bytes) sitting in the buffer. 

 

Ideas?

0 Kudos
Message 20 of 29
(1,592 Views)