pass_control.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /***************************************************************************
  2. lib/pass_control.c
  3. -------------------
  4. copyright : (C) 2002 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 my_pass_control( ibConf_t *conf, unsigned int pad, int sad )
  17. {
  18. uint8_t cmd;
  19. int retval;
  20. int i;
  21. i = InternalReceiveSetup( conf, packAddress( pad, sad ) );
  22. cmd = TCT;
  23. retval = my_ibcmd( conf, &cmd, 1 );
  24. if( retval < 0 ) return retval;
  25. retval = internal_ibgts( conf, 0 );
  26. return 0;
  27. }
  28. int ibpct( int ud )
  29. {
  30. ibConf_t *conf;
  31. ibBoard_t *board;
  32. int retval;
  33. conf = enter_library( ud );
  34. if( conf == NULL )
  35. return exit_library( ud, 1 );
  36. board = interfaceBoard( conf );
  37. if( conf->is_interface )
  38. {
  39. setIberr( EARG );
  40. return exit_library( ud, 1 );
  41. }
  42. retval = my_pass_control( conf, conf->settings.pad, conf->settings.sad );
  43. if( retval < 0 )
  44. return exit_library( ud, 1 );
  45. return exit_library( ud, 0 );
  46. }
  47. void PassControl( int boardID, Addr4882_t address )
  48. {
  49. ibConf_t *conf;
  50. ibBoard_t *board;
  51. int retval;
  52. conf = enter_library( boardID );
  53. if( conf == NULL )
  54. {
  55. exit_library( boardID, 1 );
  56. return;
  57. }
  58. if( addressIsValid( address ) == 0 )
  59. {
  60. exit_library( boardID, 1 );
  61. return;
  62. }
  63. board = interfaceBoard( conf );
  64. if( conf->is_interface == 0 )
  65. {
  66. setIberr( EARG );
  67. exit_library( boardID, 1 );
  68. return;
  69. }
  70. retval = my_pass_control( conf, extractPAD( address ), extractSAD( address ) );
  71. if( retval < 0 )
  72. {
  73. exit_library( boardID, 1 );
  74. return;
  75. }
  76. exit_library( boardID, 0 );
  77. }