ib_internal.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /***************************************************************************
  2. lib/ib_internal.h
  3. -------------------
  4. copyright : (C) 2001,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. #ifndef _IB_INTERNAL_H
  16. #define _IB_INTERNAL_H
  17. #include "ib.h"
  18. #include "ibP.h"
  19. #include "gpib_types.h"
  20. #include "gpib_ioctl.h"
  21. #include <unistd.h>
  22. #include <sys/ioctl.h>
  23. #include <assert.h>
  24. #include "ibConf.h"
  25. enum internal_gpib_addr
  26. {
  27. SAD_DISABLED = -1,
  28. ADDR_INVALID = -2
  29. };
  30. int my_wait( ibConf_t *conf, int wait_mask, int clear_mask, int set_mask, int *status );
  31. void init_async_op( struct async_operation *async );
  32. int ibBoardOpen( ibBoard_t *board );
  33. int ibBoardClose( ibBoard_t *board );
  34. int ibGetNrBoards(void);
  35. void yyerror(char *s);
  36. int iblcleos( const ibConf_t *conf );
  37. void ibPutMsg (char *format,...);
  38. void ibPutErrlog(int ud,char *routine);
  39. int ibParseConfigFile( void );
  40. int ibGetDescriptor(ibConf_t conf);
  41. int ibFindDevIndex( const char *name );
  42. ssize_t my_ibcmd( ibConf_t *conf, const uint8_t *buffer, size_t length);
  43. ssize_t my_ibrd( ibConf_t *conf, uint8_t *buffer, size_t count, size_t *bytes_read);
  44. int my_ibwrt( ibConf_t *conf, const uint8_t *buffer, size_t count, size_t *bytes_written);
  45. unsigned int send_setup_string( const ibConf_t *conf, uint8_t *cmdString );
  46. unsigned int create_send_setup( const ibBoard_t *board,
  47. const Addr4882_t addressList[], uint8_t *cmdString );
  48. int send_setup( ibConf_t *conf );
  49. void init_ibconf( ibConf_t *conf );
  50. void init_ibboard( ibBoard_t *board );
  51. int my_ibdev( ibConf_t new_conf );
  52. int my_ibbna( ibConf_t *conf, unsigned int new_board_index );
  53. unsigned int timeout_to_usec( enum gpib_timeout timeout );
  54. unsigned int ppoll_timeout_to_usec( unsigned int timeout );
  55. unsigned int usec_to_ppoll_timeout( unsigned int usec );
  56. int set_timeout( const ibBoard_t *board, unsigned int usec_timeout );
  57. int close_gpib_handle( ibConf_t *conf );
  58. int open_gpib_handle( ibConf_t *conf );
  59. int gpibi_change_address( ibConf_t *conf,
  60. unsigned int pad, int sad );
  61. int lock_board_mutex( ibBoard_t *board );
  62. int unlock_board_mutex( ibBoard_t *board );
  63. int conf_lock_board( ibConf_t *conf );
  64. void conf_unlock_board( ibConf_t *conf );
  65. int exit_library( int ud, int error );
  66. int general_exit_library( int ud, int error, int no_sync_globals, int no_update_ibsta,
  67. int status_clear_mask, int status_set_mask, int no_unlock_board );
  68. ibConf_t * enter_library( int ud );
  69. ibConf_t * general_enter_library( int ud, int no_lock_board, int ignore_eoip );
  70. void setIbsta( int status );
  71. void setIberr( int error );
  72. void setIbcnt( long count );
  73. unsigned int usec_to_timeout( unsigned int usec );
  74. int query_ppc( const ibBoard_t *board );
  75. int query_ist( const ibBoard_t *board );
  76. int query_pad( const ibBoard_t *board, unsigned int *pad );
  77. int query_sad( const ibBoard_t *board, int *sad );
  78. int conf_online( ibConf_t *conf, int online );
  79. int configure_autospoll( ibConf_t *conf, int enable );
  80. int extractPAD( Addr4882_t address );
  81. int extractSAD( Addr4882_t address );
  82. Addr4882_t packAddress( unsigned int pad, int sad );
  83. int addressIsValid( Addr4882_t address );
  84. int addressListIsValid( const Addr4882_t addressList[] );
  85. unsigned int numAddresses( const Addr4882_t addressList[] );
  86. int remote_enable( const ibBoard_t *board, int enable );
  87. int config_read_eos( ibBoard_t *board, int use_eos_char,
  88. int eos_char, int compare_8_bits );
  89. void sync_globals( void );
  90. int is_system_controller( const ibBoard_t *board );
  91. int is_cic( const ibBoard_t *board );
  92. int assert_ifc( ibBoard_t *board, unsigned int usec );
  93. int request_system_control( ibBoard_t *board, int request_control );
  94. int internal_ibpad( ibConf_t *conf, unsigned int address );
  95. int internal_ibsad( ibConf_t *conf, int address );
  96. int internal_ibtmo( ibConf_t *conf, int timeout );
  97. void internal_ibeot( ibConf_t *conf, int send_eoi );
  98. int internal_ibist( ibConf_t *conf, int ist );
  99. int internal_ibppc( ibConf_t *conf, int v );
  100. int internal_ibsre( ibConf_t *conf, int v );
  101. int internal_ibrsv( ibConf_t *conf, int v );
  102. int internal_iblines( ibConf_t *conf, short *line_status );
  103. int internal_ibgts( ibConf_t *conf, int shadow_handshake );
  104. int internal_ibrsc( ibConf_t *conf, int request_control );
  105. int internal_ibsic( ibConf_t *conf );
  106. int internal_ibstop( ibConf_t *conf );
  107. int InternalDevClearList( ibConf_t *conf, const Addr4882_t addressList[] );
  108. int InternalReceiveSetup( ibConf_t *conf, Addr4882_t address );
  109. int InternalSendSetup( ibConf_t *conf, const Addr4882_t addressList[] );
  110. int InternalSendList( ibConf_t *conf, const Addr4882_t addressList[],
  111. const void *buffer, long count, int eotmode );
  112. int InternalEnableRemote( ibConf_t *conf, const Addr4882_t addressList[] );
  113. int InternalReceive( ibConf_t *conf, Addr4882_t address,
  114. void *buffer, long count, int termination );
  115. static __inline__ ibBoard_t* interfaceBoard( const ibConf_t *conf )
  116. {
  117. assert( conf->settings.board >= 0 && conf->settings.board < GPIB_MAX_NUM_BOARDS );
  118. return &ibBoard[ conf->settings.board ];
  119. }
  120. #include <stdio.h>
  121. int gpib_yyparse(void *parse_arg);
  122. int parse_gpib_conf( const char *filename, ibConf_t *configs,
  123. unsigned int configs_length, ibBoard_t *boards, unsigned int boards_length );
  124. #define YY_DECL int gpib_yylex(YYSTYPE *gpib_lvalp, YYLTYPE *gpib_llocp, yyscan_t yyscanner)
  125. /* support for async io (ibrda() ibwrta(), etc.) */
  126. enum gpib_aio_varieties
  127. {
  128. GPIB_AIO_COMMAND,
  129. GPIB_AIO_READ,
  130. GPIB_AIO_WRITE,
  131. };
  132. int gpib_aio_launch( int ud, ibConf_t *conf, int gpib_aio_type,
  133. void *buffer, long cnt );
  134. int gpib_aio_join( struct async_operation *async );
  135. #endif /* _IB_INTERNAL_H */