viPrintf和viRead的区别

转自:http://iinsist.blog.163.com/blog/static/1906691642013526840519/


viPrintf:  

CVI里面的说明如下
Converts, formats, and writes the data designated by the format
string to the instrument. The data to be written is in the
argument(s) specified by the format string. This operation
returns when the transfer terminates.

This operation applies to the VISA INSTR session type.

参数说明
ViSession Instrument_Handle,:仪器句柄
ViString Write_Format_String :格式化串
最后一个参数是需要格式化的内容,如果有多个可以通过分号隔开。
注意:
对于格式化输入类别的函数,类似Printf  viPrint函数中, 对于字符串,必须要增加\n作为结束标志,否则系统不会正常输出,
因此viPrintf(InsHandle,"*IDN?\n");//正确用法
     viPrintf(InsHandle,"*IDN?");//错误用法  
 网上的说明如下:
 标准输入输出都是带有缓存的,一般是行缓存。对于标准输出,需要输出的数据并不是直接输出到终端上,而是首先缓存到某个地方,当遇到行刷新标志或者该缓存已满的情况下,才会把缓存的数据显示到终端设备上。ANSI C中定义换行符'\n'可以认为是行刷新标志。所以,printf函数没有带'\n'是不会自动刷新输出流,直至缓存被填满。 
 VIPrintf的功能包括Converts,、formats和writes三个操作,执行viPrintf(InsHandle,"*IDN?\n"); 从NISPI上监控到的执行过程就是
 Formatted viWrite (GPIB0::5::INSTR (0x02316370), "*IDN?.", 6, 6) 。

viWrite:

Writes data to a device.  The data to be written is in the
specified Buffer.  This operation returns when the transfer
terminates.

This operation applies to the VISA INSTR session type.

-------------------- Prototype ---------------------
ViStatus viWrite (ViSession Instrument_Handle, ViBuf Buffer,
                  ViUInt32 Count, ViPUInt32 Return_Count);


viWrite和viPrintf的差异
viPrintf可以一次输入多个指令,viWrite只能写入一个指令。
viPrintf(InsHandle,"%s,%s","*RST\n","*CLS\n");
viPrintF后面其实还是调用了viWrite;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值