04-13-2020 06:54 AM
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?
04-14-2020 01:12 AM
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?
04-14-2020 10:44 AM
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
04-14-2020 10:14 PM - edited 04-14-2020 10:16 PM
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. )
04-15-2020 08:50 AM
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.
05-06-2020 08:54 AM
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.