I know there is the option of formatting with viPrintf, but does it communicate with instruments the same way that viWrite does? Also is there any advantages to using one or the other? Any input appreciated I'm new to using the VISA library.
Solved! Go to Solution.
viWrite sends a string as it is, viPrintf constructs a string in a similar way a printf does it in C. viPrintf is roughly equivalent to a sequence sprintf (to make the string) and viWrite (to send it). Any error is more difficult to debug with viPrintf as you don't see the final string being sent therefore I would recommend using only vi Write.
It is said in the Visa reference manual:
"The viPrintf() operation sends data to a device as specified by the format string. Before
sending the data, the operation formats the arguments in the parameter list as specified in the writeFmt string. The viWrite() operation performs the actual low-level I/O to the device.
As a result, you should not use the viWrite() and viPrintf() operations in the same
I'm not sure to understand the reason for such limitation, looks like viPrintf uses some intermediate internal array to buffer the data before it is sent.
Thank you very much! It makes a lot more sense now the way you put it. I was trying to find some direct comparison somewhere, but just couldn't so I thought I would ask here.