LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read isn't polling serial port

When I call VISA Read, it looks at the data for my termination charecter, and if it is there, it returns instantly.  If the charecter is not there, it does not return once that charecter comes in.  It only returns once the time-out has expired.  

 

I'm running 2016.

Visa 15.1 I think

 

Thanks,

Sam

0 Kudos
Message 1 of 29
(4,547 Views)

Sam,

     Please attach the VI that does the VISA Read.  There are many ways for VISA to "go astray", usually because we fail to give it the correct instructions.  Maybe your code is doing what you told it to do, rather than what you want it to do -- without seeing your code, it is difficult to tell if this is the case.

 

Bob Schor

0 Kudos
Message 2 of 29
(4,529 Views)
And you certainly aren't running LabVIEW 2016. That won't be released until August of next year.

I also find your question confusing. You say the termination character is not there and then you say it is. It's one or the other.
0 Kudos
Message 3 of 29
(4,519 Views)

Oops. Yes, I'm using 2015.     

 

I'm constantly receiving messages with a carriage return as the termination charecter.  I have set the read amount to be more than any message length, and I am depending on the termination charecter.  Each time the loop executes, and the Read block runs, it polls the buffer.  If there is a termination charecter in the buffer. It works great, and returns the string right away. If there is not one in the buffer (yet), then it always waits the timeout time. No matter if a termination charecter appears in the buffer, or if the number of charecters in the buffer is greater than the 'return amount'. 

 

 This is why I currently have the timout est to be 50ms.  If I set it to 10,000ms.   Then it always waits 10 seconds, unless there happened to be a termination charector in the buffer when the read block is executed.

 

It appears that the Read block, only looks at the buffer the moment it is called, and never again....

 

Please let me know if this is as clear as mud.

 

VISA Read 3.png

 

Thanks

Sam

 

 

 

 

 

0 Kudos
Message 4 of 29
(4,467 Views)

Are you sure your termination character is a carriage return (\r) rather than a line feed (\n)? Based on your code, the VISA read node will wait until either 500 bytes comes in, the termination character of a carriage return (\r) is received or 50ms has elapsed. What is in your read buffer when it times out (show in \ codes so we can see the exact command(s))?


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 5 of 29
(4,459 Views)

Yes, I'm sure.

0 Kudos
Message 6 of 29
(4,455 Views)
You have to do what Sam said and show us the content of the string when you do get the timeout.
0 Kudos
Message 7 of 29
(4,431 Views)

The functions of using the carriage return constant, string to byte array, and index array are all a bit of a Rube Goldberg.  Just right click on the termination character input of the Serial Configure and pick Create constant, then just enter the value of 13 for a carriage return or 10 for a line feed.

0 Kudos
Message 8 of 29
(4,420 Views)

Try this:

 

Serial Port Read test.vi.png

 

 

George Zou
0 Kudos
Message 9 of 29
(4,413 Views)

So, I set the timeout to be 5000ms.   What happenes is that when the first Read is called, nothing happens because the buffer is empty.  After 5000ms.  The code timeouts, and nothing is returned (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 tried 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.

 

Serial Messages in.png

0 Kudos
Message 10 of 29
(4,406 Views)