summaryrefslogtreecommitdiffstats
path: root/lib/libgpib/gpib.3
blob: fef47c7da2bf02d04bebc6a88ab3a950e2b8f765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
.\" Copyright (c) 2010, Joerg Wunsch
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd February 1, 2010
.Dt GPIB 3
.Os
.Sh NAME
.\" .Nm ibask ,
.\" .Nm ibbna ,
.\" .Nm ibcac ,
.Nm ibclr ,
.\" .Nm ibcmd ,
.\" .Nm ibcmda ,
.\" .Nm ibconfig ,
.Nm ibdev ,
.\" .Nm ibdiag ,
.Nm ibdma ,
.Nm ibeos ,
.Nm ibeot ,
.\" .Nm ibevent ,
.\" .Nm ibfind ,
.\" .Nm ibgts ,
.\" .Nm ibist ,
.\" .Nm iblines ,
.\" .Nm ibllo ,
.\" .Nm ibln ,
.Nm ibloc ,
.Nm ibonl ,
.Nm ibpad ,
.\" .Nm ibpct ,
.\" .Nm ibpoke ,
.\" .Nm ibppc ,
.Nm ibrd ,
.\" .Nm ibrda ,
.\" .Nm ibrdf ,
.\" .Nm ibrdkey ,
.\" .Nm ibrpp ,
.\" .Nm ibrsc ,
.\" .Nm ibrsp ,
.\" .Nm ibrsv ,
.Nm ibsad ,
.\" .Nm ibsgnl ,
.Nm ibsic ,
.\" .Nm ibsre ,
.\" .Nm ibsrq ,
.\" .Nm ibstop ,
.Nm ibtmo ,
.\" .Nm ibtrap ,
.Nm ibtrg ,
.\" .Nm ibwait ,
.Nm ibwrt
.\" .Nm ibwrta ,
.\" .Nm ibwrtf ,
.\" .Nm ibwrtkey ,
.\" .Nm ibxtrc
.Nd "GPIB library"
.Sh LIBRARY
.Lb libgpib
.Sh SYNOPSIS
.In gpib.h
.Pp
.Dv extern int ibcnt ,
.Dv iberr ,
.Dv ibsta ;
.Pp
.Ft int
.Fn ibask "int handle" "int option" "int *retval"
.Ft int
.Fn ibbna "int handle" "char *bdname"
.Ft int
.Fn ibcac "int handle" "int v"
.Ft int
.Fn ibclr "int handle"
.Ft int
.Fn ibcmd "int handle" "void *buffer" "long cnt"
.Ft int
.Fn ibcmda "int handle" "void *buffer" "long cnt"
.Ft int
.Fn ibconfig "int handle" "int option" "int value"
.Ft int
.Fn ibdev "int boardID" "int pad" "int sad" "int tmo" "int eot" "int eos"
.Ft int
.Fn ibdiag "int handle" "void *buffer" "long cnt"
.Ft int
.Fn ibdma "int handle" "int v"
.Ft int
.Fn ibeos "int handle" "int eos"
.Ft int
.Fn ibeot "int handle" "int eot"
.Ft int
.Fn ibevent "int handle" "short *event"
.Ft int
.Fn ibfind "char *bdname"
.Ft int
.Fn ibgts "int handle" "int v"
.Ft int
.Fn ibist "int handle" "int v"
.Ft int
.Fn iblines "int handle" "short *lines"
.Ft int
.Fn ibllo "int handle"
.Ft int
.Fn ibln "int handle" "int padval" "int sadval" "short *listenflag"
.Ft int
.Fn ibloc "int handle"
.Ft int
.Fn ibonl "int handle" "int v"
.Ft int
.Fn ibpad "int handle" "int pad"
.Ft int
.Fn ibpct "int handle"
.Ft int
.Fn ibpoke "int handle" "int option" "int value"
.Ft int
.Fn ibppc "int handle" "int v"
.Ft int
.Fn ibrd "int handle" "void *buffer" "long cnt"
.Ft int
.Fn ibrda "int handle" "void *buffer" "long cnt"
.Ft int
.Fn ibrdf "int handle" "char *flname"
.Ft int
.Fn ibrdkey "int handle" "void *buffer" "int cnt"
.Ft int
.Fn ibrpp "int handle" "char *ppr"
.Ft int
.Fn ibrsc "int handle" "int v"
.Ft int
.Fn ibrsp "int handle" "char *spr"
.Ft int
.Fn ibrsv "int handle" "int v"
.Ft int
.Fn ibsad "int handle" "int sad"
.Ft int
.Fn ibsgnl "int handle" "int v"
.Ft int
.Fn ibsic "int handle"
.Ft int
.Fn ibsre "int handle" "int v"
.Ft int
.Fn ibsrq "(*func) void)"
.Ft int
.Fn ibstop "int handle"
.Ft int
.Fn ibtmo "int handle" "int tmo"
.Ft int
.Fn ibtrap "int  mask" "int mode"
.Ft int
.Fn ibtrg "int handle"
.Ft int
.Fn ibwait "int handle" "int mask"
.Ft int
.Fn ibwrt "int handle" "const void *buffer" "long cnt"
.Ft int
.Fn ibwrta "int handle" "const void *buffer" "long cnt"
.Ft int
.Fn ibwrtf "int handle" "const char *flname"
.Ft int
.Fn ibwrtkey "int handle" "const void *buffer" "int cnt"
.Ft int
.Fn ibxtrc "int handle" "void *buffer" "long cnt"
.Sh DESCRIPTION
The
.Nm
library provides access to the
.Xr gpib 4
kernel devices.
.Ss Variable Description
The variable
.Dv ibcnt
contains the number of bytes transferred in the most recent call to
.Fn ibcmd ,
.Fn ibrd ,
or
.Fn ibwrt .
.Pp
The name
.Dv ibcntl
is an alias for
.Dv ibcnt ,
provided for backwards compatibility.
.Pp
The variable
.Dv iberr
provides an error code for the most recent library call.
The possible error codes are:
.Bl -tag -offset indent -compact
.It EDVR
System error
.It ECIC
Not Active Controller
.It ENOL
Nobody listening
.It EADR
Controller not addressed
.It EARG
Invalid argument
.It ESAC
Not System Controller
.It EABO
I/O Aborted/Time out
.It ENEB
No such controller
.It EOIP
Async I/O in progress
.It ECAP
No such capability
.It EFSO
File system error
.It EBUS
Command byte xfer error
.It ESTB
Serial poll status byte lost
.It ESRQ
SRQ line stuck
.It ETAB
Table problem
.El
.Pp
The variable
.Dv ibsta
contains the controller status.
This is an ORed status value, with the following individual bit names:
.Bl -tag -offset indent -compact
.It ERR
Error
.It TIMO
Timeout
.It END
EOI/EOS
.It SRQI
SRQ
.It RQS
Device requests service
.It SPOLL
Serial Poll
.It EVENT
Event occurred
.It CMPL
I/O complete
.It LOK
Lockout
.It REM
Remote
.It CIC
CIC
.It ATN
ATN
.It TACS
Talker
.It LACS
Listener
.It DTAS
Device trigger status
.It DCAS
Device clear state
.El
.Ss Function Description
The function
.Fn ibdev
is used to open the GPIB device, and establish the parameters to
communicate with a particular bus device. The device is selected
by its primary address
.Fa pad ,
a numerical value between 0 and 30, possibly additionally by its
secondary address
.Fa sad ,
a numerical value between 96 and 126, or 0 to not use secondary
addressing.
The
.Fa tmo
value specifies the timeout to use when communicating with the device.
This can be any of the constants
.Dv TNONE ,
.Dv T10us ,
.Dv T30us ,
.Dv T100us ,
.Dv T300us ,
.Dv T1ms ,
.Dv T3ms ,
.Dv T10ms ,
.Dv T30ms ,
.Dv T100ms ,
.Dv T300ms ,
.Dv T1s ,
.Dv T3s ,
.Dv T10s ,
.Dv T30s ,
.Dv T100s ,
.Dv T300s ,
or
.Dv T1000s .
The boolean parameter
.Fa eot
specifies whether the bus signal
.Li EOI
(end-or-identify) should be asserted when sending the last byte of a
message to the device.
Finally, the
.Fa eos
parameter determines whether any special character should be used to
identify the end of a device message when transferring messages on the
bus.
The lower 8 bits of
.Fa eos
are interpreted as an end-of-string character,
.Li EOS .
This character can be ORed with the following values:
.Bl -tag -compact -offset indent
.It Dv REOS
When receiving a message byte on the bus that matches the
.Li EOS
character, treat it as if the
.Li EOI
signal were asserted, and stop receiving.
.It Dv XEOS
When transmitting a message byte on the bus that matches the
.Li EOS
character, assert the
.Li EOI
bus signal by the same time, and stop sending.
.It Dv BIN
If set, include all 8 bits of the
.Li EOS
character in the comparison; if unset, compare only 7 bit ASCII
values.
.El
Passing 0 as
.Fa eos
will turn off any special character treatment, allowing for a fully
8-bit transparent communications channel to the device.
.Pp
The function
.Fn ibfind
is meant to find the
.Em board index
of a board identified by the name
.Fa bdname .
.Em This function is currently not implemented.
.Pp
All remaining functions take the handle returned by calling
.Fn ibdev
as their first argument
.Fa handle .
.Pp
The function
.Fn ibask
is used to query configuration values that have been set with
.Fn ibconfig .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibbna
is meant to change the access board for the given device to
a new one, named
.Fa bdname .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibcac
is used to become the active controller on the bus, by asserting the
.Li ATN
signal line.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibclr
is used to transmit a
.Em Selected Device Clear
command to the device.
.Pp
The function
.Fn ibcmd
is used to directly write
.Fa cnt
GPIB command bytes from a buffer starting at
.Fa buffer
to the device.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibcmda
does the same as
.Fn ibcmd
except it operates asynchronously, so it returns to the caller
immediately.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibconfig
is used to set certain configuration parameters.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibdiag
is obsolete, and not implemented.
.Pp
The function
.Fn ibdma
is used to enable or disable DMA transfers.
Parameter
.Fa v
is a boolean parameter indicating DMA transfers are to be used.
Depending on the hardware and operating system configuration, DMA
transfers might not be available for a particular access board.
.Pp
The function
.Fn ibeos
configures the end-of-string character.
See
.Fn ibdev
for an explanation.
.Pp
The function
.Fn ibeot
configures the assertion of the
.Li EOI
signal line when transmitting the last byte of a message; see
.Fn ibdev
for an explanation.
.Pp
The function
.Fn ibevent
is used to obtain an event from the board's event queue.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibgts
makes the current controller the standby controller, by deasserting
the
.Li ATN
signal line.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibist
sets the individual status bits of the controller to the value
.Fa v .
.Em This function is currently not implemented.
.Pp
The function
.Fn iblines
returns the status of the control and handshake bus lines into the
area pointed to by
.Fa lines .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibllo
is obsolete, and not implemented.
.Pp
The function
.Fn ibln
checks for a listener at the primary address
.Fa  padval
and the optional secondary address
.Fa sadval .
If a listener was found, the value pointed to by
.Fa listenflag
will be set to a non-zero value.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibloc
turns the device into local mode.
.Pp
The function
.Fn ibonl
is used to close or reinitialize a device handle.
If parameter
.Fa v
is passed as zero, the handle will be closed, and cannot be used
again.
If it is passed as a non-zero value, all parameters of the handle
will be returned to their defaults;
.Em this functionality is currently unsupported.
.Pp
The function
.Fn ibpad
is used to change the primary address of the device being communicated
with to
.Fa pad .
See
.Fn ibdev
for an explanation.
.Pp
The function
.Fn ibpct
is used to make the device associated with the handle the
controller-in-charge.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibpoke
is obsolete, and not implemented.
.Pp
The function
.Fn ibppc
is used to configure the parallel poll response to
.Fa v .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrd
is used to receive
.Fa cnt
bytes from the device, and store it to the address passed as
.Fa buffer .
.Pp
The function
.Fn ibrda
behaves similar to
.Fn ibrd
except it operates asynchronously, and returns immediately to the
caller.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrdf
read data from the device, and appends it to the file with the name
.Fa flname .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrdkey
is obsolete, and not implemented.
.Pp
The function
.Fn ibrpp
performs a parallel poll, and stores the result at the location
pointed to by
.Fa ppr .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrsc
makes the board specified by the handle the
.Em system controller
if the argument
.Fa v
is non-zero.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrsp
conducts a serial poll, and stores the result in the byte pointed
to by
.Fa spr .
.Em This function is currently not implemented.
.Pp
The function
.Fn ibrsv
sets the serial poll response of the board to
.Fa v ,
possibly requesting service from the controller if the SRQ bit (0x40)
is set.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibsad
changes the secondary address of the device being communicated with to
.Fa sad .
See
.Fn ibdev
for an explanation.
.Pp
The function
.Fn ibsgnl
is obsolete, and not implemented.
.Pp
The function
.Fn ibsic
asserts the
.Em Interface Clear (IFC)
signal line on the bus for at least 100 microseconds.
This will make all devices attached to the bus to unlisten and untalk.
This function should only be executed on the system controller.
.Pp
The function
.Fn ibsre
asserts the
.Em Remote Enable (REN)
signal line on the bus if argument
.Fa v
is non-zero, or deasserts it otherwise.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibsrq
is obsolete, and not implemented.
.Pp
The function
.Fn ibstop
stops or aborts any asynchronous I/O operation.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibtmo
reconfigures the communication timeout.
See
.Fn ibdev
for an explanation.
.Pp
The function
.Fn ibtrap
is obsolete, and not implemented.
.Pp
The function
.Fn ibtrg
sends a
.Em Group Execute Trigger (GET)
command to the device.
.Pp
The function
.Fn ibwait
waits for a status condition as specified by
.Fa mask .
If
.Fa mask
is given as zero, it returns immediately.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibwrt
is used to send
.Fa cnt
bytes to the device, starting at the address pointed to by
.Fa buffer .
.Pp
The function
.Fn ibwrta
performs the same operation as
.Fn ibwrt
in an asynchronous way, returning immediately to the caller.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibwrtf
opens the file named by
.Fa flname ,
and sends its contents to the device.
.Em This function is currently not implemented.
.Pp
The function
.Fn ibwrtkey
is obsolete, and not implemented.
.Pp
The function
.Fn ibxtrc
is obsolete, and not implemented.
.Sh RETURN VALUES
The function
.Fn ibdev
returns a handle to be used for the remaining functions.
Upon failure, -1 is returned.
.Pp
All other functions return the value of the variable
.Dv ibsta .
.Sh DIAGNOSTICS
None.
.Sh COMPATIBILITY
The
.Nm
library tries to be compatible with the Linux GPIB library,
which in turn appears to be compatible with the GPIB library
shipped by National Instruments.
.Sh ERRORS
Errors in the functions above might set
.Dv errno
to one of these values:
.Bl -tag -width Er
.It Bq Er ENOENT
No such file or directory.
.It Bq Er EIO
Input/output error.
.It Bq Er ENXIO
Device not configured.
.It Bq Er E2BIG
Argument list too long.
.It Bq Er ENOMEM
Cannot allocate memory.
.It Bq Er EACCES
Permission denied.
.It Bq Er EFAULT
Bad address.
.It Bq Er EBUSY
Device busy.
.It Bq Er EINVAL
Invalid argument.
.It Bq Er ENFILE
Too many open files in system.
.It Bq Er EMFILE
Too many open files.
.It Bq Er EOPNOTSUPP
Operation not supported.
.El
.Sh SEE ALSO
.Xr gpib 4
.Sh HISTORY
The
.Nm
library was written by
.An Poul-Henning Kamp
and first appeared in
.Fx 5.4 .
.Sh AUTHORS
This manual page was written by
.An J\(:org Wunsch .
.Sh BUGS
Currently, the library can only handle a single
.Xr gpib 4
device with instance number 0.
.Pp
Many functions are currently not implemented, see above for details.
OpenPOWER on IntegriCloud