vxidev.c

来自「HP GPIB的VB和C语言库文件,参考范例.」· C语言 代码 · 共 45 行

C
45
字号
/* vxidev.c
   The following example prompts the user for an instrument
   address and then reads the id register and device type
   register.  The contents of the register are then displayed. */

#include <stdio.h>
#include <stdlib.h>
#include <sicl.h>

void main ()
{
  char inst_addr[80];
  char *base_addr;
  unsigned short id_reg, devtype_reg;
  INST id;

  /* get instrument address */
  puts ("Please enter the logical address of the register-based instrument,               for example, vxi,24 :  \n");
  gets (inst_addr);

  /* install error handler */
  ionerror (I_ERROR_EXIT);

  /* open communications session with instrument */
  id  =  iopen (inst_addr);
  itimeout (id, 10000);

  /* map into user memory space */
  base_addr = imap (id, I_MAP_VXIDEV, 0, 1, NULL);

  /* read registers */
  id_reg = iwpeek ((unsigned short *)(base_addr + 0x00));
  devtype_reg = iwpeek ((unsigned short *)(base_addr + 0x02));

  /* print results */
  printf ("Instrument at address %s\n", inst_addr);
  printf ("ID Register = 0x%4X\n  Device Type Register = 0x%4X\n", id_reg, devtype_reg);

  /* unmap memory space */
  iunmap (id, base_addr, I_MAP_VXIDEV, 0, 1);

  /* close session */
  iclose (id);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?