- New batch file management module
- New oscillator module - Bug fixes
This commit is contained in:
5
buffer.c
5
buffer.c
@ -283,7 +283,10 @@
|
|||||||
iInt = InterpExecute(pSics,pCon,pPtr);
|
iInt = InterpExecute(pSics,pCon,pPtr);
|
||||||
if(!iInt)
|
if(!iInt)
|
||||||
{
|
{
|
||||||
iRes = 0;
|
if(SCGetInterrupt(pCon) > eAbortBatch) {
|
||||||
|
iRes = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
iRet = LLDnodePtr2Next(self->iLineList);
|
iRet = LLDnodePtr2Next(self->iLineList);
|
||||||
}
|
}
|
||||||
|
30
el734hp.c
30
el734hp.c
@ -55,6 +55,8 @@
|
|||||||
float lastValue;
|
float lastValue;
|
||||||
int errorCode;
|
int errorCode;
|
||||||
int oredMsr;
|
int oredMsr;
|
||||||
|
int posCount;
|
||||||
|
int runCount;
|
||||||
} EL734Driv, *pEL734Driv;
|
} EL734Driv, *pEL734Driv;
|
||||||
/*------------------- error codes ----------------------------------*/
|
/*------------------- error codes ----------------------------------*/
|
||||||
#define BADADR -1
|
#define BADADR -1
|
||||||
@ -71,6 +73,7 @@
|
|||||||
#define RUNFAULT -12
|
#define RUNFAULT -12
|
||||||
#define POSFAULT -13
|
#define POSFAULT -13
|
||||||
#define BADCUSHION -14
|
#define BADCUSHION -14
|
||||||
|
#define BADCOUNT -15
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static int checkResponse(pEL734Driv self, char *pReply){
|
static int checkResponse(pEL734Driv self, char *pReply){
|
||||||
/*
|
/*
|
||||||
@ -142,11 +145,18 @@ static int EL734Run(void *pData,float fValue){
|
|||||||
if(!checkResponse(self,pReply)){
|
if(!checkResponse(self,pReply)){
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
|
self->posCount =0;
|
||||||
|
self->runCount = 0;
|
||||||
return OKOK;
|
return OKOK;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
static int decodeMSR(pEL734Driv self, int msr){
|
static int decodeMSR(pEL734Driv self, int msr){
|
||||||
if (msr == 0){
|
if (msr == 0){
|
||||||
|
if(self->posCount > 0 || self->runCount > 0){
|
||||||
|
self->errorCode = BADCOUNT;
|
||||||
|
return HWPosFault;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
we are done: check ored_msr for troubles
|
we are done: check ored_msr for troubles
|
||||||
*/
|
*/
|
||||||
@ -187,6 +197,15 @@ static int decodeMSR(pEL734Driv self, int msr){
|
|||||||
/*
|
/*
|
||||||
we are still tugging along ............
|
we are still tugging along ............
|
||||||
*/
|
*/
|
||||||
|
if(msr & 0x80){
|
||||||
|
self->runCount++;
|
||||||
|
} else if(msr & 0x200) {
|
||||||
|
self->posCount++;
|
||||||
|
} else if(msr & 0x100) {
|
||||||
|
self->posCount++;
|
||||||
|
} else if(msr & 0x400) {
|
||||||
|
self->posCount++;
|
||||||
|
}
|
||||||
|
|
||||||
return HWBusy;
|
return HWBusy;
|
||||||
/* inserted above line and commented out lines below M.Zolliker Sep 2004
|
/* inserted above line and commented out lines below M.Zolliker Sep 2004
|
||||||
@ -250,6 +269,8 @@ static int EL734Status(void *pData){
|
|||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
static void EL734Error(void *pData, int *iCode, char *error, int errLen){
|
static void EL734Error(void *pData, int *iCode, char *error, int errLen){
|
||||||
pEL734Driv self = NULL;
|
pEL734Driv self = NULL;
|
||||||
|
char pBueffel[132];
|
||||||
|
|
||||||
self = (pEL734Driv)pData;
|
self = (pEL734Driv)pData;
|
||||||
assert(self);
|
assert(self);
|
||||||
|
|
||||||
@ -297,6 +318,11 @@ static void EL734Error(void *pData, int *iCode, char *error, int errLen){
|
|||||||
case BADCUSHION:
|
case BADCUSHION:
|
||||||
strncpy(error,"Air cushion problem",errLen);
|
strncpy(error,"Air cushion problem",errLen);
|
||||||
break;
|
break;
|
||||||
|
case BADCOUNT:
|
||||||
|
snprintf(pBueffel,131,"%d RunFaults, %d PosFaults",
|
||||||
|
self->runCount, self->posCount);
|
||||||
|
strncpy(error,pBueffel,errLen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
getRS232Error(*iCode,error,errLen);
|
getRS232Error(*iCode,error,errLen);
|
||||||
break;
|
break;
|
||||||
@ -328,6 +354,10 @@ static int EL734Fix(void *pData, int iCode, float fValue){
|
|||||||
case RUNFAULT:
|
case RUNFAULT:
|
||||||
case POSFAULT:
|
case POSFAULT:
|
||||||
return MOTREDO;
|
return MOTREDO;
|
||||||
|
case BADCOUNT:
|
||||||
|
self->runCount = 0;
|
||||||
|
self->posCount = 0;
|
||||||
|
return MOTOK;
|
||||||
}
|
}
|
||||||
return MOTFAIL;
|
return MOTFAIL;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ typedef struct {
|
|||||||
int lastStatus; /* need to remember last status, otherwise I get oscillating
|
int lastStatus; /* need to remember last status, otherwise I get oscillating
|
||||||
NoBeam and Counting status if the beam goes off
|
NoBeam and Counting status if the beam goes off
|
||||||
*/
|
*/
|
||||||
|
char *badReply;
|
||||||
} EL737hp, *pEL737hp;
|
} EL737hp, *pEL737hp;
|
||||||
/*--------------------- ERROR CODES -------------------------------------*/
|
/*--------------------- ERROR CODES -------------------------------------*/
|
||||||
#define OFFLINE -1
|
#define OFFLINE -1
|
||||||
@ -48,6 +49,13 @@ typedef struct {
|
|||||||
#define BADREPLY -10
|
#define BADREPLY -10
|
||||||
#define SELECTFAIL -11
|
#define SELECTFAIL -11
|
||||||
#define TIMEOUT737 -12
|
#define TIMEOUT737 -12
|
||||||
|
/*---------------------------------------------------------------------*/
|
||||||
|
static void setBadReply(pEL737hp self, char *reply){
|
||||||
|
if(self->badReply != NULL){
|
||||||
|
free(self->badReply);
|
||||||
|
}
|
||||||
|
self->badReply = strdup(reply);
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
search errors in a reply from the EL737. Returns 1 on success or a
|
search errors in a reply from the EL737. Returns 1 on success or a
|
||||||
negative error code in case of trouble.
|
negative error code in case of trouble.
|
||||||
@ -136,6 +144,7 @@ static int readRS(pEL737hp pPriv, int *RS){
|
|||||||
status = sscanf(reply,"%d",RS);
|
status = sscanf(reply,"%d",RS);
|
||||||
if(status < 1){
|
if(status < 1){
|
||||||
pPriv->errorCode = BADREPLY;
|
pPriv->errorCode = BADREPLY;
|
||||||
|
setBadReply(pPriv,reply);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -196,6 +205,7 @@ static int updateMonitors(struct __COUNTER *self){
|
|||||||
status = sscanf(reply,"%d %d %d %d %f",&m1,&m2,&m3,&m4,&fTime);
|
status = sscanf(reply,"%d %d %d %d %f",&m1,&m2,&m3,&m4,&fTime);
|
||||||
if(status != 5){
|
if(status != 5){
|
||||||
pPriv->errorCode = BADREPLY;
|
pPriv->errorCode = BADREPLY;
|
||||||
|
setBadReply(pPriv,reply);
|
||||||
printf("Bad reply to EL737 RA command: %s\n", reply);
|
printf("Bad reply to EL737 RA command: %s\n", reply);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -399,7 +409,8 @@ static int EL737GetError(struct __COUNTER *self, int *iCode,
|
|||||||
strncpy(pError,"EL737 has an internal system error",errLen);
|
strncpy(pError,"EL737 has an internal system error",errLen);
|
||||||
break;
|
break;
|
||||||
case BADREPLY:
|
case BADREPLY:
|
||||||
strncpy(pError,"EL737 sent an unexpected reply",errLen);
|
snprintf(pError,errLen,"EL737 sent an unexpected reply: %s",
|
||||||
|
pPriv->badReply);
|
||||||
break;
|
break;
|
||||||
case SELECTFAIL:
|
case SELECTFAIL:
|
||||||
strncpy(pError,"select system call failed, network trouble",errLen);
|
strncpy(pError,"select system call failed, network trouble",errLen);
|
||||||
@ -415,13 +426,14 @@ static int EL737FixIt(struct __COUNTER *self, int iCode){
|
|||||||
pEL737hp pPriv = NULL;
|
pEL737hp pPriv = NULL;
|
||||||
int status;
|
int status;
|
||||||
char pReply[50];
|
char pReply[50];
|
||||||
|
char buffer[256];
|
||||||
|
int dataLen = 255;
|
||||||
|
|
||||||
assert(self);
|
assert(self);
|
||||||
pPriv = (pEL737hp)self->pData;
|
pPriv = (pEL737hp)self->pData;
|
||||||
|
|
||||||
switch(iCode){
|
switch(iCode){
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
case BADREPLY:
|
|
||||||
case BADPARAM:
|
case BADPARAM:
|
||||||
case NOPARAM:
|
case NOPARAM:
|
||||||
case BADRANGE:
|
case BADRANGE:
|
||||||
@ -429,6 +441,17 @@ static int EL737FixIt(struct __COUNTER *self, int iCode){
|
|||||||
case TIMEOUT737:
|
case TIMEOUT737:
|
||||||
return COREDO;
|
return COREDO;
|
||||||
break;
|
break;
|
||||||
|
case BADREPLY:
|
||||||
|
/*
|
||||||
|
try to read away all the garbage which may still be in the line
|
||||||
|
*/
|
||||||
|
if(availableRS232(pPriv->controller) > 0){
|
||||||
|
memset(buffer,0,256);
|
||||||
|
readRS232(pPriv->controller,buffer,&dataLen);
|
||||||
|
printf("EL737hpdriv dumped %s after bad reply\n", buffer);
|
||||||
|
}
|
||||||
|
return COREDO;
|
||||||
|
break;
|
||||||
case OFFLINE:
|
case OFFLINE:
|
||||||
EL737Command(pPriv,"RMT 1\r",pReply,49);
|
EL737Command(pPriv,"RMT 1\r",pReply,49);
|
||||||
EL737Command(pPriv,"echo 2\r",pReply,49);
|
EL737Command(pPriv,"echo 2\r",pReply,49);
|
||||||
@ -527,6 +550,9 @@ static void KillHP(pCounterDriver self){
|
|||||||
if(pPriv->controller != NULL){
|
if(pPriv->controller != NULL){
|
||||||
KillRS232(pPriv->controller);
|
KillRS232(pPriv->controller);
|
||||||
}
|
}
|
||||||
|
if(pPriv->badReply != NULL){
|
||||||
|
free(pPriv->badReply);
|
||||||
|
}
|
||||||
free(pPriv);
|
free(pPriv);
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
|
2
make_gen
2
make_gen
@ -18,7 +18,7 @@ OBJ=psi.o buffer.o ruli.o dmc.o nxsans.o nextrics.o sps.o pimotor.o \
|
|||||||
bruker.o ltc11.o A1931.o dilludriv.o eurodriv.o slsmagnet.o \
|
bruker.o ltc11.o A1931.o dilludriv.o eurodriv.o slsmagnet.o \
|
||||||
el755driv.o amorscan.o serial.o scontroller.o t_update.o \
|
el755driv.o amorscan.o serial.o scontroller.o t_update.o \
|
||||||
t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \
|
t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \
|
||||||
el737hpv2driv.o swmotor2.o ipsdriv.o
|
el737hpv2driv.o swmotor2.o ipsdriv.o tricssupport.o
|
||||||
|
|
||||||
libpsi.a: $(OBJ)
|
libpsi.a: $(OBJ)
|
||||||
rm -f libpsi.a
|
rm -f libpsi.a
|
||||||
|
@ -1373,7 +1373,7 @@ name of hkl object holding crystallographic information
|
|||||||
}
|
}
|
||||||
if(iFrame < 0 || iFrame >= self->iFrameNum)
|
if(iFrame < 0 || iFrame >= self->iFrameNum)
|
||||||
{
|
{
|
||||||
sprintf(pBueffel,"ERROR: farme %d not yet written",iDetector);
|
sprintf(pBueffel,"ERROR: frame %d not yet written",iDetector);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
nxamor.c
8
nxamor.c
@ -42,8 +42,9 @@
|
|||||||
The rough size of each detector chunk to write in TOF mode
|
The rough size of each detector chunk to write in TOF mode
|
||||||
(currently 16MB)
|
(currently 16MB)
|
||||||
#define TOFBLOCK 8192000
|
#define TOFBLOCK 8192000
|
||||||
*/
|
|
||||||
#define TOFBLOCK 16384000
|
#define TOFBLOCK 16384000
|
||||||
|
*/
|
||||||
|
#define TOFBLOCK 65536000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
a pointer to amor2t which we need for a couple of parameters
|
a pointer to amor2t which we need for a couple of parameters
|
||||||
@ -354,10 +355,12 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim,
|
|||||||
NXhandle hfil, NXdict hdict,
|
NXhandle hfil, NXdict hdict,
|
||||||
SConnection *pCon)
|
SConnection *pCon)
|
||||||
{
|
{
|
||||||
int iLength, nChunk, chunkSize, iChunk[3], i, iStart[3], nTime, iRet;
|
int nChunk, chunkSize, iChunk[3], i, iStart[3], nTime, iRet;
|
||||||
|
long iLength;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
char pBueffel[132];
|
char pBueffel[132];
|
||||||
const float *fTime;
|
const float *fTime;
|
||||||
|
int start;
|
||||||
|
|
||||||
fTime = GetHistTimeBin(pHM,&nTime);
|
fTime = GetHistTimeBin(pHM,&nTime);
|
||||||
iDim[2] = nTime;
|
iDim[2] = nTime;
|
||||||
@ -384,6 +387,7 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim,
|
|||||||
free(lData);
|
free(lData);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
SicsWait(2);
|
||||||
NXDputalias(hfil,hdict,name,lData);
|
NXDputalias(hfil,hdict,name,lData);
|
||||||
NXDputalias(hfil,hdict,"detchunk",iDim);
|
NXDputalias(hfil,hdict,"detchunk",iDim);
|
||||||
NXDaliaslink(hfil,hdict,"dana",name);
|
NXDaliaslink(hfil,hdict,"dana",name);
|
||||||
|
@ -416,7 +416,8 @@
|
|||||||
KillC804(pNew);
|
KillC804(pNew);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
SerialConfig(&pNew->pSerial,5000);
|
||||||
|
|
||||||
/* switch on, just to make sure */
|
/* switch on, just to make sure */
|
||||||
iTmo = SerialGetTmo(&pNew->pSerial);
|
iTmo = SerialGetTmo(&pNew->pSerial);
|
||||||
SerialConfig(&pNew->pSerial,0);
|
SerialConfig(&pNew->pSerial,0);
|
||||||
|
@ -507,6 +507,8 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
NXDputalias(hfil,hdict,"cntime",&fVal);
|
NXDputalias(hfil,hdict,"cntime",&fVal);
|
||||||
lVal = GetHistMonitor(self->pHist,1,pCon);
|
lVal = GetHistMonitor(self->pHist,1,pCon);
|
||||||
NXDputalias(hfil,hdict,"cnmon1",&lVal);
|
NXDputalias(hfil,hdict,"cnmon1",&lVal);
|
||||||
|
lVal = GetHistMonitor(self->pHist,4,pCon);
|
||||||
|
NXDputalias(hfil,hdict,"cnprot",&lVal);
|
||||||
eMode = GetHistCountMode(self->pHist);
|
eMode = GetHistCountMode(self->pHist);
|
||||||
if(eMode == eTimer)
|
if(eMode == eTimer)
|
||||||
{
|
{
|
||||||
|
3
psi.c
3
psi.c
@ -50,6 +50,7 @@
|
|||||||
#include "amorscan.h"
|
#include "amorscan.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "fomerge.h"
|
#include "fomerge.h"
|
||||||
|
#include "tricssupport.h"
|
||||||
|
|
||||||
static pSite sitePSI = NULL;
|
static pSite sitePSI = NULL;
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ static void AddPsiCommands(SicsInterp *pInter){
|
|||||||
AddCommand(pInter,"InitDMC",InitDmc,NULL,NULL);
|
AddCommand(pInter,"InitDMC",InitDmc,NULL,NULL);
|
||||||
AddCommand(pInter,"InitSANS",InitSANS,NULL,NULL);
|
AddCommand(pInter,"InitSANS",InitSANS,NULL,NULL);
|
||||||
AddCommand(pInter,"MakeTRICSNEXUS",NexTricsFactory,NULL,NULL);
|
AddCommand(pInter,"MakeTRICSNEXUS",NexTricsFactory,NULL,NULL);
|
||||||
|
AddCommand(pInter,"MakeTRICSSupport",MakeTricsSupport,NULL,NULL);
|
||||||
AddCommand(pInter,"MakeSPS",SPSFactory,NULL,NULL);
|
AddCommand(pInter,"MakeSPS",SPSFactory,NULL,NULL);
|
||||||
AddCommand(pInter,"MakePIMotor",PIMotorFactory,NULL,NULL);
|
AddCommand(pInter,"MakePIMotor",PIMotorFactory,NULL,NULL);
|
||||||
AddCommand(pInter,"MakeSANSWave",MakeSANSWave,NULL,NULL);
|
AddCommand(pInter,"MakeSANSWave",MakeSANSWave,NULL,NULL);
|
||||||
@ -84,6 +86,7 @@ static void RemovePsiCommands(SicsInterp *pSics){
|
|||||||
RemoveCommand(pSics,"InitDMC");
|
RemoveCommand(pSics,"InitDMC");
|
||||||
RemoveCommand(pSics,"InitSANS");
|
RemoveCommand(pSics,"InitSANS");
|
||||||
RemoveCommand(pSics,"MakeTRICSNEXUS");
|
RemoveCommand(pSics,"MakeTRICSNEXUS");
|
||||||
|
RemoveCommand(pSics,"MakeTRICSSupport");
|
||||||
RemoveCommand(pSics,"MakeSPS");
|
RemoveCommand(pSics,"MakeSPS");
|
||||||
RemoveCommand(pSics,"MakePIMotor");
|
RemoveCommand(pSics,"MakePIMotor");
|
||||||
RemoveCommand(pSics,"MakeSANSWave");
|
RemoveCommand(pSics,"MakeSANSWave");
|
||||||
|
57
swmotor2.c
57
swmotor2.c
@ -11,6 +11,10 @@
|
|||||||
motor drivers.
|
motor drivers.
|
||||||
|
|
||||||
Mark Koennecke, August 2003
|
Mark Koennecke, August 2003
|
||||||
|
|
||||||
|
Modified to do all the switching and reference running in Tcl
|
||||||
|
|
||||||
|
Mark Koennecke, August 2004
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -167,59 +171,6 @@ static long SWSetValue(void *pData, SConnection *pCon, float fVal)
|
|||||||
}
|
}
|
||||||
self->selectedMotor[0] = self->myNumber;
|
self->selectedMotor[0] = self->myNumber;
|
||||||
|
|
||||||
/*
|
|
||||||
switch done! Start a reference run
|
|
||||||
*/
|
|
||||||
SicsWait(10);
|
|
||||||
SCWrite(pCon,"Standby, starting reference run... ", eWarning);
|
|
||||||
pElli = (EL734Driv *)self->pMaster->pDriver;
|
|
||||||
sprintf(pCommand,"R %d\r",pElli->iMotor);
|
|
||||||
setRS232Timeout(pElli->controller,4000);
|
|
||||||
status = transactRS232(pElli->controller,pCommand,strlen(pCommand),
|
|
||||||
pError,131);
|
|
||||||
if(status != 1)
|
|
||||||
{
|
|
||||||
getRS232Error(status,pError,131);
|
|
||||||
sprintf(pCommand,"ERROR: %s while trying to start reference run",
|
|
||||||
pError);
|
|
||||||
SCWrite(pCon,pCommand,eError);
|
|
||||||
self->errCode = -1002;
|
|
||||||
return HWFault;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
now loop forever until reference run is done. This is either when the
|
|
||||||
motors stops being busy or when the user interrupts.
|
|
||||||
*/
|
|
||||||
sprintf(pCommand,"SS %d\r",pElli->iMotor);
|
|
||||||
for( ; ;)
|
|
||||||
{
|
|
||||||
status = transactRS232(pElli->controller,pCommand,strlen(pCommand),
|
|
||||||
pError,131);
|
|
||||||
if(status != 1)
|
|
||||||
{
|
|
||||||
getRS232Error(status,pError,131);
|
|
||||||
sprintf(pCommand,"ERROR: %s during reference run",
|
|
||||||
pError);
|
|
||||||
SCWrite(pCon,pCommand,eError);
|
|
||||||
self->errCode = -1003;
|
|
||||||
return HWFault;
|
|
||||||
}
|
|
||||||
if(strstr(pError,"?BSY") == NULL)
|
|
||||||
break;
|
|
||||||
if(SCGetInterrupt(pCon) != eContinue)
|
|
||||||
{
|
|
||||||
self->errCode = -1004;
|
|
||||||
SCWrite(pCon,"ERROR: user interrupted reference run",eError);
|
|
||||||
return HWFault;
|
|
||||||
}
|
|
||||||
SicsWait(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
now this is finished. We can really start driving the motor
|
|
||||||
*/
|
|
||||||
SCWrite(pCon,"Reference run completed, starting to drive motor..",
|
|
||||||
eWarning);
|
|
||||||
return self->pMaster->pDrivInt->SetValue(self->pMaster,pCon,fVal);
|
return self->pMaster->pDrivInt->SetValue(self->pMaster,pCon,fVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
tasscan.c
35
tasscan.c
@ -112,6 +112,22 @@ static void writePolFile(FILE *fd, pTASdata pTAS){
|
|||||||
}
|
}
|
||||||
fclose(fpol);
|
fclose(fpol);
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
static char *findLastPoint(char *text)
|
||||||
|
{
|
||||||
|
char *pPtr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pPtr = text + strlen(text) - 1;
|
||||||
|
for(i = strlen(text); i > 0; i--, pPtr--)
|
||||||
|
{
|
||||||
|
if(*pPtr == '.')
|
||||||
|
{
|
||||||
|
return pPtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
TASHeader writes the header of a TAS data file. The format is an
|
TASHeader writes the header of a TAS data file. The format is an
|
||||||
obscure format from ILL ( not ill but Institute Laue Langevin). No
|
obscure format from ILL ( not ill but Institute Laue Langevin). No
|
||||||
@ -151,14 +167,21 @@ static int TASHeader(pScanData self)
|
|||||||
extract the file number from the name for entry into the
|
extract the file number from the name for entry into the
|
||||||
datafile
|
datafile
|
||||||
*/
|
*/
|
||||||
pcPtr = strstr(self->pFile,".");
|
pcPtr = findLastPoint(self->pFile);
|
||||||
pcPtr -= 9; /* four for year, 5 for number */
|
if(pcPtr != NULL)
|
||||||
for(i = 0; i < 5; i++, pcPtr++)
|
|
||||||
{
|
{
|
||||||
pWork[i] = *pcPtr;
|
pcPtr -= 6; /* 6 digits for number */
|
||||||
|
for(i = 0; i < 6; i++, pcPtr++)
|
||||||
|
{
|
||||||
|
pWork[i] = *pcPtr;
|
||||||
|
}
|
||||||
|
pWork[6] = '\0';
|
||||||
|
iFileNO = atoi(pWork);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(self->pCon,"WARNING: failed to decode file number",eWarning);
|
||||||
}
|
}
|
||||||
pWork[5] = '\0';
|
|
||||||
iFileNO = atoi(pWork);
|
|
||||||
|
|
||||||
/* the bizarre R, A, V header */
|
/* the bizarre R, A, V header */
|
||||||
charLine(pBueffel,'R');
|
charLine(pBueffel,'R');
|
||||||
|
@ -27,14 +27,14 @@ HARDSUPLIB = ../hardsup/libhlib.a
|
|||||||
libtecsl.a: $(CLI_OBJ)
|
libtecsl.a: $(CLI_OBJ)
|
||||||
rm -f $@
|
rm -f $@
|
||||||
$(AR) $(ARFLAGS) $@ $Q
|
$(AR) $(ARFLAGS) $@ $Q
|
||||||
ranlib $@
|
ranlib libtecsl.a
|
||||||
|
|
||||||
all: libtecsl.a TecsServer TecsClient keep_running six
|
all: libtecsl.a TecsServer TecsClient keep_running six
|
||||||
|
|
||||||
CFGDIR=/afs/psi.ch/project/sinq/common/lib/tecs/cfg/
|
CFGDIR=/afs/psi.ch/project/sinq/common/lib/tecs/cfg/
|
||||||
|
|
||||||
-include make_crv
|
#-include make_crv
|
||||||
-include src/make_crv
|
#-include src/make_crv
|
||||||
|
|
||||||
$(SRC)make_crv: make_crv.tcsh inp/lsc.codes $(ALLINP)
|
$(SRC)make_crv: make_crv.tcsh inp/lsc.codes $(ALLINP)
|
||||||
$(SRC)make_crv.tcsh $(SRC)inp/lsc.codes
|
$(SRC)make_crv.tcsh $(SRC)inp/lsc.codes
|
||||||
|
205
tricssupport.c
Normal file
205
tricssupport.c
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/*------------------------------------------------------------------------
|
||||||
|
This is a little helper module for SICS which implements some
|
||||||
|
status display support functions.
|
||||||
|
|
||||||
|
COPYRIGHT: see file COPYRIGHT
|
||||||
|
|
||||||
|
Extracted from nextrics
|
||||||
|
|
||||||
|
Mark Koennecke, August 2004
|
||||||
|
--------------------------------------------------------------------------*/
|
||||||
|
#include "tricssupport.h"
|
||||||
|
#include "../napi.h"
|
||||||
|
#include "../HistMem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define NEWFRAME 1166
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
a data structure plus support functions
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
typedef struct {
|
||||||
|
pObjectDescriptor pDes;
|
||||||
|
pICallBack pCall;
|
||||||
|
} TricsSupport, *pTricsSupport;
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
static pTricsSupport CreateTricsSupport(){
|
||||||
|
pTricsSupport pNew = NULL;
|
||||||
|
|
||||||
|
pNew = (pTricsSupport)malloc(sizeof(TricsSupport));
|
||||||
|
if(pNew == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memset(pNew,0,sizeof(TricsSupport));
|
||||||
|
|
||||||
|
pNew->pDes = CreateDescriptor("TricsSupport");
|
||||||
|
pNew->pCall = CreateCallBackInterface();
|
||||||
|
if(pNew->pDes == NULL || pNew->pCall == NULL){
|
||||||
|
free(pNew);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return pNew;
|
||||||
|
}
|
||||||
|
/*--------------------------------------------------------------------*/
|
||||||
|
static void KillTricsSupport(void *pData){
|
||||||
|
pTricsSupport pNew = (pTricsSupport)pData;
|
||||||
|
|
||||||
|
if(pNew != NULL){
|
||||||
|
if(pNew->pDes != NULL){
|
||||||
|
DeleteDescriptor(pNew->pDes);
|
||||||
|
pNew->pDes = NULL;
|
||||||
|
}
|
||||||
|
if(pNew->pCall != NULL){
|
||||||
|
DeleteCallBackInterface(pNew->pCall);
|
||||||
|
pNew->pCall = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*=====================================================================*/
|
||||||
|
static int FrameSupInterest(int iEvent, void *pEvent, void *pUser){
|
||||||
|
SConnection *pCon = NULL;
|
||||||
|
int *iFrame;
|
||||||
|
char pBueffel[512];
|
||||||
|
|
||||||
|
if(iEvent != NEWFRAME){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCon = (SConnection *)pUser;
|
||||||
|
iFrame = (int *)pEvent;
|
||||||
|
assert(pCon);
|
||||||
|
sprintf(pBueffel,"framenumber = %d",*iFrame);
|
||||||
|
SCWrite(pCon,pBueffel,eWarning);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*======================================================================
|
||||||
|
NexusGetFrame opens a TRICS NeXus file and retrieves a frame for the
|
||||||
|
specified detector from it. This is a special feature for the
|
||||||
|
status display.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
static int NexusGetFrameSup(SConnection *pCon, char *filename,
|
||||||
|
int iDetector, int iFrame){
|
||||||
|
char pBueffel[132];
|
||||||
|
int iRet, type, rank, iDim[2];
|
||||||
|
NXhandle hfil;
|
||||||
|
HistInt *lData = NULL;
|
||||||
|
|
||||||
|
/* do a few range checks */
|
||||||
|
if(iDetector < 1 || iDetector > 3){
|
||||||
|
sprintf(pBueffel,"ERROR: unknown detector %d requested",iDetector);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open file */
|
||||||
|
iRet = NXopen(filename,NXACC_READ,&hfil);
|
||||||
|
if(iRet != NX_OK){
|
||||||
|
sprintf(pBueffel,"ERROR: cannot open %s",filename);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(pBueffel,131,"/frame%4.4d/detector%1.1d/counts",iFrame,
|
||||||
|
iDetector);
|
||||||
|
iRet = NXopenpath(hfil,pBueffel);
|
||||||
|
if(iRet != NX_OK){
|
||||||
|
sprintf(pBueffel,"ERROR: frame %d, detector %d not found in %s",
|
||||||
|
iFrame, iDetector,
|
||||||
|
filename);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
NXclose(&hfil);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
NXgetinfo(hfil,&rank,iDim,&type);
|
||||||
|
|
||||||
|
lData = (HistInt *)malloc(iDim[0]*iDim[1]*sizeof(HistInt));
|
||||||
|
if(!lData){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in NexusGetFrame",eError);
|
||||||
|
NXclose(&hfil);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(lData,0,iDim[0]*iDim[1]*sizeof(HistInt));
|
||||||
|
iRet = NXgetdata(hfil,lData);
|
||||||
|
if(iRet != NX_OK){
|
||||||
|
SCWrite(pCon,"ERROR: failed to read data",eError);
|
||||||
|
NXclose(&hfil);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send it */
|
||||||
|
sprintf(pBueffel,"detector%1.1d",iDetector);
|
||||||
|
SCWriteZipped(pCon,pBueffel,lData,iDim[0]*iDim[1]*sizeof(HistInt));
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
NXclose(&hfil);
|
||||||
|
free(lData);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
int MakeTricsSupport(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
pTricsSupport pNew = NULL;
|
||||||
|
|
||||||
|
pNew = CreateTricsSupport();
|
||||||
|
if(!pNew){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory creating TricsSupport",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(AddCommand(pSics,"tricssupport",TricsSupportAction,KillTricsSupport,
|
||||||
|
pNew) != 1){
|
||||||
|
SCWrite(pCon,"ERROR: duplicate command tricssupport not created",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
int TricsSupportAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
int iDet, iFrame, iRet;
|
||||||
|
long lID;
|
||||||
|
char pBueffel[131];
|
||||||
|
pTricsSupport self = (pTricsSupport)pData;
|
||||||
|
|
||||||
|
assert(self);
|
||||||
|
|
||||||
|
/* check for subcommands */
|
||||||
|
if(argc < 2){
|
||||||
|
snprintf(pBueffel,130,"ERROR: no subcommand found for %s",argv[0]);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
strtolower(argv[1]);
|
||||||
|
if(strcmp(argv[1],"oldframe") == 0){
|
||||||
|
if(argc < 5){
|
||||||
|
SCWrite(pCon,"ERROR: insufficient number of arguments to oldframe",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
iDet = atoi(argv[3]);
|
||||||
|
iFrame = atoi(argv[4]);
|
||||||
|
iRet = NexusGetFrameSup(pCon,argv[2],iDet, iFrame);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1],"interest") == 0){
|
||||||
|
lID = RegisterCallback(self->pCall, NEWFRAME, FrameSupInterest,
|
||||||
|
pCon, NULL);
|
||||||
|
SCRegister(pCon,pSics, self->pCall,lID);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
} else if(strcmp(argv[1],"newframe") == 0){
|
||||||
|
if(argc < 3){
|
||||||
|
SCWrite(pCon,
|
||||||
|
"ERROR: insufficient number of arguments to tricsupport newframe",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
iFrame = atoi(argv[2]);
|
||||||
|
InvokeCallBack(self->pCall, NEWFRAME,&iFrame);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
22
tricssupport.h
Normal file
22
tricssupport.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*------------------------------------------------------------------------
|
||||||
|
This is a little helper module for SICS which implements some
|
||||||
|
status display support functions.
|
||||||
|
|
||||||
|
COPYRIGHT: see file COPYRIGHT
|
||||||
|
|
||||||
|
Extracted from nextrics
|
||||||
|
|
||||||
|
Mark Koennecke, August 2004
|
||||||
|
--------------------------------------------------------------------------*/
|
||||||
|
#ifndef TRICSSUPPORT
|
||||||
|
#define TRICSSUPPORT
|
||||||
|
|
||||||
|
#include <sics.h>
|
||||||
|
|
||||||
|
int MakeTricsSupport(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]);
|
||||||
|
int TricsSupportAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
242
utils/ecb-load.c
242
utils/ecb-load.c
@ -1,242 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* This file contains the download program the ECB system.
|
|
||||||
* It reads a Tek-hex formated file and downloads it to the ECB-system.
|
|
||||||
* The lowest address is used as the start address of the program.
|
|
||||||
*
|
|
||||||
* Project: ECB-C
|
|
||||||
* Filename: ecb_load.c
|
|
||||||
*
|
|
||||||
* Author: L. S. Jensen 18. Feb 1993
|
|
||||||
*
|
|
||||||
* Heavily reworked by code transfusions from tascom in order to
|
|
||||||
* support new ECB file format.
|
|
||||||
*
|
|
||||||
* Mark Koennecke, May 2003
|
|
||||||
*
|
|
||||||
* Copyright (C) Risoe National Laboratory, 1993, All rights reserved
|
|
||||||
****************************************************************************/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ecb-drv.h" /* The ecb driver interface. */
|
|
||||||
|
|
||||||
#define MAX_BUFFER_SIZE 32767 /* Max. RAM in ECB system */
|
|
||||||
#define LINE_SIZE 128
|
|
||||||
|
|
||||||
#define LAST_LINE -125
|
|
||||||
#define CHECKSUM_ERR -100
|
|
||||||
#define FORMAT_ERR -101
|
|
||||||
#define FILE_ERR -102
|
|
||||||
|
|
||||||
#define CSTART_CODE 171 /* The number of ECB function cstart */
|
|
||||||
|
|
||||||
#define FOREVER 1 /* Used in a loop */
|
|
||||||
#define ECB_BYTES 65536L
|
|
||||||
#define ECB_DOWN_LOAD 178
|
|
||||||
#define LOAD_NEXT 1
|
|
||||||
/*****************************************************************************
|
|
||||||
* Local variables in this file.
|
|
||||||
*****************************************************************************/
|
|
||||||
static char buffer[MAX_BUFFER_SIZE];
|
|
||||||
|
|
||||||
static int debug = 0;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Convert HEX to bin
|
|
||||||
*******************************************************************************/
|
|
||||||
static int look_up[] = {10, 11, 12, 13, 14 ,15};
|
|
||||||
|
|
||||||
static unsigned long
|
|
||||||
Hex_to_bin(char c)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(isdigit((int) c))
|
|
||||||
return (c - '0');
|
|
||||||
else
|
|
||||||
return look_up[c - 'A'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Convert Bin to HEX
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
static char
|
|
||||||
Bin_to_hex (int i)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(i <= 9)
|
|
||||||
return ( (char)(i + (int)('0')) );
|
|
||||||
else
|
|
||||||
return ( (char)( (i - 10) + (int)('A')) );
|
|
||||||
}
|
|
||||||
/***************************************************************************
|
|
||||||
* This function creates blocks as large as possible of consecutive data
|
|
||||||
* bytes from the hex file in order to speed up the data transfer by
|
|
||||||
* sending blocks of data to the ECB system rather than single lines.
|
|
||||||
****************************************************************************/
|
|
||||||
static Z80_reg x_outreg, x_inreg;
|
|
||||||
|
|
||||||
static long
|
|
||||||
Send_blocks(FILE *fp, Gpib_dev dev)
|
|
||||||
{
|
|
||||||
char line[LINE_SIZE];
|
|
||||||
char *point;
|
|
||||||
int line_not_output, byte_count, line_no,type, no_bytes,total_bytes;
|
|
||||||
int load_count = -1, function;
|
|
||||||
unsigned char x_ecb_data[ECB_BYTES]; /* Array to hold data blocks for ECB */
|
|
||||||
unsigned long adrs, old_adrs, total0, total1, total2;
|
|
||||||
void *line9 = &line[9];
|
|
||||||
unsigned short address;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (line_not_output == 1)
|
|
||||||
line_not_output = 0; /* Start with old line */
|
|
||||||
else
|
|
||||||
{ /* Read a line from file */
|
|
||||||
point = fgets (line, LINE_SIZE, fp);
|
|
||||||
if (point != NULL)
|
|
||||||
{
|
|
||||||
byte_count = strlen(line);
|
|
||||||
byte_count -= 4; /* Remove checksum and \n in the */
|
|
||||||
line[byte_count+1] = '\0'; /* line, i.e. the four last characters */
|
|
||||||
line[0] = '0'; /* Replace : in line[0] with 0 */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!ferror(fp))
|
|
||||||
byte_count = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fclose (fp);
|
|
||||||
fp = NULL;
|
|
||||||
return(FILE_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
line_no += 1;
|
|
||||||
if (byte_count != 0)
|
|
||||||
{
|
|
||||||
if (line_no == 1)
|
|
||||||
strcpy (x_ecb_data, line);
|
|
||||||
type = (Hex_to_bin(line[7]) << 4) + Hex_to_bin(line[8]);
|
|
||||||
if (type != 0)
|
|
||||||
{
|
|
||||||
if (line_no > 1) /* Output buffer and mark that */
|
|
||||||
line_not_output = 1; /* last input line has not been output */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
no_bytes = (Hex_to_bin(line[1]) << 4) + Hex_to_bin(line[2]);
|
|
||||||
adrs = (Hex_to_bin(line[3]) << 12) + (Hex_to_bin(line[4]) << 8) +
|
|
||||||
(Hex_to_bin(line[5]) << 4) + Hex_to_bin(line[6]);
|
|
||||||
if (line_no == 1)
|
|
||||||
{
|
|
||||||
total_bytes = no_bytes;
|
|
||||||
old_adrs = adrs;
|
|
||||||
continue; /* Get next input line */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (old_adrs + no_bytes == adrs)
|
|
||||||
{ /* Contigious addresses */
|
|
||||||
total_bytes += no_bytes;
|
|
||||||
old_adrs = adrs;
|
|
||||||
strcat (x_ecb_data, line9); /* Add the new bytes to buffer */
|
|
||||||
total0 = total_bytes/256; /* and adjust number of bytes */
|
|
||||||
x_ecb_data[0] = Bin_to_hex(total0);
|
|
||||||
total1 = total_bytes - 256*total0;
|
|
||||||
total2 = total1/16;
|
|
||||||
x_ecb_data[1] = Bin_to_hex(total2);
|
|
||||||
x_ecb_data[2] = Bin_to_hex(total1 - 16*total2);
|
|
||||||
if (line_no < 20) /* Max 20 lines together */
|
|
||||||
continue; /* Get next input line */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
line_not_output = 0; /* Output buffer, nothing waiting in line[] */
|
|
||||||
}
|
|
||||||
|
|
||||||
address = 1;
|
|
||||||
byte_count = strlen (x_ecb_data);
|
|
||||||
Ecb_write (dev, x_ecb_data,byte_count,1); /* Write a line to ECB */
|
|
||||||
line_no = 0;
|
|
||||||
|
|
||||||
if (load_count == -1) /* Type Loading followed by dots while */
|
|
||||||
{ /* down loading the file */
|
|
||||||
printf ("Loading");
|
|
||||||
load_count = 0;
|
|
||||||
}
|
|
||||||
load_count += 1;
|
|
||||||
|
|
||||||
if (load_count > 15)
|
|
||||||
{
|
|
||||||
printf (".");
|
|
||||||
load_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function = ECB_DOWN_LOAD;
|
|
||||||
Ecb_func (dev, function,x_inreg); /* Call ECB download function */
|
|
||||||
if (x_outreg.b != LOAD_NEXT) /* Wait for reply from ECB */
|
|
||||||
break; /* If LOAD_NEXT, get next line, else finished */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\nLoading completed\n");
|
|
||||||
}
|
|
||||||
/****************************************************************************
|
|
||||||
* Handles error in gpib driver.
|
|
||||||
****************************************************************************/
|
|
||||||
void
|
|
||||||
Exit_code(int status)
|
|
||||||
{
|
|
||||||
if(debug)
|
|
||||||
printf("exit status %d", status);
|
|
||||||
exit(status);
|
|
||||||
}
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
Gpib_dev dev;
|
|
||||||
int dev_no;
|
|
||||||
FILE *record_fp;
|
|
||||||
long start_adr;
|
|
||||||
Z80_reg z80;
|
|
||||||
|
|
||||||
if (argc < 4|| argc > 5)
|
|
||||||
{
|
|
||||||
printf("used: %s Gpib-driver-name ECB-device-number ECB-hex-filename\n",
|
|
||||||
argv[0]);
|
|
||||||
exit(GPIB_ERR);
|
|
||||||
}
|
|
||||||
if (argc == 5)
|
|
||||||
{
|
|
||||||
if ((0 == strcasecmp(argv[4],"DEBUG"))||(0 == strcasecmp(argv[4],"VERBOSE")))
|
|
||||||
debug = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
record_fp = fopen(argv[3], "rb"); /* Open in read-only mode in binary mode */
|
|
||||||
if (record_fp == NULL)
|
|
||||||
{
|
|
||||||
printf("used: %s Gpib-driver-name ECB-device-number ECB-hex-filename\n",
|
|
||||||
argv[0]);
|
|
||||||
exit(FILE_ERR);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = Ecb_unit(argv[1], argv[2]); /* Open the ECB device */
|
|
||||||
|
|
||||||
start_adr = Send_blocks(record_fp, dev);
|
|
||||||
if (start_adr < 0) /* An error */
|
|
||||||
exit(start_adr);
|
|
||||||
|
|
||||||
z80.d = start_adr; /* Lsb part in Z80 reg. D */
|
|
||||||
z80.e = start_adr>>8; /* Msb part in Z80 reg. E */
|
|
||||||
|
|
||||||
Ecb_func(dev, CSTART_CODE, z80); /* And start the ecb-c program. */
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
100
utils/ecb_load_new/ecb_load.c
Normal file
100
utils/ecb_load_new/ecb_load.c
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Download program for the ECB system with the new P2701 CPU module.
|
||||||
|
*
|
||||||
|
* Filename: ecb_load.c
|
||||||
|
*
|
||||||
|
* Author: P.S. May 2004
|
||||||
|
*
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
/*******************************************************************************
|
||||||
|
*& modificaions:
|
||||||
|
*&
|
||||||
|
*& V003.100 P.S. 2-May-2004
|
||||||
|
*& Creation.
|
||||||
|
*&
|
||||||
|
*&*****************************************************************************/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "ecb_load.h" /* The ecb driver interface. */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Default path and name for the download file..
|
||||||
|
*******************************************************************************/
|
||||||
|
#define FILE_NAME "/scratch/users/tascomp/sans2m/tas/symfil/ecb_v501.hex"
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* External variables defined in this file.
|
||||||
|
*******************************************************************************/
|
||||||
|
int x_tas_error = 0; /* Global error type */
|
||||||
|
char *x_error_text = '\0'; /* Error text line*/
|
||||||
|
int x_error_int = 0; /* Global error parameter */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* If the program is started without arguments, the file ecb_v501.hex is
|
||||||
|
* downloaded. Another file name may be specified as an argument.
|
||||||
|
****************************************************************************/
|
||||||
|
extern int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int ecb_type;
|
||||||
|
FILE *stream;
|
||||||
|
char file_name[F_BUFSIZ] = FILE_NAME;
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
strcpy (file_name, argv[1]);
|
||||||
|
if (argc > 2)
|
||||||
|
exit(0); /* Error exit */
|
||||||
|
|
||||||
|
stream = fopen(file_name, "r"); /* Open in read-only mode */
|
||||||
|
if (stream == NULL)
|
||||||
|
{
|
||||||
|
printf("Error: unable to open file %s \n", file_name);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gpib_init();
|
||||||
|
Ecb_init();
|
||||||
|
|
||||||
|
/* Check communication with the ECB system works and that we are in ROM mode */
|
||||||
|
ecb_type = Ecb_type (TYPE_OUT);
|
||||||
|
if (ecb_type != 0)
|
||||||
|
{
|
||||||
|
if (ecb_type == -1)
|
||||||
|
printf (" old ECB CPU (not P2701a)\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("\nERROR:- the ECB system is in RAM mode\n");
|
||||||
|
printf (" and download of the ECB program is only possible in ROM mode.\n");
|
||||||
|
printf (" You must set the ECB system in ROM mode.\n\n");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ecb_down_load (stream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Main error routine.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Ecb_load_error()
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("\nERROR:-");
|
||||||
|
|
||||||
|
if ((Ecb_error()) == FOUND) return;
|
||||||
|
if ((Gpib_error()) == FOUND) return;
|
||||||
|
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
143
utils/ecb_load_new/ecb_load.h
Normal file
143
utils/ecb_load_new/ecb_load.h
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file contains the header defs for the ECB download program
|
||||||
|
*
|
||||||
|
* File name: ecb_load.h
|
||||||
|
*
|
||||||
|
* Author: P.S. May 2004
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
/*******************************************************************************
|
||||||
|
/*******************************************************************************
|
||||||
|
*& 'ecbdriv.h' modifications:
|
||||||
|
*&
|
||||||
|
*&
|
||||||
|
*******************************************************************************/
|
||||||
|
/****************************************************************************************
|
||||||
|
* Declaration of data types.
|
||||||
|
****************************************************************************************/
|
||||||
|
typedef int Long; /* 32 bits integer */
|
||||||
|
|
||||||
|
/* GPIB interface */
|
||||||
|
/****************************************************************************************
|
||||||
|
* Constants.
|
||||||
|
****************************************************************************************/
|
||||||
|
#define TC_FAR
|
||||||
|
#define F_BUFSIZ 256 /* 256 characters per line */
|
||||||
|
#define NUL ('\0') /* Binary null character */
|
||||||
|
#define ACKN ('\6') /* Acknowledge character */
|
||||||
|
#define FOUND 1 /* Symbol found in Put/Get_variable */
|
||||||
|
#define NOT_FOUND 0 /* Symbol not found Put/Get_variable */
|
||||||
|
#define GLOBAL 2 /* Sym. used in more Put/Get_variable */
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1 /* Logical true */
|
||||||
|
#endif
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0 /* Logical false */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* ECB type definitions.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
typedef struct /* Z80 registers transferred in function calls */
|
||||||
|
{
|
||||||
|
unsigned char d; /* D register in Z80 */
|
||||||
|
unsigned char e; /* E register in Z80 */
|
||||||
|
unsigned char b; /* B register in Z80 */
|
||||||
|
unsigned char c; /* C register in Z80 */
|
||||||
|
} Z80_reg;
|
||||||
|
|
||||||
|
typedef union /* Used to swap bytes in 'address' and 'byte_count' */
|
||||||
|
{
|
||||||
|
unsigned short word;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char msb; /* Most significant byte */
|
||||||
|
unsigned char lsb; /* Least significant byte */
|
||||||
|
}b;
|
||||||
|
}Swap;
|
||||||
|
|
||||||
|
typedef union /* Used to read DMA data from the P2701a CPU module */
|
||||||
|
{
|
||||||
|
unsigned char *byte; /* Four 8 bit bytes per 32 bit integer word */
|
||||||
|
Long *word;
|
||||||
|
}Ecb_data;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* ECB basic functions.
|
||||||
|
*******************************************************************************/
|
||||||
|
#define READ_N_BYTES 3 /* ECB function to read n bytes */
|
||||||
|
#define WRITE_N_BYTES 4 /* ECB function to write n bytes */
|
||||||
|
#define DMA_READ 5 /* ECB function to DMA read n bytes */
|
||||||
|
|
||||||
|
#define ECB_DOWN_LOAD 178 /* ECB function to download the ECB program */
|
||||||
|
#define LOAD_NEXT 1 /* Return code from download function */
|
||||||
|
#define ECB_TYPE 157 /* Returns ECB ROM or RAM and version */
|
||||||
|
|
||||||
|
#define TYPE_OUT 2 /* Returns type from function 157 */
|
||||||
|
#define VERS_OUT 3 /* Returns version from function 157 */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* GPIB and ECB implementation environment.
|
||||||
|
*******************************************************************************/
|
||||||
|
#define GPIB_H "/usr/local/include/ugpib.h"
|
||||||
|
#define GPIB0 "gpib0" /* Name of adater board No. 0 */
|
||||||
|
#define ECB1 "dev5" /* Name of ECB system #1 */
|
||||||
|
#define ECBTEXT "ECB SYSTEM"
|
||||||
|
#define ECB2 "dev4" /* Name of ECB system #2 */
|
||||||
|
#define DEFAULT_TIMO T3s /* Default timeout 3 sec. */
|
||||||
|
#define ECB_BYTES 65536L /* Max No. of bytes to transfer in each call */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Error codes
|
||||||
|
*******************************************************************************/
|
||||||
|
#define TAS_ERROR 100 /* General error */
|
||||||
|
#define OPEN_FILE 600 /* Could not open file */
|
||||||
|
#define FILE_READ 601 /* Could not read file */
|
||||||
|
#define WRITE_FILE 602 /* Could not write to file */
|
||||||
|
#define GPIB_WRITE_ERROR 700
|
||||||
|
#define GPIB_READ_ERROR 701
|
||||||
|
#define GPIB_FIND_ERROR 702 /* Could not 'open' device */
|
||||||
|
#define GPIB_NO_LISNER_ERROR 703
|
||||||
|
#define ECB_ILLEGAL_FUNC 750 /* No such ECB function */
|
||||||
|
#define ECB_OVERFLOW 751 /* Byte count exceeds array size */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Globals
|
||||||
|
*******************************************************************************/
|
||||||
|
extern int x_tas_error; /* Global error type */
|
||||||
|
extern char *x_error_text; /* Error text line*/
|
||||||
|
extern int x_error_int; /* Global error parameter */
|
||||||
|
extern int x_gpib0; /* Unit descriptor for board (adaptor) 0 */
|
||||||
|
extern int x_ecb1; /* Unit descriptor of ECB system #1 */
|
||||||
|
extern Z80_reg x_inreg; /* Z80 registers b,c,d and e before call */
|
||||||
|
extern Z80_reg x_outreg; /* Z80 registers b,c,d and e after call */
|
||||||
|
extern unsigned char x_ecb_data[]; /* Array to hold data blocks for ECB */
|
||||||
|
extern int x_ecb_error_count; /* Counter for ECB call errors */
|
||||||
|
extern Ecb_data x_ecba; /* DMA data from P2701a ECB-CPU */
|
||||||
|
extern int x_cpu_typ; /* =0: WP-CPU, =1: P2701 */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Functions
|
||||||
|
*******************************************************************************/
|
||||||
|
extern void Gpib_init (void);
|
||||||
|
extern int Gpib_error(void);
|
||||||
|
|
||||||
|
extern int Ecb_func (int , unsigned char); /* Call ECB function */
|
||||||
|
extern void Ecb_read (int, unsigned short, unsigned short); /* Read n bytes */
|
||||||
|
extern void Ecb_write (int, unsigned short, unsigned short); /* Write n bytes */
|
||||||
|
extern int Ecb_dma_read (int, unsigned short, unsigned short); /* DMA data */
|
||||||
|
extern void Ecb_memory_allocate (int size);
|
||||||
|
extern int Ecb_type (int);
|
||||||
|
|
||||||
|
extern void Ecb_init(void);
|
||||||
|
extern int Ecb_error(void);
|
||||||
|
|
||||||
|
extern void Ecb_load_error(void); /* Print error messages */
|
||||||
|
extern void Error_exit(void);
|
||||||
|
extern int Base_error(void);
|
||||||
|
|
725
utils/ecb_load_new/ecbdriv_els.c
Normal file
725
utils/ecb_load_new/ecbdriv_els.c
Normal file
@ -0,0 +1,725 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file contains the TASCOM ECB driver functions.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Project: TASCOM
|
||||||
|
* File name: ecbdriv_els.c
|
||||||
|
*
|
||||||
|
* Author: J. Bundgaard Nov. 1991.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (C) Risoe National Laboratory, 1991-1994, All rights reserved
|
||||||
|
*******************************************************************************/
|
||||||
|
/*******************************************************************************
|
||||||
|
*& modified by:
|
||||||
|
*&
|
||||||
|
*&
|
||||||
|
*& V003.101 P.S. 26-APR-2004
|
||||||
|
*& For the ecb_load program only.
|
||||||
|
*&
|
||||||
|
*&
|
||||||
|
*&*****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "ecb_load.h"
|
||||||
|
#include GPIB_H
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Static variables
|
||||||
|
*******************************************************************************/
|
||||||
|
static repete = 1;
|
||||||
|
static int look_up[] = {10, 11, 12, 13, 14 ,15};
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* External variables defined in this file.
|
||||||
|
*******************************************************************************/
|
||||||
|
int x_ecb1 = -1; /* Unit descriptor of ECB system #1 */
|
||||||
|
Z80_reg x_inreg; /* Z80 registers b,c,d and e before call */
|
||||||
|
Z80_reg x_outreg; /* Z80 registers b,c,d and e after call */
|
||||||
|
unsigned char x_ecb_data[ECB_BYTES]; /* Array to hold data blocks for ECB */
|
||||||
|
int x_ecb_error_count = 0; /* Counter for ECB call errors */
|
||||||
|
int x_cpu_typ = 0; /* =0: WP-CPU, =1: P2701, =2: P2701 + P2501 */
|
||||||
|
Ecb_data x_ecba; /* DMA data from P2701a ECB-CPU */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Prototypes for functions defined in this file.
|
||||||
|
*******************************************************************************/
|
||||||
|
extern void Ecb_init(void);
|
||||||
|
extern int Ecb_error(void);
|
||||||
|
extern void Ecb_unit (void); /* Establish unit No. for ECB */
|
||||||
|
extern int Ecb_func (int , unsigned char); /* Call ECB function */
|
||||||
|
extern void Ecb_read (int, unsigned short, unsigned short); /* Read n bytes */
|
||||||
|
extern void Ecb_write (int, unsigned short, unsigned short); /* Write n bytes */
|
||||||
|
|
||||||
|
static int Ecb_prepare (int, unsigned char, unsigned short, unsigned short);
|
||||||
|
static int Ecb_send_func (int, unsigned char); /* Send function code */
|
||||||
|
static void Ecb_error_func (char *, unsigned char, int);
|
||||||
|
static void Restart_ecb_func (int unit, unsigned char function);
|
||||||
|
static int Restart_ecb_prepare(int,unsigned char,unsigned short,unsigned short);
|
||||||
|
static void Do_reset (void);
|
||||||
|
extern void Ecb_down_load (FILE *stream);
|
||||||
|
static unsigned long Hex_to_bin(char c);
|
||||||
|
static char Bin_to_hex (int i);
|
||||||
|
extern int Ecb_type (int);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* ECB system initialisation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Ecb_init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
x_cpu_typ = 1; /* New CPU module, P2701 */
|
||||||
|
|
||||||
|
x_ecb1 = -1;
|
||||||
|
if (x_gpib0 >= 0)
|
||||||
|
{
|
||||||
|
x_ecb1 = ibfind (ECB1); /* Now see if the ECB system is avaiable */
|
||||||
|
if (x_ecb1 <= 0)
|
||||||
|
{
|
||||||
|
x_ecb1 = -1;
|
||||||
|
x_error_text =(char *) ECB1;
|
||||||
|
x_tas_error = GPIB_FIND_ERROR;
|
||||||
|
Ecb_load_error();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ibsic (x_gpib0); /* Send interface clear */
|
||||||
|
usleep (300000); /* Wait 0.3 sec. */
|
||||||
|
ibtmo (x_ecb1, T10s); /* Time out 10 sec. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x_tas_error = FALSE;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function to call a Z80 function (subroutine) without interrupt.
|
||||||
|
* This means that the function No. must be greater than or equal to
|
||||||
|
* 128 (function 0) and less than or equal to 191 (function 63).
|
||||||
|
* 'Unit' is the address of the ECB system on the GPIB bus. Four Z80 regs.
|
||||||
|
* are transferred upon the call from the host to the ECB system, and
|
||||||
|
* again read back to the host upon exit from the ECB function. This
|
||||||
|
* mechanismen is used to tranfer of arguments and results. Two global
|
||||||
|
* structures are used for the purpose, x_inreg and x_outreg.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern int
|
||||||
|
Ecb_func (int unit, unsigned char function)
|
||||||
|
{
|
||||||
|
int byte_cnt;
|
||||||
|
short status;
|
||||||
|
char *ecb_error_text;
|
||||||
|
void TC_FAR *point_input = &x_inreg;
|
||||||
|
void TC_FAR *point_output = &x_outreg;
|
||||||
|
|
||||||
|
if (Ecb_send_func (unit, function) == FALSE)
|
||||||
|
{
|
||||||
|
if (repete == 1)
|
||||||
|
Restart_ecb_func (unit, function); /* GPIB error: recall Ecb_func() once */
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function accepted. Send the 4 Z80 register values */
|
||||||
|
byte_cnt = 4;
|
||||||
|
status = ibwrt (unit, point_input, byte_cnt);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete ==1)
|
||||||
|
{
|
||||||
|
Restart_ecb_func (unit, function); /* GPIB error: recall Ecb_func() once */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_WRITE_ERROR;
|
||||||
|
ecb_error_text = "during write of data bytes at ECB function";
|
||||||
|
Ecb_error_func(ecb_error_text, function, unit);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
/* Wait for the function to complete and then receive the 4 Z80 regs. values */
|
||||||
|
status = ibrd (unit, point_output, byte_cnt);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete ==1)
|
||||||
|
{
|
||||||
|
Restart_ecb_func (unit, function); /* GPIB error: recall Ecb_func() once */
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_READ_ERROR;
|
||||||
|
ecb_error_text = "during read of data bytes at ECB function";
|
||||||
|
Ecb_error_func(ecb_error_text, function, unit);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function to re-call Ecb_func() in case of a GPIB bus error.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
Restart_ecb_func (int unit, unsigned char function)
|
||||||
|
{
|
||||||
|
|
||||||
|
Do_reset();
|
||||||
|
Ecb_func (unit, function);
|
||||||
|
repete = 1; /* Reset repete to allow re-calls */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function to re-call Ecb_send_func() in case of a GPIB bus error.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
Restart_ecb_prepare (int unit, unsigned char function,
|
||||||
|
unsigned short address, unsigned short byte_count)
|
||||||
|
{
|
||||||
|
short status;
|
||||||
|
|
||||||
|
Do_reset();
|
||||||
|
status = Ecb_prepare (unit, function, address, byte_count);
|
||||||
|
repete = 1; /* Reset repete to allow re-calls */
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Send Interface clear and print a message.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
Do_reset (void)
|
||||||
|
{
|
||||||
|
ibsic (x_gpib0); /* Send interface clear */
|
||||||
|
usleep (300000); /* Wait 0.3 sec. */
|
||||||
|
ibsic (x_gpib0); /* Send interface clear */
|
||||||
|
usleep (300000); /* Wait 0.3 sec. */
|
||||||
|
repete = 0; /* No more re-calls */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function that transfers 'byte_count' bytes from the ECB system to
|
||||||
|
* the host. 'Address' specifies source start address in the Z80 me-
|
||||||
|
* mory space. Destination is the global unsigned character array
|
||||||
|
* x_ecb_data.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Ecb_read (int unit, unsigned short address, unsigned short byte_count)
|
||||||
|
{
|
||||||
|
short status;
|
||||||
|
void TC_FAR *point_data = &x_ecb_data;
|
||||||
|
|
||||||
|
if (Ecb_prepare (unit, READ_N_BYTES, address, byte_count) == FALSE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Read the requested No. of bytes */
|
||||||
|
status = ibrd (unit, point_data, (int) byte_count);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_READ_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function that transfers 'byte_count' bytes from the host to the ECB
|
||||||
|
* system. 'Address' specifies destination start address in the Z80 me-
|
||||||
|
* mory space. Source is the global unsigned character array x_ecb_data.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Ecb_write (int unit, unsigned short address, unsigned short byte_count)
|
||||||
|
{
|
||||||
|
short status;
|
||||||
|
char *ecb_error_text;
|
||||||
|
void TC_FAR *point_data = &x_ecb_data;
|
||||||
|
|
||||||
|
if (Ecb_prepare (unit, WRITE_N_BYTES, address, byte_count) == FALSE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Write the requested No. of bytes */
|
||||||
|
status = ibwrt (unit, point_data, (int) byte_count);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_WRITE_ERROR;
|
||||||
|
ecb_error_text = "";
|
||||||
|
Ecb_error_func(ecb_error_text, 0, unit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Receive a dummy byte */
|
||||||
|
byte_count = 1;
|
||||||
|
status = ibrd (unit, point_data, (int) byte_count);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_READ_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Prepare an ECB read or write n bytes. See Ecb_read() and Ecb_write().
|
||||||
|
*******************************************************************************/
|
||||||
|
static int
|
||||||
|
Ecb_prepare (int unit, unsigned char function,
|
||||||
|
unsigned short address, unsigned short byte_count)
|
||||||
|
{
|
||||||
|
int byte_cnt;
|
||||||
|
short status;
|
||||||
|
Swap save, adr, count;
|
||||||
|
char *ecb_error_text;
|
||||||
|
void TC_FAR *point_adress = (Swap *) &adr.word;
|
||||||
|
void TC_FAR *point_count = (Swap *) &count.word;
|
||||||
|
|
||||||
|
if (byte_count > ECB_BYTES)
|
||||||
|
{
|
||||||
|
x_error_int = byte_count;
|
||||||
|
x_tas_error = ECB_OVERFLOW;
|
||||||
|
ecb_error_text = "";
|
||||||
|
Ecb_error_func(ecb_error_text, 0, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
save.word = address; /* Swap address bytes */
|
||||||
|
adr.b.lsb = save.b.msb;
|
||||||
|
adr.b.msb = save.b.lsb;
|
||||||
|
save.word = byte_count; /* Swap byte count bytes */
|
||||||
|
count.b.lsb = save.b.msb;
|
||||||
|
count.b.msb = save.b.lsb;
|
||||||
|
|
||||||
|
if (Ecb_send_func (unit, function) == FALSE)
|
||||||
|
{
|
||||||
|
if (repete ==1)
|
||||||
|
{ /* GPIB error, Restart Ecb_prepare() once */
|
||||||
|
status = Restart_ecb_prepare (unit, function, address, byte_count);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
ecb_error_text = "during write of ECB function code ";
|
||||||
|
Ecb_error_func(ecb_error_text, function, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte_cnt = 2; /* Function accepted, send the two byte address value */
|
||||||
|
status = ibwrt (unit, point_adress, byte_cnt);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete ==1)
|
||||||
|
{ /* GPIB error, Restart Ecb_prepare() once */
|
||||||
|
Restart_ecb_prepare (unit, function, address, byte_count);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_WRITE_ERROR;
|
||||||
|
ecb_error_text = "";
|
||||||
|
Ecb_error_func(ecb_error_text, 0, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
/* Send the two byte byte_count value */
|
||||||
|
status = ibwrt (unit, point_count, byte_cnt);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete ==1)
|
||||||
|
{ /* GPIB error, Restart Ecb_prepare() once */
|
||||||
|
Restart_ecb_prepare (unit, function, address, byte_count);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_WRITE_ERROR;
|
||||||
|
ecb_error_text = "";
|
||||||
|
Ecb_error_func(ecb_error_text, 0, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function to send ECB function code and receive an acknowledge
|
||||||
|
* character as response.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
Ecb_send_func (int unit, unsigned char function)
|
||||||
|
{
|
||||||
|
unsigned char response;
|
||||||
|
unsigned long byte_cnt;
|
||||||
|
int error_type;
|
||||||
|
short status;
|
||||||
|
char *ecb_error_text;
|
||||||
|
void TC_FAR *point_func = &function;
|
||||||
|
void TC_FAR *point_resp = &response;
|
||||||
|
|
||||||
|
byte_cnt = 1; /* Send function code */
|
||||||
|
status = ibwrt (unit, point_func, byte_cnt);
|
||||||
|
error_type = iberr;
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete == 1)
|
||||||
|
return(FALSE);
|
||||||
|
if (status | TIMO)
|
||||||
|
{
|
||||||
|
if ((error_type == ENOL) || (error_type == EBUS))
|
||||||
|
{
|
||||||
|
x_error_text = ECBTEXT;
|
||||||
|
x_tas_error = GPIB_NO_LISNER_ERROR;
|
||||||
|
Ecb_load_error();
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_WRITE_ERROR;
|
||||||
|
Ecb_load_error();
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get acknowledge byte back */
|
||||||
|
status = ibrd (unit, point_resp, byte_cnt);
|
||||||
|
if (status < 0)
|
||||||
|
{
|
||||||
|
if (repete == 1)
|
||||||
|
return(FALSE);
|
||||||
|
if (status | TIMO)
|
||||||
|
x_error_text = "Timeout";
|
||||||
|
else
|
||||||
|
x_error_text = '\0';
|
||||||
|
x_tas_error = GPIB_READ_ERROR;
|
||||||
|
ecb_error_text = "during read of ack-byte at ECB function ";
|
||||||
|
Ecb_error_func(ecb_error_text, function, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
if (response != ACKN) /* Acknowledge ? */
|
||||||
|
{
|
||||||
|
x_error_int = function;
|
||||||
|
x_tas_error = ECB_ILLEGAL_FUNC;
|
||||||
|
ecb_error_text = " ECB function code ";
|
||||||
|
Ecb_error_func(ecb_error_text, function, unit);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Errors at calls to the ECB system. After two ECB errors TASCOM
|
||||||
|
* returns to DOS.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
Ecb_error_func (char *ecb_error_text, unsigned char function, int unit)
|
||||||
|
{
|
||||||
|
|
||||||
|
Ecb_load_error();
|
||||||
|
if (function != 0)
|
||||||
|
{
|
||||||
|
printf ("%s %d\n",ecb_error_text, function);
|
||||||
|
fflush (stdout);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Errors at calls to the ECB system. After two ECB errors TASCOM
|
||||||
|
* returns to DOS.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
Ecb_error_func1 (char *ecb_error_text, unsigned char function, int unit)
|
||||||
|
{
|
||||||
|
|
||||||
|
Ecb_load_error();
|
||||||
|
if (function != 0)
|
||||||
|
{
|
||||||
|
printf ("%s %d\n",ecb_error_text, function);
|
||||||
|
fflush (stdout);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Down load the ECB program.
|
||||||
|
* Reads lines from the HEX file and add up to 20 data lines together before
|
||||||
|
* sending them to the ECB system.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Ecb_down_load (FILE *stream)
|
||||||
|
{
|
||||||
|
int ecb_type, unit, function, load_count = -1;
|
||||||
|
char *point;
|
||||||
|
unsigned short byte_count, address;
|
||||||
|
char line[F_BUFSIZ];
|
||||||
|
unsigned long type, no_bytes, adrs, total_bytes, old_adrs, total1, total0, total2;
|
||||||
|
int line_no = 0;
|
||||||
|
void TC_FAR *point_func = &function;
|
||||||
|
int line_not_output = 0; /* if =1: data waiting in line[] */
|
||||||
|
void TC_FAR *line9 = &line[9];
|
||||||
|
|
||||||
|
|
||||||
|
/* Stop_display(); */
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (line_not_output == 1)
|
||||||
|
line_not_output = 0; /* Start with old line */
|
||||||
|
else
|
||||||
|
{ /* Read a line from file */
|
||||||
|
point = fgets (line, F_BUFSIZ, stream);
|
||||||
|
if (point != NULL)
|
||||||
|
{
|
||||||
|
byte_count = strlen(line);
|
||||||
|
byte_count -= 4; /* Remove checksum and \n in the */
|
||||||
|
line[byte_count+1] = NUL; /* line, i.e. the four last characters */
|
||||||
|
line[0] = '0'; /* Replace : in line[0] with 0 */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ferror(stream))
|
||||||
|
byte_count = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose (stream);
|
||||||
|
stream = NULL;
|
||||||
|
x_tas_error = FILE_READ;
|
||||||
|
Ecb_load_error ();
|
||||||
|
printf (" during download of the ECB program\n");
|
||||||
|
/* Start_display(); */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line_no += 1;
|
||||||
|
if (byte_count != 0)
|
||||||
|
{
|
||||||
|
if (line_no == 1)
|
||||||
|
strcpy (x_ecb_data, line);
|
||||||
|
type = (Hex_to_bin(line[7]) << 4) + Hex_to_bin(line[8]);
|
||||||
|
if (type != 0)
|
||||||
|
{
|
||||||
|
if (line_no > 1) /* Output buffer and mark that */
|
||||||
|
line_not_output = 1; /* last input line has not been output */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
no_bytes = (Hex_to_bin(line[1]) << 4) + Hex_to_bin(line[2]);
|
||||||
|
adrs = (Hex_to_bin(line[3]) << 12) + (Hex_to_bin(line[4]) << 8) +
|
||||||
|
(Hex_to_bin(line[5]) << 4) + Hex_to_bin(line[6]);
|
||||||
|
if (line_no == 1)
|
||||||
|
{
|
||||||
|
total_bytes = no_bytes;
|
||||||
|
old_adrs = adrs;
|
||||||
|
continue; /* Get next input line */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (old_adrs + no_bytes == adrs)
|
||||||
|
{ /* Contigious addresses */
|
||||||
|
total_bytes += no_bytes;
|
||||||
|
old_adrs = adrs;
|
||||||
|
strcat (x_ecb_data, line9); /* Add the new bytes to buffer */
|
||||||
|
total0 = total_bytes/256; /* and adjust number of bytes */
|
||||||
|
x_ecb_data[0] = Bin_to_hex(total0);
|
||||||
|
total1 = total_bytes - 256*total0;
|
||||||
|
total2 = total1/16;
|
||||||
|
x_ecb_data[1] = Bin_to_hex(total2);
|
||||||
|
x_ecb_data[2] = Bin_to_hex(total1 - 16*total2);
|
||||||
|
if (line_no < 20) /* Max 20 lines together */
|
||||||
|
continue; /* Get next input line */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line_not_output = 0; /* Output buffer, nothing waiting in line[] */
|
||||||
|
}
|
||||||
|
|
||||||
|
unit = x_ecb1;
|
||||||
|
address = 1;
|
||||||
|
byte_count = strlen (x_ecb_data);
|
||||||
|
Ecb_write (unit, address, byte_count); /* Write a line to ECB */
|
||||||
|
line_no = 0;
|
||||||
|
|
||||||
|
/* if (Test_ctrl_c())
|
||||||
|
/* {
|
||||||
|
/* Start_display();
|
||||||
|
/* return; /* Control(c) hit */
|
||||||
|
/* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (load_count == -1) /* Type Loading followed by dots while */
|
||||||
|
{ /* down loading the file */
|
||||||
|
printf ("\nLoading");
|
||||||
|
fflush (stdout);
|
||||||
|
load_count = 0;
|
||||||
|
}
|
||||||
|
load_count += 1;
|
||||||
|
|
||||||
|
if (load_count > 15)
|
||||||
|
{
|
||||||
|
printf (".");
|
||||||
|
fflush (stdout);
|
||||||
|
load_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function = ECB_DOWN_LOAD;
|
||||||
|
Ecb_func (unit, function); /* Call ECB download function */
|
||||||
|
if (x_outreg.b != LOAD_NEXT) /* Wait for reply from ECB */
|
||||||
|
break; /* If LOAD_NEXT, get next line, else finished */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf ("\nLoading complete\n");
|
||||||
|
fflush (stdout);
|
||||||
|
|
||||||
|
/* Start_display(); */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Convert HEX to bin
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static unsigned long
|
||||||
|
Hex_to_bin(char c)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isdigit((int) c))
|
||||||
|
return (c - '0');
|
||||||
|
else
|
||||||
|
return look_up[c - 'A'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Convert Bin to HEX
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
static char
|
||||||
|
Bin_to_hex (int i)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(i <= 9)
|
||||||
|
return ( (char)(i + (int)('0')) );
|
||||||
|
else
|
||||||
|
return ( (char)( (i - 10) + (int)('A')) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Get type and version of the ECB program. If return_value is TYPE_OUT, the
|
||||||
|
* type is returned as 1 for RAM and 0 for ROM. If return_value is VERS_OUT,
|
||||||
|
* the version number * 100 is returned.
|
||||||
|
* If return_value = 0, type and version are printed.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
extern int
|
||||||
|
Ecb_type (int return_value)
|
||||||
|
{
|
||||||
|
int unit, function;
|
||||||
|
int version, status;
|
||||||
|
|
||||||
|
|
||||||
|
/* P2701a CPU: Get ROM/RAM type */
|
||||||
|
unit = x_ecb1;
|
||||||
|
function = ECB_TYPE;
|
||||||
|
status = Ecb_func (unit, function);
|
||||||
|
if (status == 0)
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
|
||||||
|
version = 100*(int)x_outreg.b + 10*(int)x_outreg.c + (int)x_outreg.e;
|
||||||
|
|
||||||
|
if (return_value == TYPE_OUT)
|
||||||
|
return((int) x_outreg.d);
|
||||||
|
|
||||||
|
if (return_value == VERS_OUT)
|
||||||
|
return(version);
|
||||||
|
|
||||||
|
printf ("ECB program: ");
|
||||||
|
if (x_outreg.d == 1)
|
||||||
|
printf ("RAM");
|
||||||
|
else if (x_outreg.d == 0)
|
||||||
|
printf ("ROM");
|
||||||
|
printf (" mode, version %4.2f\n", ((float) version)/100);
|
||||||
|
fflush (stdout);
|
||||||
|
|
||||||
|
return((int) x_outreg.d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Ecb option error routine.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern int
|
||||||
|
Ecb_error(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (x_tas_error)
|
||||||
|
{
|
||||||
|
case ECB_OVERFLOW:
|
||||||
|
printf (" Byte count %d overflows ECB data buffer.", x_error_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ECB_ILLEGAL_FUNC:
|
||||||
|
printf (" No such ECB function: %d", x_error_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return(NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("\n");
|
||||||
|
fflush (stdout);
|
||||||
|
return(FOUND);
|
||||||
|
|
||||||
|
}
|
116
utils/ecb_load_new/gpib_els.c
Normal file
116
utils/ecb_load_new/gpib_els.c
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file contains the interface for the gpib option
|
||||||
|
* in the Risoe process control and data acquisition program TASCOM.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Project: TASCOM
|
||||||
|
* File name: gpib_els.c
|
||||||
|
*
|
||||||
|
* Author: P.S. May 2004
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
/*******************************************************************************
|
||||||
|
*& modificaions:
|
||||||
|
*&
|
||||||
|
*& V003.101 P.S. 26-APR-2004
|
||||||
|
*& For the ecb_load program only.
|
||||||
|
*&
|
||||||
|
*&
|
||||||
|
*&*****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "ecb_load.h"
|
||||||
|
|
||||||
|
#include GPIB_H
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Static variables
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Extern variables defined in this file.
|
||||||
|
*******************************************************************************/
|
||||||
|
int x_gpib0; /* Unit descriptor for board (adaptor) 0 */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Prototypes for functions defined in this file.
|
||||||
|
*******************************************************************************/
|
||||||
|
extern void Gpib_init (void);
|
||||||
|
extern int Gpib_error(void);
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Set the GPIB delay and if look_for_board = LOOK_FOR_BOARD, see if we have a
|
||||||
|
* GPIB module in the computer.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Gpib_init (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
x_gpib0 = -1;
|
||||||
|
|
||||||
|
/* See if the GPIB module is avaiable */
|
||||||
|
x_gpib0 = ibfind (GPIB0);
|
||||||
|
if (x_gpib0 < 0)
|
||||||
|
{
|
||||||
|
x_error_text = (char *) GPIB0;
|
||||||
|
x_tas_error = GPIB_FIND_ERROR;
|
||||||
|
Ecb_load_error ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ibconfig (x_gpib0, IbcTIMING, 1);
|
||||||
|
ibsic (x_gpib0); /* Send interface clear */
|
||||||
|
usleep (300000); /* Wait 0.3 sec. */
|
||||||
|
|
||||||
|
x_tas_error = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Gpib option error routine.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
extern int
|
||||||
|
Gpib_error(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (x_tas_error)
|
||||||
|
{
|
||||||
|
case GPIB_WRITE_ERROR:
|
||||||
|
printf (" GPIB write error: %s", x_error_text);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GPIB_READ_ERROR:
|
||||||
|
printf (" GPIB read error: %s", x_error_text);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GPIB_FIND_ERROR:
|
||||||
|
printf (" No GPIB module in the computer ?");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GPIB_NO_LISNER_ERROR:
|
||||||
|
printf (" No Listener. Communication error to the %s.\n", x_error_text);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return(NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("\n");
|
||||||
|
fflush (stdout);
|
||||||
|
return(FOUND);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
101
utils/ecb_load_new/makefile
Normal file
101
utils/ecb_load_new/makefile
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
# LIBRARY NAMES GIVEN BELOW
|
||||||
|
LIBRARIES=/usr/local/lib/libgpibenet.a
|
||||||
|
|
||||||
|
# INCLUDE SEARCH PATH GIVEN BELOW
|
||||||
|
INCLUDES= -Iinclude
|
||||||
|
|
||||||
|
VPATH=.:include
|
||||||
|
|
||||||
|
# LINKER FLAGS GIVEN BELOW
|
||||||
|
LDFLAGS=-L/usr/local/lib
|
||||||
|
|
||||||
|
# DEFINES
|
||||||
|
LD=gcc
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
# COMPILER FLAGS GIVEN BELOW
|
||||||
|
CFLAGS= -c -g
|
||||||
|
PFLAGS=$(CFLAGS)
|
||||||
|
FFLAGS=$(CFLAGS)
|
||||||
|
|
||||||
|
.SUFFIXES: .uil .uid .c .o .f .for .F .hpf .mpl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# SOURCES GIVEN BELOW
|
||||||
|
SRCS=ecb_load.c ecbdriv_els.c gpib_els.c
|
||||||
|
|
||||||
|
# OBJECTS GIVEN BELOW
|
||||||
|
OBJS=ecb_load.o ecbdriv_els.o gpib_els.o
|
||||||
|
|
||||||
|
ecb_load : $(OBJS)
|
||||||
|
$(LD) -g -o $@ $(LDFLAGS) $(OBJS) $(LIBRARIES) -lm -ltermcap
|
||||||
|
|
||||||
|
|
||||||
|
# INCLUDE FILE DEPENDENCY GIVEN BELOW
|
||||||
|
|
||||||
|
ecb_load.o: ecb_load.h
|
||||||
|
|
||||||
|
ecbdriv_els.o: ecb_load.h
|
||||||
|
|
||||||
|
gpib_els.o: ecb_load.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -rf $(OBJS) core tascom
|
||||||
|
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
.f.o:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.p.o:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.c.a:
|
||||||
|
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.f.a:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.p.a:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
lint:
|
||||||
|
lint $(INCLUDES) $(SRCS) $(LINTLIBS)
|
||||||
|
|
||||||
|
|
||||||
|
depend:
|
||||||
|
@cat < /dev/null > makedep
|
||||||
|
@for i in ${SRCS}; do \
|
||||||
|
($(CC) -M $(INCLUDES) $$i >> makedep); done
|
||||||
|
@echo '/^# DO NOT DELETE THIS LINE/+1,$$d' > eddep
|
||||||
|
@echo '$$r makedep' >> eddep
|
||||||
|
@echo 'w' >> eddep
|
||||||
|
@${CP} makefile makefile.bak
|
||||||
|
@ed - makefile < eddep
|
||||||
|
@$(RM) -f eddep makedep
|
||||||
|
@echo '# DO NOT EDIT THIS FILE HERE.' >> makefile
|
||||||
|
@echo '# USER EDITS MUST PRECEDE THE COMMENT:' >> makefile
|
||||||
|
@echo '# "# DO NOT DELETE THIS LINE".' >> makefile
|
||||||
|
@echo '# see make depend above' >> makefile
|
||||||
|
|
||||||
|
|
||||||
|
touchsrcs:
|
||||||
|
touch $(SRCS)
|
||||||
|
|
||||||
|
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||||
|
|
103
utils/ecb_load_new/makefile_EGPIB
Normal file
103
utils/ecb_load_new/makefile_EGPIB
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
# LIBRARY NAMES GIVEN BELOW
|
||||||
|
LIBRARIES=/usr/local/lib/libgpibenet.a
|
||||||
|
|
||||||
|
# INCLUDE SEARCH PATH GIVEN BELOW
|
||||||
|
INCLUDES= -Iinclude
|
||||||
|
|
||||||
|
VPATH=.:include
|
||||||
|
|
||||||
|
# LINKER FLAGS GIVEN BELOW
|
||||||
|
LDFLAGS=-L/usr/local/lib
|
||||||
|
|
||||||
|
# DEFINES
|
||||||
|
LD=gcc
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
# COMPILER FLAGS GIVEN BELOW
|
||||||
|
CFLAGS= -c -g
|
||||||
|
PFLAGS=$(CFLAGS)
|
||||||
|
FFLAGS=$(CFLAGS)
|
||||||
|
|
||||||
|
.SUFFIXES: .uil .uid .c .o .f .for .F .hpf .mpl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# SOURCES GIVEN BELOW
|
||||||
|
SRCS=ecb-load.c ecbdriv_els.c gpib_els.c error_els.c
|
||||||
|
|
||||||
|
# OBJECTS GIVEN BELOW
|
||||||
|
OBJS=ecb-load.o ecbdriv_els.o gpib_els.o error_els.o
|
||||||
|
|
||||||
|
ecb_load : $(OBJS)
|
||||||
|
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBRARIES) -lm -ltermcap
|
||||||
|
|
||||||
|
|
||||||
|
# INCLUDE FILE DEPENDENCY GIVEN BELOW
|
||||||
|
|
||||||
|
ecb_load.o: ecb_load.h
|
||||||
|
|
||||||
|
ecbdriv_els.o: ecb_load.h
|
||||||
|
|
||||||
|
gpib_els.o: ecb_load.h
|
||||||
|
|
||||||
|
error_els.o: ecb_load.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -rf $(OBJS) core tascom
|
||||||
|
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
.f.o:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.p.o:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.c.a:
|
||||||
|
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.f.a:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.p.a:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
lint:
|
||||||
|
lint $(INCLUDES) $(SRCS) $(LINTLIBS)
|
||||||
|
|
||||||
|
|
||||||
|
depend:
|
||||||
|
@cat < /dev/null > makedep
|
||||||
|
@for i in ${SRCS}; do \
|
||||||
|
($(CC) -M $(INCLUDES) $$i >> makedep); done
|
||||||
|
@echo '/^# DO NOT DELETE THIS LINE/+1,$$d' > eddep
|
||||||
|
@echo '$$r makedep' >> eddep
|
||||||
|
@echo 'w' >> eddep
|
||||||
|
@${CP} makefile makefile.bak
|
||||||
|
@ed - makefile < eddep
|
||||||
|
@$(RM) -f eddep makedep
|
||||||
|
@echo '# DO NOT EDIT THIS FILE HERE.' >> makefile
|
||||||
|
@echo '# USER EDITS MUST PRECEDE THE COMMENT:' >> makefile
|
||||||
|
@echo '# "# DO NOT DELETE THIS LINE".' >> makefile
|
||||||
|
@echo '# see make depend above' >> makefile
|
||||||
|
|
||||||
|
|
||||||
|
touchsrcs:
|
||||||
|
touch $(SRCS)
|
||||||
|
|
||||||
|
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||||
|
|
103
utils/ecb_load_new/makefile_GPIB
Normal file
103
utils/ecb_load_new/makefile_GPIB
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
# LIBRARY NAMES GIVEN BELOW
|
||||||
|
LIBRARIES=/usr/local/lib/libgpib.a
|
||||||
|
|
||||||
|
# INCLUDE SEARCH PATH GIVEN BELOW
|
||||||
|
INCLUDES= -Iinclude
|
||||||
|
|
||||||
|
VPATH=.:include
|
||||||
|
|
||||||
|
# LINKER FLAGS GIVEN BELOW
|
||||||
|
LDFLAGS=-L/usr/local/lib
|
||||||
|
|
||||||
|
# DEFINES
|
||||||
|
LD=gcc
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
# COMPILER FLAGS GIVEN BELOW
|
||||||
|
CFLAGS= -c -g
|
||||||
|
PFLAGS=$(CFLAGS)
|
||||||
|
FFLAGS=$(CFLAGS)
|
||||||
|
|
||||||
|
.SUFFIXES: .uil .uid .c .o .f .for .F .hpf .mpl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# SOURCES GIVEN BELOW
|
||||||
|
SRCS=ecb-load.c ecbdriv_els.c gpib_els.c error_els.c
|
||||||
|
|
||||||
|
# OBJECTS GIVEN BELOW
|
||||||
|
OBJS=ecb-load.o ecbdriv_els.o gpib_els.o error_els.o
|
||||||
|
|
||||||
|
ecb_load : $(OBJS)
|
||||||
|
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBRARIES) -lm -ltermcap
|
||||||
|
|
||||||
|
|
||||||
|
# INCLUDE FILE DEPENDENCY GIVEN BELOW
|
||||||
|
|
||||||
|
ecb_load.o: ecb_load.h
|
||||||
|
|
||||||
|
ecbdriv_els.o: ecb_load.h
|
||||||
|
|
||||||
|
gpib_els.o: ecb_load.h
|
||||||
|
|
||||||
|
error_els.o: ecb_load.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -rf $(OBJS) core tascom
|
||||||
|
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
.f.o:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.p.o:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
|
||||||
|
|
||||||
|
.c.a:
|
||||||
|
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.f.a:
|
||||||
|
$(FC) -c $(FFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
.p.a:
|
||||||
|
$(PC) -c $(PFLAGS) $(INCLUDES) $<
|
||||||
|
$(AR) $(ARFLAGS) $@ $*.o
|
||||||
|
$(RM) -f $*.o
|
||||||
|
|
||||||
|
lint:
|
||||||
|
lint $(INCLUDES) $(SRCS) $(LINTLIBS)
|
||||||
|
|
||||||
|
|
||||||
|
depend:
|
||||||
|
@cat < /dev/null > makedep
|
||||||
|
@for i in ${SRCS}; do \
|
||||||
|
($(CC) -M $(INCLUDES) $$i >> makedep); done
|
||||||
|
@echo '/^# DO NOT DELETE THIS LINE/+1,$$d' > eddep
|
||||||
|
@echo '$$r makedep' >> eddep
|
||||||
|
@echo 'w' >> eddep
|
||||||
|
@${CP} makefile makefile.bak
|
||||||
|
@ed - makefile < eddep
|
||||||
|
@$(RM) -f eddep makedep
|
||||||
|
@echo '# DO NOT EDIT THIS FILE HERE.' >> makefile
|
||||||
|
@echo '# USER EDITS MUST PRECEDE THE COMMENT:' >> makefile
|
||||||
|
@echo '# "# DO NOT DELETE THIS LINE".' >> makefile
|
||||||
|
@echo '# see make depend above' >> makefile
|
||||||
|
|
||||||
|
|
||||||
|
touchsrcs:
|
||||||
|
touch $(SRCS)
|
||||||
|
|
||||||
|
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
#
|
|
||||||
# Makefile for the ECB load program on Linux, PSI setup
|
|
||||||
CC =cc
|
|
||||||
CFLAGS = -g -I$(SINQDIR)/linux/include
|
|
||||||
OBJS = ecb-drv.o ecb-load.o gpib-drv.o
|
|
||||||
LIBS = $(SINQDIR)/linux/lib/libgpibenet.so
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
ecb-load: $(OBJS)
|
|
||||||
$(CC) -g -o ecb-load $(OBJS) $(LIBS) -lfl
|
|
||||||
|
|
||||||
ecb-drv.o: ecb-drv.c ecb-drv.h gpib-drv.h
|
|
||||||
$(CC) $(CFLAGS) -c ecb-drv.c
|
|
||||||
|
|
||||||
ecb-load.o: ecb-load.c ecb-drv.h gpib-drv.h
|
|
||||||
$(CC) $(CFLAGS) -c ecb-load.c
|
|
||||||
|
|
||||||
gpib-drv.o: gpib-drv.c gpib-drv.h
|
|
||||||
$(CC) $(CFLAGS) -c gpib-drv.c
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm *~
|
|
||||||
-rm $(OBJS)
|
|
||||||
-rm ecb-load
|
|
||||||
-rm core
|
|
Reference in New Issue
Block a user