hpibstat.c

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

C
55
字号
/* hpibstat.c
   The following example retrieves and displays
   HP-IB bus status information.
*/

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

main()
{
   INST id;                 /* session id        */
   int rem;                 /* remote enable     */
   int srq;                 /* service request   */
   int ndac;                /* not data accepted */
   int sysctlr;             /* system controller */
   int actctlr;             /* active controller */
   int talker;              /* talker            */
   int listener;            /* listener          */
   int addr;                /* bus address       */

   #if defined(__BORLANDC__) && !defined(__WIN32__)
      _InitEasyWin();   // required for Borland EasyWin programs
   #endif

   /* exit process if SICL error detected */
   ionerror(I_ERROR_EXIT);

   /* open HP-IB interface session */
   id = iopen("hpib7");
   itimeout (id, 10000);

   /* retrieve HP-IB bus status */
   igpibbusstatus(id, I_GPIB_BUS_REM,      &rem);
   igpibbusstatus(id, I_GPIB_BUS_SRQ,      &srq);
   igpibbusstatus(id, I_GPIB_BUS_NDAC,     &ndac);
   igpibbusstatus(id, I_GPIB_BUS_SYSCTLR,  &sysctlr);
   igpibbusstatus(id, I_GPIB_BUS_ACTCTLR,  &actctlr);
   igpibbusstatus(id, I_GPIB_BUS_TALKER,   &talker);
   igpibbusstatus(id, I_GPIB_BUS_LISTENER, &listener);
   igpibbusstatus(id, I_GPIB_BUS_ADDR,     &addr);

   /* display bus status */
   printf("%-5s%-5s%-5s%-5s%-5s%-5s%-5s%-5s\n", "REM", "SRQ",
         "NDC", "SYS", "ACT", "TLK", "LTN", "ADDR");
   printf("%2d%5d%5d%5d%5d%5d%5d%6d\n", rem, srq, ndac, 
          sysctlr, actctlr, talker, listener, addr);

/* For WIN16 programs, call _siclcleanup before exiting to release
   resources allocated by SICL for this application.  This call
   is a no-op for WIN32 programs. */
   _siclcleanup();

   return 0;
}

⌨️ 快捷键说明

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