From owner-svn-src-all@FreeBSD.ORG Mon Jan 25 06:37:44 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0C4B1065679; Mon, 25 Jan 2010 06:37:44 +0000 (UTC) (envelope-from joerg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E001B8FC15; Mon, 25 Jan 2010 06:37:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0P6biiA075836; Mon, 25 Jan 2010 06:37:44 GMT (envelope-from joerg@svn.freebsd.org) Received: (from joerg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0P6bi6Y075834; Mon, 25 Jan 2010 06:37:44 GMT (envelope-from joerg@svn.freebsd.org) Message-Id: <201001250637.o0P6bi6Y075834@svn.freebsd.org> From: Joerg Wunsch Date: Mon, 25 Jan 2010 06:37:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202962 - head/share/man/man4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2010 06:37:45 -0000 Author: joerg Date: Mon Jan 25 06:37:44 2010 New Revision: 202962 URL: http://svn.freebsd.org/changeset/base/202962 Log: Add an example, derived from the basic demo phk once sent me. Modified: head/share/man/man4/gpib.4 Modified: head/share/man/man4/gpib.4 ============================================================================== --- head/share/man/man4/gpib.4 Mon Jan 25 06:18:31 2010 (r202961) +++ head/share/man/man4/gpib.4 Mon Jan 25 06:37:44 2010 (r202962) @@ -44,6 +44,39 @@ IEC-625 (or just "IEC bus"), or HP-IB (H Bus), or GPIB (General Purpose Instrument Bus). The device can become either a listener, talker, controller, and in particular a master controller on the bus. +.Ss Example +The following example code queries the device provided as +.Va argv[1] +for its identification response. +.Bd -literal +/* compile with: cc -O -o ibtest ibtest.c -lgpib */ + +#include +#include +#include +#include + +#include + +int +main(int argc, char **argv) +{ + int dmm; + unsigned char buf[100]; + char vbuf[sizeof buf * 4]; + + /* DVM */ + dmm = ibdev(0, (argc > 1? atoi(argv[1]): 7), 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); +} +.Ed .Sh FILES .Bl -tag -width /dev/gpibNNib .It Pa /dev/gpib Ns Em N Ns "ib"