ibPad.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /***************************************************************************
  2. lib/ibPad.c
  3. -------------------
  4. copyright : (C) 2001,2002,2003 by Frank Mori Hess
  5. email : fmhess@users.sourceforge.net
  6. ***************************************************************************/
  7. /***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #include "ib_internal.h"
  16. int internal_ibpad( ibConf_t *conf, unsigned int address )
  17. {
  18. ibBoard_t *board;
  19. int retval;
  20. board = interfaceBoard( conf );
  21. if( address > 30 )
  22. {
  23. setIberr( EARG );
  24. fprintf( stderr, "libgpib: invalid gpib address\n" );
  25. return -1;
  26. }
  27. retval = gpibi_change_address( conf, address, conf->settings.sad );
  28. if( retval < 0 )
  29. {
  30. fprintf( stderr, "libgpib: failed to change gpib address\n" );
  31. return -1;
  32. }
  33. return 0;
  34. }
  35. int ibpad( int ud, int addr )
  36. {
  37. ibConf_t *conf;
  38. int retval;
  39. conf = enter_library( ud );
  40. if( conf == NULL )
  41. return exit_library( ud, 1 );
  42. retval = internal_ibpad( conf, addr );
  43. if( retval < 0 )
  44. {
  45. return exit_library( ud, 1 );
  46. }
  47. return exit_library( ud, 0 );
  48. }