Files
sics/nigpib.c
koennecke b26b8fc735 - Changed strncpy to strlcpy, strncat to strlcat
- Added strlcpy and strlcat to SICS
- Added a driver for the POLDI power supplies


SKIPPED:
	psi/A1931.c
	psi/autowin.c
	psi/bruker.c
	psi/docho.c
	psi/dornier2.c
	psi/dspcode.c
	psi/ease.c
	psi/ecb.c
	psi/ecbcounter.c
	psi/ecbdriv.c
	psi/el734dc.c
	psi/el734driv.c
	psi/el734hp.c
	psi/el737driv.c
	psi/el737hpdriv.c
	psi/el737hpdrivsps.c
	psi/el737hpv2driv.c
	psi/el755driv.c
	psi/eurodriv.c
	psi/haakedriv.c
	psi/itc4driv.c
	psi/julcho.c
	psi/linadriv.c
	psi/lmd200.c
	psi/lscsupport.c
	psi/ltc11.c
	psi/make_gen
	psi/oicom.c
	psi/oxinst.c
	psi/pimotor.c
	psi/pipiezo.c
	psi/polterwrite.c
	psi/psi.c
	psi/sanscook.c
	psi/sanslirebin.c
	psi/sanswave.c
	psi/sinqhmdriv.c
	psi/sinqhttp.c
	psi/slsecho.c
	psi/slsmagnet.c
	psi/slsvme.c
	psi/sps.c
	psi/swmotor.c
	psi/swmotor2.c
	psi/tabledrive.c
	psi/tasscan.c
	psi/tdchm.c
	psi/velodorn.c
	psi/velodornier.c
2010-04-13 15:08:38 +00:00

121 lines
2.7 KiB
C

/*
This is an implementation of a GPIB driver based on the drivers
provided by National Instruments. The driver has been tested
with the ENET-100 GPIB-TCP/IP bridge but should also work with
NI GPIB boards plugged into the composter.
copright: see file COPYRIGHT
Mark Koennecke, January 2002
*/
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <tcl.h>
#include "fortify.h"
#include "sics.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 devID;
devID = ibdev(boardNo, address, secondaryAddress, tmo, eot, eos);
if (devID < 0) {
return -iberr;
} else {
return devID;
}
}
/*---------------------------------------------------------------------*/
static int NIdetach(int devID)
{
int status;
status = ibonl(devID, 0);
if (status & ERR) {
return -iberr;
} else {
return 1;
}
}
/*-------------------------------------------------------------------*/
static int NIwrite(int devID, void *buffer, int bytesToWrite)
{
int status;
status = ibwrt(devID, buffer, bytesToWrite);
if (status & ERR) {
return -iberr;
} else {
return 1;
}
}
/*-------------------------------------------------------------------*/
static int NIread(int devID, void *buffer, int bytesToRead)
{
int status;
status = ibrd(devID, buffer, bytesToRead);
if (status & ERR) {
return -iberr;
} else {
return 1;
}
}
/*--------------------------------------------------------------------*/
static int NIclear(int devID)
{
ibclr(devID);
return 1;
}
/*-----------------------------------------------------------------*/
static void NIerror(int code, char *buffer, int maxBuffer)
{
int flag = -code;
switch (flag) {
case EDVR:
case ENEB:
case ECIC:
strlcpy(buffer, "NI-GPIB not correctly installed or bad address",
maxBuffer);
return;
case EABO:
strlcpy(buffer, "Timeout on data transfer", maxBuffer);
return;
case EBUS:
strlcpy(buffer, "No device connected to GPIB or address errror",
maxBuffer);
return;
case ENOL:
strlcpy(buffer, "No listeners on bus. Perhaps address error?",
maxBuffer);
return;
default:
strlcpy(buffer, "Unrecognised error code, fix nigpib.c", maxBuffer);
break;
}
}
/*------------------------------------------------------------------*/
void NIassign(pGPIB self)
{
self->attach = NIattach;
self->detach = NIdetach;
self->send = NIwrite;
self->read = NIread;
self->getErrorDescription = NIerror;
self->clear = NIclear;
}