12-10-2021 03:04 AM
Thank you for your suggestion.
Yes, now it works. The results in the LabVIEW program have become the same with the reading of power meter' display.
But, I found other problem. The error out always send message '-1073807339' (Timeout expired before operation completed). Everything goes well, why the LabVIEW send the message? Actually this message has appeared since the beginning of the program.
12-10-2021 03:27 AM - edited 12-10-2021 03:30 AM
That's because you failed to notice all my remarks. You still request from VISA Read to read 64 characters but there are only 7 per message, 1 for the initial value 6, which is VERY likely the number of bytes that follow and 6 bytes for the actual message.
So VISA Read sits there, waiting for 64 bytes and after the timeout expires simply returns you that error that it did not succeed to return the required 64 bytes.
You should probably either read 7 bytes, check that the first is 6 and the second is 68 ('D') and then decode the frame accordingly, or you could read first one byte, and use that value as number of characters to read for the second VISA Read. Still check that this value is a reasonable one (6 or any other possible message your device might return) and the next character is really a 'D' before trying to decode the frame.
Also note that you do normally not want to open and close a VISA session inside a loop for every iteration of the loop. You rather put the VISA Open before the loop, and the VISA Close after the loop.
12-10-2021 04:00 AM
Thank you for the suggestion.
12-10-2021 05:58 AM - edited 12-10-2021 05:59 AM
I have changed the read byte to 7, put the VISA Open before the loop, and the VISA Close after the loop.
However, other message error is 1073676294 (The number of bytes transferred is equal to the requested input count. More data might be available).
The error message appear after I press stop button, but when I press abort execution to stop the mesaurment, the error did not apper.