05-25-2004 09:12 AM
05-26-2004 09:00 AM
05-26-2004 09:25 AM
04-21-2006 01:18 AM
04-21-2006 02:32 AM - edited 04-21-2006 02:32 AM
It looks like you are compiling C++ code, not C. The 2nd param of viWrite() function is declared as ViBuf type in visa.h, which is also TYPEDEFed as unsigned char*. For VC++ compiler, the signed char* and unsigned char* are much different types therefore no implicit conversion is applied. Instead you must explicitly typecast for the parameter. Also a string constant such as "*IDN?\n" is considered as const char* type, which also requires typecast if converting non-const type.
vs = viWrite( vi, reinterpret_cast<ViBuf>("ISET 3.0\n"), 9, &dwRet); // C++ style typecast
or
vs = viWrite( vi, (ViBuf)"ISET 3.0\n", 9, &dwRet); // legacy C style typecast
Also, if you just send an ASCII string, consider using viPrintf() function.
vs = viSetAttribute( vi, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS);
...
vs = viPrintf( vi, "ISET %0.1f\n", 3.0);
The viPrintf() is much simpler than viWrite() for ASCII write, because it does not require the size params, and you can use printf() style syntax. Mind that you should set Wrtite-Buffer-Operation mode to Flush-On-Access, because some VISA implementation may not flush out (= write to instrument) immediately when viPrintf() has been called as default. (No need to call it everytime, but only once is enough.) Plus, do not forget to add "\n" termination on the string to write. viPrintf() explicitly requires a terrmination chracter.
Makoto
このメッセージは 04-21-2006 05:36 PMに Makoto が編集しています。
04-24-2006 04:10 AM