ibfoo.c revision 141777
1/*- 2 * Copyright (c) 2005 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * This file merely redirects to the file in <dev/ieee488/ugpib.h> 27 * 28 * $FreeBSD: head/lib/libgpib/ibfoo.c 141777 2005-02-12 23:52:44Z phk $ 29 */ 30 31#include <stdio.h> 32#include <errno.h> 33#include <err.h> 34#include <sys/types.h> 35#include <fcntl.h> 36 37#include <dev/ieee488/ugpib.h> 38#include <dev/ieee488/ibfoo_int.h> 39 40int ibcnt, iberr, ibsta; 41 42static int fd = -1; 43 44static int 45__ibsubmit(struct ibarg *ap) 46{ 47 int i; 48 49 if (fd < 0) 50 fd = open("/dev/gpib0ib", O_RDWR); 51 if (fd < 0) 52 err(1, "Could not open /dev/gpib0ib"); 53 i = ioctl(fd, GPIB_IBFOO, ap); 54 if (i) 55 err(1, "GPIB_IBFOO(%d, 0x%x) failed", ap->__ident, ap->__field); 56 ibcnt = ap->__ibcnt; 57 iberr = ap->__iberr; 58 ibsta = ap->__ibsta; 59 return (ap->__retval); 60} 61 62int 63ibask (int handle, int option, int * retval) 64{ 65 struct ibarg io; 66 67 io.__ident = __ID_IBASK; 68 io.handle = handle; 69 io.option = option; 70 io.retval = retval; 71 io.__field = __F_HANDLE | __F_OPTION | __F_RETVAL; 72 return (__ibsubmit(&io)); 73} 74 75int 76ibbna (int handle, char * bdname) 77{ 78 struct ibarg io; 79 80 io.__ident = __ID_IBBNA; 81 io.handle = handle; 82 io.bdname = bdname; 83 io.__field = __F_HANDLE | __F_BDNAME; 84 return (__ibsubmit(&io)); 85} 86 87int 88ibcac (int handle, int v) 89{ 90 struct ibarg io; 91 92 io.__ident = __ID_IBCAC; 93 io.handle = handle; 94 io.v = v; 95 io.__field = __F_HANDLE | __F_V; 96 return (__ibsubmit(&io)); 97} 98 99int 100ibclr (int handle) 101{ 102 struct ibarg io; 103 104 io.__ident = __ID_IBCLR; 105 io.handle = handle; 106 io.__field = __F_HANDLE; 107 return (__ibsubmit(&io)); 108} 109 110int 111ibcmd (int handle, void * buffer, long cnt) 112{ 113 struct ibarg io; 114 115 io.__ident = __ID_IBCMD; 116 io.handle = handle; 117 io.buffer = buffer; 118 io.cnt = cnt; 119 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 120 return (__ibsubmit(&io)); 121} 122 123int 124ibcmda (int handle, void * buffer, long cnt) 125{ 126 struct ibarg io; 127 128 io.__ident = __ID_IBCMDA; 129 io.handle = handle; 130 io.buffer = buffer; 131 io.cnt = cnt; 132 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 133 return (__ibsubmit(&io)); 134} 135 136int 137ibconfig (int handle, int option, int value) 138{ 139 struct ibarg io; 140 141 io.__ident = __ID_IBCONFIG; 142 io.handle = handle; 143 io.option = option; 144 io.value = value; 145 io.__field = __F_HANDLE | __F_OPTION | __F_VALUE; 146 return (__ibsubmit(&io)); 147} 148 149int 150ibdev (int boardID, int pad, int sad, int tmo, int eot, int eos) 151{ 152 struct ibarg io; 153 154 io.__ident = __ID_IBDEV; 155 io.boardID = boardID; 156 io.pad = pad; 157 io.sad = sad; 158 io.tmo = tmo; 159 io.eot = eot; 160 io.eos = eos; 161 io.__field = __F_BOARDID | __F_PAD | __F_SAD | __F_TMO | __F_EOT | __F_EOS; 162 return (__ibsubmit(&io)); 163} 164 165int 166ibdiag (int handle, void * buffer, long cnt) 167{ 168 struct ibarg io; 169 170 io.__ident = __ID_IBDIAG; 171 io.handle = handle; 172 io.buffer = buffer; 173 io.cnt = cnt; 174 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 175 return (__ibsubmit(&io)); 176} 177 178int 179ibdma (int handle, int v) 180{ 181 struct ibarg io; 182 183 io.__ident = __ID_IBDMA; 184 io.handle = handle; 185 io.v = v; 186 io.__field = __F_HANDLE | __F_V; 187 return (__ibsubmit(&io)); 188} 189 190int 191ibeos (int handle, int eos) 192{ 193 struct ibarg io; 194 195 io.__ident = __ID_IBEOS; 196 io.handle = handle; 197 io.eos = eos; 198 io.__field = __F_HANDLE | __F_EOS; 199 return (__ibsubmit(&io)); 200} 201 202int 203ibeot (int handle, int eot) 204{ 205 struct ibarg io; 206 207 io.__ident = __ID_IBEOT; 208 io.handle = handle; 209 io.eot = eot; 210 io.__field = __F_HANDLE | __F_EOT; 211 return (__ibsubmit(&io)); 212} 213 214int 215ibevent (int handle, short * event) 216{ 217 struct ibarg io; 218 219 io.__ident = __ID_IBEVENT; 220 io.handle = handle; 221 io.event = event; 222 io.__field = __F_HANDLE | __F_EVENT; 223 return (__ibsubmit(&io)); 224} 225 226int 227ibfind (char * bdname) 228{ 229 struct ibarg io; 230 231 io.__ident = __ID_IBFIND; 232 io.bdname = bdname; 233 io.__field = __F_BDNAME; 234 return (__ibsubmit(&io)); 235} 236 237int 238ibgts (int handle, int v) 239{ 240 struct ibarg io; 241 242 io.__ident = __ID_IBGTS; 243 io.handle = handle; 244 io.v = v; 245 io.__field = __F_HANDLE | __F_V; 246 return (__ibsubmit(&io)); 247} 248 249int 250ibist (int handle, int v) 251{ 252 struct ibarg io; 253 254 io.__ident = __ID_IBIST; 255 io.handle = handle; 256 io.v = v; 257 io.__field = __F_HANDLE | __F_V; 258 return (__ibsubmit(&io)); 259} 260 261int 262iblines (int handle, short * lines) 263{ 264 struct ibarg io; 265 266 io.__ident = __ID_IBLINES; 267 io.handle = handle; 268 io.lines = lines; 269 io.__field = __F_HANDLE | __F_LINES; 270 return (__ibsubmit(&io)); 271} 272 273int 274ibllo (int handle) 275{ 276 struct ibarg io; 277 278 io.__ident = __ID_IBLLO; 279 io.handle = handle; 280 io.__field = __F_HANDLE; 281 return (__ibsubmit(&io)); 282} 283 284int 285ibln (int handle, int padval, int sadval, short * listenflag) 286{ 287 struct ibarg io; 288 289 io.__ident = __ID_IBLN; 290 io.handle = handle; 291 io.padval = padval; 292 io.sadval = sadval; 293 io.listenflag = listenflag; 294 io.__field = __F_HANDLE | __F_PADVAL | __F_SADVAL | __F_LISTENFLAG; 295 return (__ibsubmit(&io)); 296} 297 298int 299ibloc (int handle) 300{ 301 struct ibarg io; 302 303 io.__ident = __ID_IBLOC; 304 io.handle = handle; 305 io.__field = __F_HANDLE; 306 return (__ibsubmit(&io)); 307} 308 309int 310ibonl (int handle, int v) 311{ 312 struct ibarg io; 313 314 io.__ident = __ID_IBONL; 315 io.handle = handle; 316 io.v = v; 317 io.__field = __F_HANDLE | __F_V; 318 return (__ibsubmit(&io)); 319} 320 321int 322ibpad (int handle, int v) 323{ 324 struct ibarg io; 325 326 io.__ident = __ID_IBPAD; 327 io.handle = handle; 328 io.v = v; 329 io.__field = __F_HANDLE | __F_V; 330 return (__ibsubmit(&io)); 331} 332 333int 334ibpct (int handle) 335{ 336 struct ibarg io; 337 338 io.__ident = __ID_IBPCT; 339 io.handle = handle; 340 io.__field = __F_HANDLE; 341 return (__ibsubmit(&io)); 342} 343 344int 345ibpoke (int handle, int option, int value) 346{ 347 struct ibarg io; 348 349 io.__ident = __ID_IBPOKE; 350 io.handle = handle; 351 io.option = option; 352 io.value = value; 353 io.__field = __F_HANDLE | __F_OPTION | __F_VALUE; 354 return (__ibsubmit(&io)); 355} 356 357int 358ibppc (int handle, int v) 359{ 360 struct ibarg io; 361 362 io.__ident = __ID_IBPPC; 363 io.handle = handle; 364 io.v = v; 365 io.__field = __F_HANDLE | __F_V; 366 return (__ibsubmit(&io)); 367} 368 369int 370ibrd (int handle, void * buffer, long cnt) 371{ 372 struct ibarg io; 373 374 io.__ident = __ID_IBRD; 375 io.handle = handle; 376 io.buffer = buffer; 377 io.cnt = cnt; 378 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 379 return (__ibsubmit(&io)); 380} 381 382int 383ibrda (int handle, void * buffer, long cnt) 384{ 385 struct ibarg io; 386 387 io.__ident = __ID_IBRDA; 388 io.handle = handle; 389 io.buffer = buffer; 390 io.cnt = cnt; 391 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 392 return (__ibsubmit(&io)); 393} 394 395int 396ibrdf (int handle, char * flname) 397{ 398 struct ibarg io; 399 400 io.__ident = __ID_IBRDF; 401 io.handle = handle; 402 io.flname = flname; 403 io.__field = __F_HANDLE | __F_FLNAME; 404 return (__ibsubmit(&io)); 405} 406 407int 408ibrdkey (int handle, void * buffer, int cnt) 409{ 410 struct ibarg io; 411 412 io.__ident = __ID_IBRDKEY; 413 io.handle = handle; 414 io.buffer = buffer; 415 io.cnt = cnt; 416 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 417 return (__ibsubmit(&io)); 418} 419 420int 421ibrpp (int handle, char * ppr) 422{ 423 struct ibarg io; 424 425 io.__ident = __ID_IBRPP; 426 io.handle = handle; 427 io.ppr = ppr; 428 io.__field = __F_HANDLE | __F_PPR; 429 return (__ibsubmit(&io)); 430} 431 432int 433ibrsc (int handle, int v) 434{ 435 struct ibarg io; 436 437 io.__ident = __ID_IBRSC; 438 io.handle = handle; 439 io.v = v; 440 io.__field = __F_HANDLE | __F_V; 441 return (__ibsubmit(&io)); 442} 443 444int 445ibrsp (int handle, char * spr) 446{ 447 struct ibarg io; 448 449 io.__ident = __ID_IBRSP; 450 io.handle = handle; 451 io.spr = spr; 452 io.__field = __F_HANDLE | __F_SPR; 453 return (__ibsubmit(&io)); 454} 455 456int 457ibrsv (int handle, int v) 458{ 459 struct ibarg io; 460 461 io.__ident = __ID_IBRSV; 462 io.handle = handle; 463 io.v = v; 464 io.__field = __F_HANDLE | __F_V; 465 return (__ibsubmit(&io)); 466} 467 468int 469ibsad (int handle, int sad) 470{ 471 struct ibarg io; 472 473 io.__ident = __ID_IBSAD; 474 io.handle = handle; 475 io.sad = v; 476 io.__field = __F_HANDLE | __F_SAD; 477 return (__ibsubmit(&io)); 478} 479 480int 481ibsgnl (int handle, int v) 482{ 483 struct ibarg io; 484 485 io.__ident = __ID_IBSGNL; 486 io.handle = handle; 487 io.v = v; 488 io.__field = __F_HANDLE | __F_V; 489 return (__ibsubmit(&io)); 490} 491 492int 493ibsic (int handle) 494{ 495 struct ibarg io; 496 497 io.__ident = __ID_IBSIC; 498 io.handle = handle; 499 io.__field = __F_HANDLE; 500 return (__ibsubmit(&io)); 501} 502 503int 504ibsre (int handle, int v) 505{ 506 struct ibarg io; 507 508 io.__ident = __ID_IBSRE; 509 io.handle = handle; 510 io.v = v; 511 io.__field = __F_HANDLE | __F_V; 512 return (__ibsubmit(&io)); 513} 514 515int 516ibsrq (ibsrq_t * func) 517{ 518 struct ibarg io; 519 520 io.__ident = __ID_IBSRQ; 521 io.func = func; 522 io.__field = __F_FUNC; 523 return (__ibsubmit(&io)); 524} 525 526int 527ibstop (int handle) 528{ 529 struct ibarg io; 530 531 io.__ident = __ID_IBSTOP; 532 io.handle = handle; 533 io.__field = __F_HANDLE; 534 return (__ibsubmit(&io)); 535} 536 537int 538ibtmo (int handle, int tmo) 539{ 540 struct ibarg io; 541 542 io.__ident = __ID_IBTMO; 543 io.handle = handle; 544 io.tmo = tmo; 545 io.__field = __F_HANDLE | __F_TMO; 546 return (__ibsubmit(&io)); 547} 548 549int 550ibtrap (int mask, int mode) 551{ 552 struct ibarg io; 553 554 io.__ident = __ID_IBTRAP; 555 io.mask = mask; 556 io.mode = mode; 557 io.__field = __F_MASK | __F_MODE; 558 return (__ibsubmit(&io)); 559} 560 561int 562ibtrg (int handle) 563{ 564 struct ibarg io; 565 566 io.__ident = __ID_IBTRG; 567 io.handle = handle; 568 io.__field = __F_HANDLE; 569 return (__ibsubmit(&io)); 570} 571 572int 573ibwait (int handle, int mask) 574{ 575 struct ibarg io; 576 577 io.__ident = __ID_IBWAIT; 578 io.handle = handle; 579 io.mask = mask; 580 io.__field = __F_HANDLE | __F_MASK; 581 return (__ibsubmit(&io)); 582} 583 584int 585ibwrt (int handle, const void *buffer, long cnt) 586{ 587 struct ibarg io; 588 589 io.__ident = __ID_IBWRT; 590 io.handle = handle; 591 io.buffer = __DECONST(void *, buffer); 592 io.cnt = cnt; 593 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 594 return (__ibsubmit(&io)); 595} 596 597int 598ibwrta (int handle, const void * buffer, long cnt) 599{ 600 struct ibarg io; 601 602 io.__ident = __ID_IBWRTA; 603 io.handle = handle; 604 io.buffer = __DECONST(void *, buffer); 605 io.cnt = cnt; 606 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 607 return (__ibsubmit(&io)); 608} 609 610int 611ibwrtf (int handle, const char *flname) 612{ 613 struct ibarg io; 614 615 io.__ident = __ID_IBWRTF; 616 io.handle = handle; 617 io.flname = __DECONST(void *, flname); 618 io.__field = __F_HANDLE | __F_FLNAME; 619 return (__ibsubmit(&io)); 620} 621 622int 623ibwrtkey (int handle, const void *buffer, int cnt) 624{ 625 struct ibarg io; 626 627 io.__ident = __ID_IBWRTKEY; 628 io.handle = handle; 629 io.buffer = __DECONST(void *, buffer); 630 io.cnt = cnt; 631 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 632 return (__ibsubmit(&io)); 633} 634 635int 636ibxtrc (int handle, void * buffer, long cnt) 637{ 638 struct ibarg io; 639 640 io.__ident = __ID_IBXTRC; 641 io.handle = handle; 642 io.buffer = buffer; 643 io.cnt = cnt; 644 io.__field = __F_HANDLE | __F_BUFFER | __F_CNT; 645 return (__ibsubmit(&io)); 646} 647 648