‎11-23-2015 03:09 PM
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
‎11-23-2015 03:41 PM
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
‎11-23-2015 03:50 PM
‎11-24-2015 08:23 AM - edited ‎11-24-2015 08:29 AM
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.
Thanks
Sam
‎11-24-2015 08:26 AM - edited ‎11-24-2015 08:31 AM
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))?
‎11-24-2015 08:27 AM
Yes, I'm sure.
‎11-24-2015 10:03 AM
‎11-24-2015 10:13 AM
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.
‎11-24-2015 10:17 AM
Try this:
‎11-24-2015 10:24 AM
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.