LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[CVI2015] viRead and buffer size

Solved!
Go to solution

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, 

0 Kudos
Message 1 of 4
(3,098 Views)

...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...

0 Kudos
Message 2 of 4
(3,092 Views)

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.

 

0 Kudos
Message 3 of 4
(3,068 Views)
Solution
Accepted by topic author HoussamAz

Well,

 

The solution I have found for now is to reduce the timeout so ivRead don't wait for a long time ... 

0 Kudos
Message 4 of 4
(3,039 Views)