1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/***************************************************************************
lib/ibbna.c
-------------------
copyright : (C) 2002 by Frank Mori Hess
email : fmhess@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "ib_internal.h"
int my_ibbna(ibConf_t *conf, unsigned int new_board_index)
{
ibConf_t *board_conf;
int retval;
int old_board_index;
if (conf->is_interface) {
setIberr(EARG);
return -1;
}
retval = close_gpib_handle(conf);
if (retval < 0) {
setIberr(EDVR);
return -1;
}
board_conf = &ibFindConfigs[new_board_index];
if (board_conf->is_interface == 0) {
setIberr(EARG);
return -1;
}
retval = is_cic(interfaceBoard(board_conf));
if (retval <= 0) {
if (retval == 0)
setIberr(ECIC);
return -1;
}
old_board_index = conf->settings.board;
conf->settings.board = board_conf->settings.board;
if (ibBoardOpen(interfaceBoard(conf), conf->error_msg_disable) < 0) {
setIberr(EDVR);
return -1;
}
retval = open_gpib_handle(conf);
if(retval < 0) {
setIberr(EDVR);
return -1;
}
setIberr(old_board_index);
return 0;
}
int ibbna(int ud, char *board_name)
{
ibConf_t *conf;
int retval;
int find_index;
conf = enter_library(ud);
if(!conf)
return exit_library(ud, 1);
if((find_index = ibFindDevIndex(board_name)) < 0) {
setIberr(EARG);
return exit_library(ud, 1);
}
retval = my_ibbna(conf, find_index);
if(retval < 0)
return exit_library(ud, 1);
return exit_library(ud, 0);
}
|