summaryrefslogtreecommitdiffstats
path: root/share/man/man4/gpib.4
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2010-01-25 06:37:44 +0000
committerjoerg <joerg@FreeBSD.org>2010-01-25 06:37:44 +0000
commit048b796ee5ec4c61205ae039484da25230762f4f (patch)
tree2cc505734644d54e0a9402e61852637c656cda48 /share/man/man4/gpib.4
parent627ca92735e5359e6f20b6c910538b5b82e36a3a (diff)
downloadFreeBSD-src-048b796ee5ec4c61205ae039484da25230762f4f.zip
FreeBSD-src-048b796ee5ec4c61205ae039484da25230762f4f.tar.gz
Add an example, derived from the basic demo phk once sent me.
Diffstat (limited to 'share/man/man4/gpib.4')
-rw-r--r--share/man/man4/gpib.433
1 files changed, 33 insertions, 0 deletions
diff --git a/share/man/man4/gpib.4 b/share/man/man4/gpib.4
index e5e7a1b..1e84381 100644
--- a/share/man/man4/gpib.4
+++ b/share/man/man4/gpib.4
@@ -44,6 +44,39 @@ IEC-625 (or just "IEC bus"), or HP-IB (Hewlett Packard Instrument
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 <stdio.h>
+#include <stdlib.h>
+#include <err.h>
+#include <vis.h>
+
+#include <gpib/gpib.h>
+
+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"
OpenPOWER on IntegriCloud