LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

can i viRead several times after one viWrite?

i use viWrite to request oscilloscope wave data. 

suppose that, the total count of received data is 610.

After the viWrite operation, i want to use two viRead to receive the 610 data.

viWrite(instr, "READ:WAVFM:CH1", 14, &retCount); //Write request

viRead(instr, buffer, 10, &retCount); //First read the head 10 bytes

viRead(instr, buffer, 600, &retCount); //Then read the rest 600 bytes

 

is it correct?

 

0 Kudos
Message 1 of 6
(2,504 Views)

additional remarks:

if i use one viRead to receive data, and i will receive the total 610 bytes.

viWrite(instr, "READ:WAVFM:CH1", 14, &retCount); //Write request

viRead(instr, buffer, 610, &retCount); //it will read  610 bytes

 

---------------------------------------------------------

if i use NI MAX to test.

viWrite(instr, "READ:WAVFM:CH1", 14, &retCount); //Write request

viRead(instr, buffer, 10, &retCount); //First read the head 10 bytes

viRead(instr, buffer, 600, &retCount); //it will read  590 bytes

why?

0 Kudos
Message 2 of 6
(2,458 Views)

You need to check the return code on that 2nd viRead. It's probably to do with it saw a termination char or the protocol being used said there was no more data. If temrination character then there is an attribute to disable it. Something like "term char enabled" Helps to view this kinda stuff in Io Trace to see what is going on and you cn see data in buffer

0 Kudos
Message 3 of 6
(2,437 Views)

1, i disable the VI_ATTR_TERMCHAR_EN (default value is 0);

status=viSetAttribute(vi,VI_ATTR_TERMCHAR_EN,0); //rerurn code is VI_SUCCESS

 

2,status=viWrite(instr, "READ:WAVFM:CH1", 14, &retCount); //Write request,rerurn code is VI_SUCCESS

 

3,status=viRead(instr, buffer, 10, &retCount);

//First read the head 10 bytes, retCount=10,rerurn code is VI_SUCCESS_MAX_CNT,(The number of bytes read is equal to count. No END indicator was received and no termination character was read.)

 

4,status=viRead(instr, buffer, 600, &retCount);

//Then read the rest 600 bytes,retCount=590,rerurn code is VI_SUCCESS,(The operation completed successfully and the END indicator was received (for interfaces that have END indicators). This completion code is returned regardless of whether the termination character is received or the number of bytes read is equal to count. )

0 Kudos
Message 4 of 6
(2,419 Views)

Well that indicates the instrument has not got 600 bytes left to transfer after the first 10. Need to check return code on this: 

viRead(instr, buffer, 610, &retCount); //it will read  610 bytes

 

You sure its returning 610 bytes or does status code say same as the 2nd viRead of 600 bytes: The operation completed successfully and the END indicator was received (for interfaces that have END indicators). It has to or otherwise it doesn't make sense.

0 Kudos
Message 5 of 6
(2,397 Views)

then,why:

viWrite(instr, "READ:WAVFM:CH1", 14, &retCount); //Write request

viRead(instr, buffer, 610, &retCount); //it will read 610 bytes

 

why, in this case,it will read 610 bytes success.

0 Kudos
Message 6 of 6
(2,325 Views)