用vc6编程实现gpib通信

2019-07-17 19:04发布

我是用Agilent VISA程序库,按照visa手册对vc进行设置,粘了一个实现IDN?功能的程序,编译链接没问题,但执行试并没有得到仪器名称。仪器在visa assistant中已经查到并能实现idn?功能。程序如下:
/*idn.c
  This example program queries a GPIB device for an identification string
  and prints the results. Note that you must change the address. */

#include <visa.h>
#include <stdio.h>

void main () {

  ViSession defaultRM, vi;
  char buf [256] = {0};


  /* Open session to GPIB device at address 22 */
  viOpenDefaultRM (&defaultRM);
  viOpen (defaultRM, "GPIB0::22::INSTR", VI_NULL,VI_NULL, &vi);

  /* Initialize device */
  viPrintf (vi, "*RST ");

  /* Send an *IDN? string to the device */
  viPrintf (vi, "*IDN? ");

  /* Read results */
  viScanf (vi, "%t", &buf);

  /* Print results */
  printf ("Instrument id string: %s ", buf);

  /* Close session */
  viClose (vi);
  viClose (defaultRM);
}


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。