11-18-2005 03:17 PM
11-21-2005 05:15 AM
11-21-2005 11:11 AM
11-21-2005 11:48 AM
11-21-2005 11:52 AM
Hi Michelle,
It is often related to the end-of-line character ( '\n' vs '\r\n' ), where there is a mismatch between the amount of bytes being reported as available and the actual length of the data that is available. If this is the case, you may be trying to read a string (let's say 8 bytes) with an end of line character (\r\n) being counted as 2 bytes, giving you a total of 10 reported bytes. But when you read it, there are only 9 bytes available. So giving more time will not solve this (one trick is to read 1 less byte... as an experiment ONLY). The solution would be to fix the source which reports the string length....
However, you are saying that you see this with an instrument? Do you mean a test instrument? ( if so, that would be strange).
Have you tried using MAX (Measurement and Automation Explorer) to communicate with your instrument using *IDN? command?
It will also provide you Instrument model plus serial number in text string also with number of bytes returned.
Ray
11-21-2005 01:49 PM
I'm actually reading back 60 bytes of information from a third party board. I request status from the board, and then "bytes at port" is reported as 0 and the read operation times out. On the next iteration of the loop, 60 bytes are available, so they are read back.
Even though 0 bytes are available originally, shouldn't the read VI wait until the timeout (10 seconds) before reporting a timeout? Is it possible that the read VI is executed before the write VI completely finishes?
11-21-2005 02:01 PM
11-21-2005 02:50 PM
11-22-2005 07:14 AM - edited 11-22-2005 07:14 AM
Hi Michelle,
LOL!! 😄 I have to agree with Lynn. You should never attempt to read more bytes than are available. So for 0 bytes, you should not read anything. I am not sure why it timesout before the 10 seconds, but it may depend on how your read serial port is configured (if my memory is ok -- early morning ).
Reading what may show up in the serial buffer may (or actually will) lead to strange and unexpected behavior. It is better to create a loop for 10 seconds that reads the contents of the serial port based on the number of bytes available, and append to the same string (within that loop). This means that you start with an empty string, read any data available for a given amount of time (and up until it is empty), then pass what was read at the output of the loop. This may do what you attempted to achieve, without timing out. 😉
Ray
Message Edited by JoeLabView on 11-22-2005 08:18 AM