GPIB: (very) basic ibfoo() library support

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Sun, 06 Feb 2005 18:12:14 +0100
I needed to get some data out from some of my measurement equipment
for some $work and the hacked up userland /dev/io code I have used
for some time just didn't cut it.

So now we have the skeleton of ibfoo() support in FreeBSD.  We only
support PCIIA compatible adapters, and only a very small subset of
the ibfoo() functions are implemented, but the framework has been
written so that both other hardware and more functions should be a
matter of very little work.

Completing this is on my wish-list, but only on my todo list to the
extent that I need it for something else.  Help to get this more
complete is most welcome!

The "wish list":

   o Complete more of the ibfoo() functions.
   o Support for different GPIB cards.
   o IEEE488.2 API implentation.
   o Manual pages.  (Either just reference the NI docs or rewrite it
     all to avoid copyright issues).

Reading material:

    http://www.ni.com/pdf/manuals/321038g.pdf 
    http://www.measurementcomputing.com/gpibhelp_Lib4881.html
    http://linux-gpib.sourceforge.net/doc_html/index.html

The following program should be able to pull out the identity of
any SCPI instrument which happens to sit on PAD21 on your GPIB bus,

	/* compile with:  cc -o ibtest ibtest.c -lgpib */

	#include <stdio.h>
	#include <err.h>
	#include <vis.h>

	#include <gpib/gpib.h>

	int
	main(int argc __unused, char **argv __unused)
	{
		int dmm;
		unsigned char buf[100];
		char vbuf[sizeof buf * 4];

		/* DVM */
		dmm = ibdev(0, 21, 0, T10s, 1, 0);
		if (dmm < 0)
			errx(1, "ibdev = %d\n", dmm);
		ibwrt(dmm, "*IDN?\r\n", 7);
		ibrd(dmm, buf, sizeof buf - 1);
		strvisx(vbuf, buf, ibcnt, VIS_WHITE | VIS_CSTYLE);
		printf("%s\n", vbuf);
		return (0);
	}

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Received on Sun Feb 06 2005 - 16:12:16 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:27 UTC