08-06-2025 11:36 AM
Is there a way to peak at what's already read off the wire?
let's say I define 1000 bytes to read
return value is variable and can be either \r terminated or no termination (just a single ^).
In the latter case, it will wait the full time out period before it proceeds.
So my question is if there is a way to peak at what's already read so far, while it's still within the time out period.
VISA read is one atomic command, so not sure how to access what's already read.
Solved! Go to Solution.
08-06-2025 01:49 PM - edited 08-06-2025 01:50 PM
Hi fan,
@shuttlefan wrote:
So my question is if there is a way to peak at what's already read so far, while it's still within the time out period.
VISA read is one atomic command, so not sure how to access what's already read.
Lower the timeout period and read the buffer.
What is the longest time you need to wait for a message with a TermChar (\r)? Set that time plus some safety margin…
(Or read byte by byte until you received your message.)
08-06-2025 02:05 PM
I've also been known to use the ^ or similar as the termination character in certain situations and use Trim Whitespace to clear out any potential end of line characters before analyzing the read data.
08-06-2025 02:12 PM
@GerdW wrote:
What is the longest time you need to wait for a message with a TermChar (\r)? Set that time plus some safety margin…
I don't have a good feel for how long the device will take to respond if it's doing something else at same time so not sure how low to lower it.
(Or read byte by byte until you received your message.)
I think this might be the safest way to do it. For the commands that don't return a termination char, read it one by one to not rely on timeout. Didn't know if there was a way to peak so it's sounding like there isn't.