From owner-freebsd-current@FreeBSD.ORG Sun Feb 6 17:12:16 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D05816A4CE; Sun, 6 Feb 2005 17:12:16 +0000 (GMT) Received: from critter.freebsd.dk (f170.freebsd.dk [212.242.86.170]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FD3B43D54; Sun, 6 Feb 2005 17:12:15 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.1/8.13.1) with ESMTP id j16HCEVO090777; Sun, 6 Feb 2005 18:12:14 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: current@freebsd.org, hacker@freebsd.org From: Poul-Henning Kamp Date: Sun, 06 Feb 2005 18:12:14 +0100 Message-ID: <90776.1107709934@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Subject: GPIB: (very) basic ibfoo() library support X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2005 17:12:16 -0000 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 #include #include #include 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@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.