07-12-2018 09:58 AM
Hello,
I'm using the viRead function to get info from a TCP instrument.
The question is, the parameter "buffer size" should be known in advance, otherwise I got non fatal timeout error.
So what should I do in the case that I don't know the size of the response from the instrument ?
status = viRead (instr, (ViBuf)outputBuffer, BufferSize, &count);
regards,
Solved! Go to Solution.
07-12-2018 10:43 AM
...with a manual of the instrument you probably can find out the longest possible response of the instrument, say 20 characters. Then you use a buffer size of 20 + 1 characters.
It doesn't matter if your buffer is too large, it is just a waste of memory, but it can crash your program if the buffer is too small...
07-13-2018 02:34 AM
Hello Wolfgang,
I know but the problem is when the bufferSize is bigger then the response length. I'ts not a memory problem.
Example : When I fixe the buffer size to 20 and then I try to read a response of 10 char. The function ivRead stay waiting for 20 char reception and then a timeout error occurs with non fatal error.
07-20-2018 02:40 AM
Well,
The solution I have found for now is to reduce the timeout so ivRead don't wait for a long time ...