- Adapted indenation to new agreed upon system
- Added support for second generation scriptcontext based counter
This commit is contained in:
76
nigpib.c
76
nigpib.c
@ -15,90 +15,102 @@
|
||||
#include <tcl.h>
|
||||
#include "fortify.h"
|
||||
#include "sics.h"
|
||||
#include <ugpib.h>
|
||||
#include <ugpib.h>
|
||||
#include "gpibcontroller.i"
|
||||
|
||||
typedef struct __GPIB *pGPIB;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int NIattach(int boardNo, int address, int secondaryAddress,
|
||||
int tmo, int eot, int eos){
|
||||
int tmo, int eot, int eos)
|
||||
{
|
||||
int devID;
|
||||
|
||||
devID = ibdev(boardNo, address, secondaryAddress, tmo, eot, eos);
|
||||
if(devID < 0){
|
||||
if (devID < 0) {
|
||||
return -iberr;
|
||||
} else {
|
||||
return devID;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int NIdetach(int devID){
|
||||
static int NIdetach(int devID)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = ibonl(devID, 0);
|
||||
if(status & ERR){
|
||||
if (status & ERR) {
|
||||
return -iberr;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int NIwrite(int devID, void *buffer, int bytesToWrite){
|
||||
static int NIwrite(int devID, void *buffer, int bytesToWrite)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = ibwrt(devID,buffer,bytesToWrite);
|
||||
if(status & ERR){
|
||||
return - iberr;
|
||||
} else {
|
||||
|
||||
status = ibwrt(devID, buffer, bytesToWrite);
|
||||
if (status & ERR) {
|
||||
return -iberr;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int NIread(int devID, void *buffer, int bytesToRead){
|
||||
static int NIread(int devID, void *buffer, int bytesToRead)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = ibrd(devID,buffer,bytesToRead);
|
||||
if(status & ERR){
|
||||
return - iberr;
|
||||
} else {
|
||||
|
||||
status = ibrd(devID, buffer, bytesToRead);
|
||||
if (status & ERR) {
|
||||
return -iberr;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int NIclear(int devID){
|
||||
static int NIclear(int devID)
|
||||
{
|
||||
ibclr(devID);
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
static void NIerror(int code, char *buffer, int maxBuffer){
|
||||
int flag = - code;
|
||||
|
||||
switch(flag){
|
||||
/*-----------------------------------------------------------------*/
|
||||
static void NIerror(int code, char *buffer, int maxBuffer)
|
||||
{
|
||||
int flag = -code;
|
||||
|
||||
switch (flag) {
|
||||
case EDVR:
|
||||
case ENEB:
|
||||
case ECIC:
|
||||
strncpy(buffer,"NI-GPIB not correctly installed or bad address",
|
||||
maxBuffer);
|
||||
strncpy(buffer, "NI-GPIB not correctly installed or bad address",
|
||||
maxBuffer);
|
||||
return;
|
||||
case EABO:
|
||||
strncpy(buffer,"Timeout on data transfer",maxBuffer);
|
||||
strncpy(buffer, "Timeout on data transfer", maxBuffer);
|
||||
return;
|
||||
case EBUS:
|
||||
strncpy(buffer,"No device connected to GPIB or address errror",
|
||||
maxBuffer);
|
||||
strncpy(buffer, "No device connected to GPIB or address errror",
|
||||
maxBuffer);
|
||||
return;
|
||||
case ENOL:
|
||||
strncpy(buffer,"No listeners on bus. Perhaps address error?",
|
||||
maxBuffer);
|
||||
strncpy(buffer, "No listeners on bus. Perhaps address error?",
|
||||
maxBuffer);
|
||||
return;
|
||||
default:
|
||||
strncpy(buffer,"Unrecognised error code, fix nigpib.c",
|
||||
maxBuffer);
|
||||
strncpy(buffer, "Unrecognised error code, fix nigpib.c", maxBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
void NIassign(pGPIB self){
|
||||
void NIassign(pGPIB self)
|
||||
{
|
||||
self->attach = NIattach;
|
||||
self->detach = NIdetach;
|
||||
self->send = NIwrite;
|
||||
|
Reference in New Issue
Block a user