home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / vxidev.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  1.2 KB  |  45 lines

  1. /* vxidev.c
  2.    The following example prompts the user for an instrument
  3.    address and then reads the id register and device type
  4.    register.  The contents of the register are then displayed. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <sicl.h>
  9.  
  10. void main ()
  11. {
  12.   char inst_addr[80];
  13.   unsigned long a16map;
  14.   unsigned short id_reg, devtype_reg;
  15.   INST id;
  16.  
  17.   /* get instrument address */
  18.   puts ("Please enter the logical address of the register-based instrument,               for example, vxi,24 :  \n");
  19.   gets (inst_addr);
  20.  
  21.   /* install error handler */
  22.   ionerror (I_ERROR_EXIT);
  23.  
  24.   /* open communications session with instrument */
  25.   id  =  iopen (inst_addr);
  26.   itimeout (id, 10000);
  27.  
  28.   /* map into user memory space */
  29.   a16map = imapx (id, I_MAP_VXIDEV, 0, 1);
  30.  
  31.   /* read registers */
  32.   ipeekx16 (id, a16map, 0x00, &id_reg);
  33.   ipeekx16 (id, a16map, 0x02, &devtype_reg);
  34.  
  35.   /* print results */
  36.   printf ("Instrument at address %s\n", inst_addr);
  37.   printf ("ID Register = 0x%04X\n  Device Type Register = 0x%04X\n", id_reg, devtype_reg);
  38.  
  39.   /* unmap memory space */
  40.   iunmapx (id, a16map, I_MAP_VXIDEV, 0, 1);
  41.  
  42.   /* close session */
  43.   iclose (id);
  44. }
  45.