ibEos.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /***************************************************************************
  2. lib/ibEos.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 ibeos(int ud, int v)
  17. {
  18. ibConf_t *conf;
  19. conf = general_enter_library( ud, 1, 0 );
  20. if( conf == NULL )
  21. return general_exit_library( ud, 1, 0, 0, 0, 0, 1 );
  22. conf->settings.eos = v & 0xff;
  23. conf->settings.eos_flags = v & 0xff00;
  24. return general_exit_library( ud, 0, 0, 0, 0, 0, 1 );
  25. }
  26. int iblcleos( const ibConf_t *conf )
  27. {
  28. int use_eos, compare8;
  29. use_eos = conf->settings.eos_flags & REOS;
  30. compare8 = conf->settings.eos_flags & BIN;
  31. return config_read_eos( interfaceBoard( conf ), use_eos, conf->settings.eos, compare8 ) ;
  32. }
  33. int config_read_eos( ibBoard_t *board, int use_eos_char, int eos_char,
  34. int compare_8_bits )
  35. {
  36. eos_ioctl_t eos_cmd;
  37. int retval;
  38. eos_cmd.eos_flags = 0;
  39. if( use_eos_char )
  40. eos_cmd.eos_flags |= REOS;
  41. if( compare_8_bits )
  42. eos_cmd.eos_flags |= BIN;
  43. eos_cmd.eos = 0;
  44. if( use_eos_char )
  45. {
  46. eos_cmd.eos = eos_char;
  47. eos_cmd.eos &= 0xff;
  48. if( eos_cmd.eos != eos_char )
  49. {
  50. setIberr( EARG );
  51. fprintf(stderr, "libgpib: eos char more than 8 bits?\n");
  52. return -1;
  53. }
  54. }
  55. retval = ioctl( board->fileno, IBEOS, &eos_cmd );
  56. if( retval < 0 )
  57. {
  58. setIberr( EDVR );
  59. setIbcnt( errno );
  60. fprintf(stderr, "libgpib: IBEOS ioctl failed\n");
  61. }
  62. return retval;
  63. }