⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idn.c

📁 HP GPIB的VB和C语言库文件,参考范例.
💻 C
字号:
/////////////////////////////////////////////////////////////////////
//
// The following simple demonstration program uses the Standard 
// Instrument Control Library to query an HP-IB instrument for
// an identification string and then prints the result.
//
// Edit the DEVICE_ADDRESS line below to specify the address of the 
// device you want to talk to.  For example:
//
//     hpib7,0    - refers to an HP-IB device at bus address 0 
//                  connected to an interface named "hpib7" by the 
//                  I/O Config utility.
//
//     hpib7,9,0  - refers to an HP-IB device at bus address 9, 
//                  secondary address 0, connected to an interface 
//                  named "hpib7" by the I/O Config utility.
//
// Note that this program is meant to be built either as a WIN16 
// QuickWin or EasyWin program on 16 bit Windows 95, or as a WIN32
// console application on 32 bit Windows 95 or Windows NT.  Also 
// note that WIN16 programs must be compiled with the Large memory 
// model.
//
/////////////////////////////////////////////////////////////////////

#include <stdio.h>              // for printf()
#include "sicl.h"		// Standard Instrument Control Library routines

#define DEVICE_ADDRESS "hpib7,0"   // Modify this line to match your setup

void main(void)
{
   INST id;                 	// device session id
   char buf[256] = { 0 };   	// read buffer for idn string

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

   // Install a default SICL error handler that logs an error message and
   // exits.  On Windows 95 view messages with the SICL Message Viewer,
   // and on Windows NT use the Windows NT Event Viewer.
   ionerror(I_ERROR_EXIT);	

   // Open a device session using the DEVICE_ADDRESS
   id = iopen(DEVICE_ADDRESS);

   // Set the I/O timeout value for this session to 1 second
   itimeout(id, 1000);
  
   // Write the *RST string (and send an EOI indicator) to put the instrument
   // in a known state.
   iprintf(id, "*RST\n");

   // Write the *IDN? string and send an EOI indicator, then read
   // the response into buf.  
   // For WIN16 programs, this will only work with the Large memory model 
   // since ipromptf expects to receive far pointers to the format strings.

   ipromptf(id, "*IDN?\n", "%t", buf);
   printf("%s\n", buf);

   iclose(id);

   // 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();
}

⌨️ 快捷键说明

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