Files
sics/intserv.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

120 lines
2.6 KiB
C

/*--------------------------------------------------------------------------
The server side implementation of the Interrupt module.
As future version of this module may support adding interrupt
handlers, the necessary precautions are made, by keeping the
interrupt handlers in an array of function pointers. Is
quick as well.
Mark Koennecke, November 1996
Revised: Mark Koennecke, September 1997
Copyright: see copyright.h
Labor fuer Neutronenstreuung
Paul Scherrer Institut
CH-5423 Villigen-PSI
-----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <strlutil.h>
#include "fortify.h"
#include "conman.h"
#include "SCinter.h"
#include "nserver.h"
#include "obdes.h"
#include "network.h"
#include "interrupt.h"
#include "status.h"
#include "splitter.h"
#include "configfu.h"
#include "devexec.h"
#include "servlog.h"
#include "nread.h"
#include "task.h"
#include "event.h"
#define MAXINTERRUPT 7
#define INTERUPTWAIT 5
static mkChannel *IntPort = NULL;
static pTaskMan pTask = NULL;
/*----------------------------------------------------------------------------*/
static char *pIntText[] = {
"continue",
"abortop",
"abortscan",
"abortbatch",
"halt",
"free",
"end",
NULL
};
/*---------------------------------------------------------------------------*/
int ServerSetupInterrupt(int iPort, pNetRead pNet, pTaskMan pTasker)
{
int i;
pTask = pTasker;
/* setup interrupt port */
IntPort = UDPOpen(iPort);
if (IntPort == NULL) {
return 0;
} else {
NetReadRegister(pNet, IntPort, udp, NULL);
return 1;
}
}
/*--------------------------------------------------------------------------*/
void ServerStopInterrupt(void)
{
/* close the port */
if (IntPort) {
NETClosePort(IntPort);
free(IntPort);
}
}
/*-------------------------------------------------------------------------*/
void SetInterrupt(int iCode)
{
int iInt;
iInt = iCode;
TaskSignal(pTask, SICSINT, &iInt);
}
/*--------------------------------------------------------------------------*/
int Interrupt2Text(int iInterrupt, char *text, int iTextLen)
{
if ((iInterrupt < 0) || (iInterrupt > MAXINTERRUPT)) {
return 0;
}
strlcpy(text, pIntText[iInterrupt], iTextLen - 1);
return 1;
}
/*-------------------------------------------------------------------------*/
int Text2Interrupt(char *text)
{
int i = 0;
while (pIntText[i] != NULL) {
if (strcmp(pIntText[i], text) == 0) {
break;
}
i++;
}
if (i >= MAXINTERRUPT) {
return -1;
}
return i;
}