epicsUInt32 checkVersion(volatile epicsUInt8 *base, unsigned int required) { #ifndef __linux__ epicsUInt32 junk; if(devReadProbe(sizeof(junk), (volatile void*)(base+U32_FWVersion), (void*)&junk)) { throw std::runtime_error("Failed to read from MRM registers (but could read CSR registers)\n"); } #endif epicsUInt32 type, ver; epicsUInt32 v = READ32(base, FWVersion); epicsPrintf("FPGA version: %08x\n", v); type = v >> FWVersion_type_shift; if(type != 0x2){ errlogPrintf("Found type %x which does not correspond to EVG type 0x2.\n", type); return 0; } ver = v & FWVersion_ver_mask; if(ver < required) { errlogPrintf("Firmware version >= %x is required got %x\n", required,ver); return 0; } return ver; }
/* Check the interface version of the kernel module to ensure compatibility */ static int checkUIOVersion(int expect) { FILE *fd; int version = -1; fd = fopen(ifaceversion, "r"); if(!fd) { errlogPrintf("Can't open %s in order to read kernel module interface version. Is kernel module loaded?\n", ifaceversion); return 1; } if(fscanf(fd, "%d", &version) != 1) { errlogPrintf("Failed to read %s in order to get the kernel module interface version. Is kernel module loaded?\n", ifaceversion); fclose(fd); return 1; } fclose(fd); if(version<expect) { errlogPrintf("Error: Expect MRF kernel module version %d, found %d.\n", version, expect); return 1; } if(version > expect){ epicsPrintf("Info: Expect MRF kernel module version %d, found %d.\n", version, expect); } return 0; }
epicsShareFunc int devLibPCIUse(const char* use) { ELLNODE *cur; devLibPCI *drv; if (!use) use="native"; epicsThreadOnce(&devPCIReg_once, ®Init, NULL); epicsMutexMustLock(pciDriversLock); if (pdevLibPCI) { epicsMutexUnlock(pciDriversLock); errlogPrintf("PCI bus driver already selected. Can't change selection\n"); return 1; } for(cur=ellFirst(&pciDrivers); cur; cur=ellNext(cur)) { drv=CONTAINER(cur, devLibPCI, node); if (strcmp(drv->name, use)==0) { pdevLibPCI = drv; epicsMutexUnlock(pciDriversLock); return 0; } } epicsMutexUnlock(pciDriversLock); errlogPrintf("PCI bus driver '%s' not found\n",use); return 1; }
/*BEGIN STANDARD RECORD SUPPORT ROUTINES*/ LOCAL long init_record(ab1771IXRecord *precord,int pass) { abStatus status; recordPvt *precordPvt; if(pass!=0) return(0); precord->iai1 = &mydevIai1; precord->dpvt = precordPvt = dbCalloc(1,sizeof(recordPvt)); callbackSetCallback(myCallback,&precordPvt->callback); callbackSetUser(precord,&precordPvt->callback); precord->inpm = (short *)dbCalloc(NUM_WORDS_IN,sizeof(short)); precord->outm = (short *)dbCalloc(NUM_WORDS_OUT,sizeof(short)); status = (*pabDrv->registerCard)(precord->link,precord->rack, precord->slot,typeBt,"ab1771IX",drvCallback,&precordPvt->drvPvt); if(status!=abNewCard) { if(status==abSuccess) errlogPrintf("record %s slot already used\n",precord->name); else errlogPrintf("record %s init error %s\n",precord->name, abStatusMessage[status]); issueError(precord,errFatal," while registering card"); precord->pact = TRUE; /*leave record active*/ return(0); } (*pabDrv->setUserPvt)(precordPvt->drvPvt,(void *)precord); msgInit(precord); precord->udf = FALSE; return(0); }
void devPCIShowDevice(int lvl, const epicsPCIDevice *dev) { int i; errlogPrintf("PCI %04x:%02x:%02x.%x IRQ %u\n" " vendor:device %04x:%04x rev %02x\n", dev->domain, dev->bus, dev->device, dev->function, dev->irq, dev->id.vendor, dev->id.device, dev->id.revision); if(lvl<1) return; errlogPrintf(" subved:subdev %04x:%04x\n" " class %06x %s\n", dev->id.sub_vendor, dev->id.sub_device, dev->id.pci_class, devPCIDeviceClassToString(dev->id.pci_class)); if (dev->driver) errlogPrintf(" driver %s\n", dev->driver); if(lvl<2) return; for(i=0; i<PCIBARCOUNT; i++) { epicsUInt32 len; if ((*pdevLibPCI->pDevPCIBarLen)(dev, i, &len) == 0 && len > 0) { char* u = ""; if (len >= 1024) { len >>= 10; u = "k"; } if (len >= 1024) { len >>= 10; u = "M"; }
static void deleteFromList(struct dbCommon *precord, scan_list *psl) { scan_element *pse; epicsMutexMustLock(psl->lock); pse = precord->spvt; if (pse == NULL) { epicsMutexUnlock(psl->lock); errlogPrintf("dbScan: Tried to delete record from wrong scan list!\n" "\t%s.SPVT = NULL, but psl = %p\n", precord->name, (void *)psl); return; } if (pse->pscan_list != psl) { epicsMutexUnlock(psl->lock); errlogPrintf("dbScan: Tried to delete record from wrong scan list!\n" "\t%s.SPVT->pscan_list = %p but psl = %p\n", precord->name, (void *)pse, (void *)psl); return; } pse->pscan_list = NULL; ellDelete(&psl->list, (void *)pse); psl->modified = TRUE; epicsMutexUnlock(psl->lock); }
static void initPeriodic(void) { dbMenu *pmenu = dbFindMenu(pdbbase, "menuScan"); double quantum = epicsThreadSleepQuantum(); int i; if (!pmenu) { errlogPrintf("initPeriodic: menuScan not present\n"); return; } nPeriodic = pmenu->nChoice - SCAN_1ST_PERIODIC; papPeriodic = dbCalloc(nPeriodic, sizeof(periodic_scan_list*)); periodicTaskId = dbCalloc(nPeriodic, sizeof(void *)); for (i = 0; i < nPeriodic; i++) { periodic_scan_list *ppsl = dbCalloc(1, sizeof(periodic_scan_list)); const char *choice = pmenu->papChoiceValue[i + SCAN_1ST_PERIODIC]; double number; char *unit; int status = epicsParseDouble(choice, &number, &unit); ppsl->scan_list.lock = epicsMutexMustCreate(); ellInit(&ppsl->scan_list.list); ppsl->name = choice; if (status || number == 0) { errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice); ppsl->period = i; } else if (!*unit || !epicsStrCaseCmp(unit, "second") || !epicsStrCaseCmp(unit, "seconds")) { ppsl->period = number; } else if (!epicsStrCaseCmp(unit, "minute") || !epicsStrCaseCmp(unit, "minutes")) { ppsl->period = number * 60; } else if (!epicsStrCaseCmp(unit, "hour") || !epicsStrCaseCmp(unit, "hours")) { ppsl->period = number * 60 * 60; } else if (!epicsStrCaseCmp(unit, "Hz") || !epicsStrCaseCmp(unit, "Hertz")) { ppsl->period = 1 / number; } else { errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice); ppsl->period = i; } number = ppsl->period / quantum; if ((ppsl->period < 2 * quantum) || (number / floor(number) > 1.1)) { errlogPrintf("initPeriodic: Scan rate '%s' is not achievable.\n", choice); } ppsl->scanCtl = ctlPause; ppsl->loopEvent = epicsEventMustCreate(epicsEventEmpty); papPeriodic[i] = ppsl; } }
casBufferFactory::casBufferFactory () : smallBufFreeList ( 0 ), largeBufFreeList ( 0 ), largeBufferSizePriv ( 0u ) { long maxBytesAsALong; long status = envGetLongConfigParam ( & EPICS_CA_MAX_ARRAY_BYTES, & maxBytesAsALong ); if ( status || maxBytesAsALong < 0 ) { errlogPrintf ( "cas: EPICS_CA_MAX_ARRAY_BYTES was not a positive integer\n" ); this->largeBufferSizePriv = MAX_TCP; } else { /* allow room for the protocol header so that they get the array size they requested */ static const unsigned headerSize = sizeof ( caHdr ) + 2 * sizeof ( ca_uint32_t ); ca_uint32_t maxBytes = ( unsigned ) maxBytesAsALong; if ( maxBytes < 0xffffffff - headerSize ) { maxBytes += headerSize; } else { maxBytes = 0xffffffff; } if ( maxBytes < MAX_TCP ) { errlogPrintf ( "cas: EPICS_CA_MAX_ARRAY_BYTES was rounded up to %u\n", MAX_TCP ); this->largeBufferSizePriv = MAX_TCP; } else { this->largeBufferSizePriv = maxBytes; } } freeListInitPvt ( & this->smallBufFreeList, MAX_MSG_SIZE, 8 ); freeListInitPvt ( & this->largeBufFreeList, this->largeBufferSizePriv, 1 ); }
/* * envGetInetPortConfigParam () */ epicsShareFunc unsigned short epicsShareAPI envGetInetPortConfigParam (const ENV_PARAM *pEnv, unsigned short defaultPort) { long longStatus; long epicsParam; longStatus = envGetLongConfigParam (pEnv, &epicsParam); if (longStatus!=0) { epicsParam = (long) defaultPort; errlogPrintf ("EPICS Environment \"%s\" integer fetch failed\n", pEnv->name); errlogPrintf ("setting \"%s\" = %ld\n", pEnv->name, epicsParam); } if (epicsParam<=IPPORT_USERRESERVED || epicsParam>USHRT_MAX) { errlogPrintf ("EPICS Environment \"%s\" out of range\n", pEnv->name); /* * Quit if the port is wrong due coding error */ assert (epicsParam != (long) defaultPort); epicsParam = (long) defaultPort; errlogPrintf ("Setting \"%s\" = %ld\n", pEnv->name, epicsParam); } /* * ok to clip to unsigned short here because we checked the range */ return (unsigned short) epicsParam; }
/*returns: (-1,0)=>(failure,success)*/ static long init_wf_loadedSeq(waveformRecord* pwf) { long ret = 0; if(pwf->inp.type != VME_IO) { errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pwf->name); return S_db_badField; } try { std::string parm(pwf->inp.value.vmeio.parm); evgMrm* evg = dynamic_cast<evgMrm*>(mrf::Object::getObject(parm)); if(!evg) throw std::runtime_error("Failed to lookup EVG"); evgSeqRamMgr* seqRamMgr = evg->getSeqRamMgr(); if(!seqRamMgr) throw std::runtime_error("Failed to lookup EVG Seq Ram Manager"); pwf->dpvt = seqRamMgr; ret = 0; } catch(std::runtime_error& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_db_noMemory; } return ret; }
static void addAction(caLink *pca, short link_action) { int callAdd; epicsMutexMustLock(workListLock); callAdd = (pca->link_action == 0); if (pca->link_action & CA_CLEAR_CHANNEL) { errlogPrintf("dbCa::addAction %d with CA_CLEAR_CHANNEL set\n", link_action); printLinks(pca); link_action = 0; } if (link_action & CA_CLEAR_CHANNEL) { if (++removesOutstanding >= removesOutstandingWarning) { errlogPrintf("dbCa::addAction pausing, %d channels to clear\n", removesOutstanding); printLinks(pca); } while (removesOutstanding >= removesOutstandingWarning) { epicsMutexUnlock(workListLock); epicsThreadSleep(1.0); epicsMutexMustLock(workListLock); } } pca->link_action |= link_action; if (callAdd) ellAdd(&workList, &pca->node); epicsMutexUnlock(workListLock); if (callAdd) epicsEventSignal(workListEvent); }
// Extract slot details from the xml void converter::loadSlotDetails(TiXmlHandle &hRoot) { //printf("Slot details\n"); for( TiXmlElement* pElem=hRoot.FirstChild("slot").Element(); pElem; pElem=pElem->NextSiblingElement()) { std::string slotName = pElem->Attribute("name"); std::map<std::string, slotData>::iterator iter = m_slots.find(slotName); if ( iter==m_slots.end() ) { errlogPrintf("sampleChanger: Unknown slot '%s' in slot details\n", slotName.c_str()); } else { iter->second.rackType = pElem->Attribute("rack_type"); if ( pElem->QueryDoubleAttribute("xoff", &(iter->second.xoff))!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot xoff attribute \"%s\"\n", slotName.c_str()); } if ( m_dims>1 && pElem->QueryDoubleAttribute("yoff", &(iter->second.yoff))!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot yoff attribute \"%s\"\n", slotName.c_str()); } //printf("Det slot %s %s %f\n", iter->second.name, iter->second.rackType, iter->second.xoff); } } }
static long read_bi(biRecord *pbi) { F3RP61_SEQ_DPVT *dpvt = (F3RP61_SEQ_DPVT *) pbi->dpvt; MCMD_STRUCT *pmcmdStruct = &dpvt->mcmdStruct; MCMD_RESPONSE *pmcmdResponse; if (pbi->pact) { pmcmdResponse = &pmcmdStruct->mcmdResponse; if (dpvt->ret < 0) { errlogPrintf("devBiF3RP61Seq: read_bi failed for %s\n", pbi->name); return (-1); } if (pmcmdResponse->errorCode) { errlogPrintf("devBiF3RP61Seq: errorCode %d returned for %s\n", pmcmdResponse->errorCode, pbi->name); return (-1); } pbi->rval = (unsigned long) pmcmdResponse->dataBuff.wData[0]; pbi->udf=FALSE; } else { if (f3rp61Seq_queueRequest(dpvt) < 0) { errlogPrintf("devBiF3RP61Seq: f3rp61Seq_queueRequest failed for %s\n", pbi->name); return (-1); } pbi->pact = 1; } return(0); }
static long init_record_mbbo( mbboRecord *pior) { struct instio *pinstio; PARPROP *pp = NULL; void *pval; if( pior->out.type != INST_IO) { errlogPrintf( "%s: mbbo INP field type should be INST_IO\n", pior->name); return( S_db_badField); } /* parse device dependent option string and set data pointer */ pinstio = &(pior->out.value.instio); if( ( pp = CAENx527ParseDevArgs( pinstio->string)) == NULL) { errlogPrintf( "%s: Invalid device parameters: \"%s\"\n", pior->name, pinstio->string); return(2); } pior->dpvt = pp; strcpy( pp->PVname, pior->name); /* Initialize the value from value in the crate */ pval = CAENx527GetChParVal( pp); if( pval == NULL) return( 3); pior->val = CAENx527mbbi2state( pp); pior->rval = CAENx527mbbi2state( pp); pp->hvchan->epicsenabled = 1; return( 0); }
static long init_record_mbbi( mbbiRecord *pior) { struct instio *pinstio; PARPROP *pp = NULL; if( pior->inp.type != INST_IO) { errlogPrintf( "%s: mbbi INP field type should be INST_IO\n", pior->name); return( S_db_badField); } /* parse device dependent option string and set data pointer */ pinstio = &(pior->inp.value.instio); if( ( pp = CAENx527ParseDevArgs( pinstio->string)) == NULL) { errlogPrintf( "%s: Invalid device parameters: \"%s\"\n", pior->name, pinstio->string); return(2); } if( pp->evntno > 0) /* pior->evnt = pp->evntno;*/ sprintf(pior->evnt,"%d",pp->evntno); pior->dpvt = pp; strcpy( pp->PVname, pior->name); pp->hvchan->epicsenabled = 1; return( 0); }
// Extract the definitions of the rack types from the xml void converter::loadRackDefs(TiXmlHandle &hRoot) { m_racks.clear(); //printf("Loading rack defs\n"); for( TiXmlElement* pElem=hRoot.FirstChild("racks").FirstChild("rack").Element(); pElem; pElem=pElem->NextSiblingElement()) { //printf("Loading rack defs - racks\n"); std::map<std::string, samplePosn> posns; std::string rackName = pElem->Attribute("name"); for ( TiXmlElement *pRack = pElem->FirstChildElement("position") ; pRack ; pRack=pRack->NextSiblingElement() ) { samplePosn posn; const char *attrib = pRack->Attribute("name"); if ( attrib!=NULL ) { posn.name = attrib; } else { errlogPrintf("sampleChanger: rack has no name attribute \"%s\"\n", rackName.c_str()); } //printf("Loading rack defs - %s\n", posn.name.c_str()); if ( pRack->QueryDoubleAttribute("x", &posn.x)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read x attribute \"%s\" \"%s\"\n", rackName.c_str(), posn.name.c_str()); } if ( m_dims>1 && pRack->QueryDoubleAttribute("y", &posn.y)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read y attribute \"%s\" \"%s\"\n", rackName.c_str(), posn.name.c_str()); } posns[posn.name] = posn; } m_racks[rackName] = posns; } }
/* * Create and start a new thread */ epicsThreadId epicsThreadCreate (const char *name, unsigned int priority, unsigned int stackSize, EPICSTHREADFUNC funptr,void *parm) { rtems_id tid; rtems_status_code sc; char c[4]; if (!initialized) epicsThreadInit(); if (stackSize < RTEMS_MINIMUM_STACK_SIZE) { errlogPrintf ("Warning: epicsThreadCreate %s illegal stackSize %d\n",name,stackSize); stackSize = RTEMS_MINIMUM_STACK_SIZE; } strncpy (c, name, sizeof c); sc = rtems_task_create (rtems_build_name (c[0], c[1], c[2], c[3]), epicsThreadGetOssPriorityValue (priority), stackSize, RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0), RTEMS_FLOATING_POINT|RTEMS_LOCAL, &tid); if (sc != RTEMS_SUCCESSFUL) { errlogPrintf ("epicsThreadCreate create failure for %s: %s\n",name, rtems_status_text (sc)); return 0; } setThreadInfo (tid, name, funptr,parm); return (epicsThreadId)tid; }
void PvaPyLogger::log(const char* messageLevel, const char* message, va_list messageArgs) const { char timeStamp[MaxTimeStampLength]; prepareTimeStamp(timeStamp, MaxTimeStampLength, TimeStampFormat); if (useEpicsLog) { errlogPrintf("%s %s %s: ", timeStamp, messageLevel, name); errlogVprintf(message, messageArgs); errlogPrintf("\n"); } else { // On vxWorks fflush() fails frequently, so only use // fprintf() if logging goes into a file. if (usePrintf) { printf("%s %s %s: ", timeStamp, messageLevel, name); vprintf(message, messageArgs); printf("\n"); } else { fprintf(logFile, "%s %s %s: ", timeStamp, messageLevel, name); vfprintf(logFile, message, messageArgs); fprintf(logFile, "\n"); fflush(logFile); } } }
/*returns: (-1,0)=>(failure,success)*/ static long write_bo_pauseSeq(boRecord* pbo) { long ret = 0; evgSoftSeq* seq = 0; try { if(!pbo->val) return 0; seq = (evgSoftSeq*)pbo->dpvt; if(!seq) return S_dev_noDevice; SCOPED_LOCK2(seq->m_lock, guard); seq->pause(); seq->setErr(""); } catch(std::runtime_error& e) { seq->setErr(e.what()); errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name); ret = S_db_noMemory; } return ret; }
/*returns: (-1,0)=>(failure,success)*/ static long write_bo_softTrig(boRecord* pbo) { long ret = 0; try { if(!pbo->val) return 0; evgSoftSeq* seq = (evgSoftSeq*)pbo->dpvt; if(!seq) throw std::runtime_error("Device pvt field not initialized"); SCOPED_LOCK2(seq->m_lock, guard); evgSeqRam* seqRam = seq->getSeqRam(); if(!seqRam) throw std::runtime_error("Failed to lookup EVG Seq RAM"); seqRam->softTrig(); } catch(std::runtime_error& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name); ret = S_db_noMemory; } return ret; }
/*returns: (-1,0)=>(failure,success)*/ static long read_wf_eventMask(waveformRecord* pwf) { long ret = 0; try { evgSoftSeq* seq = (evgSoftSeq*)pwf->dpvt; if(!seq) throw std::runtime_error("Device pvt field not initialized"); SCOPED_LOCK2(seq->m_lock, guard); std::vector<epicsUInt8> eventMask = seq->getEventMaskCt(); epicsUInt8* bptr = (epicsUInt8*)pwf->bptr; for(unsigned int i = 0; i < eventMask.size(); i++) bptr[i] = eventMask[i]; pwf->nord = (epicsUInt32)eventMask.size(); } catch(std::runtime_error& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_db_noMemory; } return ret; }
static long init_record(dbCommon *pRec, DBLINK* lnk) { long ret = 0; if(lnk->type != VME_IO) { errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pRec->name); return S_db_badField; } try { std::string parm(lnk->value.vmeio.parm); evgMrm* evg = dynamic_cast<evgMrm*>(mrf::Object::getObject(parm)); if(!evg) throw std::runtime_error("Failed to lookup EVG"); evgSoftSeqMgr* seqMgr = evg->getSoftSeqMgr(); if(!seqMgr) throw std::runtime_error("Failed to lookup EVG Seq Manager"); evgSoftSeq* seq = seqMgr->getSoftSeq(lnk->value.vmeio.signal); if(!seq) throw std::runtime_error("Failed to lookup EVG Sequence"); pRec->dpvt = seq; ret = 0; } catch(std::runtime_error& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pRec->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pRec->name); ret = S_db_noMemory; } return ret; }
void epicsAssert (const char *pFile, const unsigned line, const char *pExp, const char *pAuthorName) { epicsTimeStamp current; errlogPrintf("\n\n\n" "A call to 'assert(%s)'\n" " by thread '%s' failed in %s line %u.\n", pExp, epicsThreadGetNameSelf(), pFile, line); errlogPrintf("EPICS Release %s.\n", epicsReleaseVersion); if (epicsTimeGetCurrent(¤t) == 0) { char date[64]; epicsTimeToStrftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S.%f %Z", ¤t); errlogPrintf("Local time is %s\n", date); } if (!pAuthorName) { pAuthorName = "the author"; } errlogPrintf("Please E-mail this message to %s or to [email protected]\n", pAuthorName); errlogPrintf("Calling epicsThreadSuspendSelf()\n"); epicsThreadSuspendSelf (); }
/*returns: (-1,0)=>(failure,success)*/ static long read_wf_loadedSeq(waveformRecord* pwf) { long ret = 0; try { evgSeqRamMgr* seqRamMgr = (evgSeqRamMgr*)pwf->dpvt; if(!seqRamMgr) { errlogPrintf("Device pvt field not initialized\n"); return -1; } epicsInt32* pBuf = (epicsInt32*)pwf->bptr; evgSoftSeq* seq; for(int i = 0; i < evgNumSeqRam; i++) { seq = seqRamMgr->getSeqRam(i)->getSoftSeq(); if(seq) pBuf[i] = seq->getId(); else pBuf[i] = -1; } pwf->nord = evgNumSeqRam; ret = 0; } catch(std::runtime_error& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_dev_noDevice; } catch(std::exception& e) { errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name); ret = S_db_noMemory; } return ret; }
static int iocBuild_1(void) { if (iocState != iocVirgin && iocState != iocStopped) { errlogPrintf("iocBuild: IOC can only be initialized from uninitialized or stopped state\n"); return -1; } errlogInit(0); initHookAnnounce(initHookAtIocBuild); if (!epicsThreadIsOkToBlock()) { epicsThreadSetOkToBlock(1); } errlogPrintf("Starting iocInit\n"); if (checkDatabase(pdbbase)) { errlogPrintf("iocBuild: Aborting, bad database definition (DBD)!\n"); return -1; } epicsSignalInstallSigHupIgnore(); initHookAnnounce(initHookAtBeginning); coreRelease(); iocState = iocBuilding; taskwdInit(); callbackInit(); initHookAnnounce(initHookAfterCallbackInit); return 0; }
int iocRun(void) { if (iocState != iocPaused && iocState != iocBuilt) { errlogPrintf("iocRun: IOC not paused\n"); return -1; } initHookAnnounce(initHookAtIocRun); /* Enable scan tasks and some driver support functions. */ scanRun(); dbCaRun(); initHookAnnounce(initHookAfterDatabaseRunning); if (iocState == iocBuilt) initHookAnnounce(initHookAfterInterruptAccept); rsrv_run(); initHookAnnounce(initHookAfterCaServerRunning); if (iocState == iocBuilt) initHookAnnounce(initHookAtEnd); errlogPrintf("iocRun: %s\n", iocState == iocBuilt ? "All initialization complete" : "IOC restarted"); iocState = iocRunning; initHookAnnounce(initHookAfterIocRunning); return 0; }
void omsMAXvEncFunc::initialize() { const char* functionName = "initialize"; Debug(5, "omsMAXvEncFunc::initialize: start initialize\n" ); int encIndex = numAxes; if (encIndex > MAXENCFUNC) encIndex = MAXENCFUNC; /* auxiliary encoders */ for (int i=0; i < encIndex; ++i){ if (createParam(i, motorEncoderFunctionString, asynParamInt32, &encFuncIndex[i]) != asynSuccess) errlogPrintf("%s:%s:%s: unable to create param motorEncoderFunctionString, index %d\n", driverName, functionName, portName, i); if (createParam(i, motorEncoderRawPosString, asynParamFloat64, &encRawPosIndex[i]) != asynSuccess) errlogPrintf("%s:%s:%s: unable to create param motorEncoderRawPosString, index %d\n", driverName, functionName, portName, i); } createParam(0, motorAuxEncoderPositionString, asynParamFloat64, &encPosIndex[0]); createParam(1, motorAuxEncoderPositionString, asynParamFloat64, &encPosIndex[1]); Debug(3, "omsMAXvEncFunc::initialize: auxiliary encoder 0 position index %d\n", encPosIndex[0] ); Debug(3, "omsMAXvEncFunc::initialize: auxiliary encoder 1 position index %d\n", encPosIndex[1] ); for (int i=0; i < encIndex; ++i) Debug(3, "omsMAXvEncFunc::initialize: encFuncIndex %d => %d\n", i, encFuncIndex[i] ); lock(); for (int i=0; i < encIndex; ++i){ setIntegerParam(i, encFuncIndex[i], 0); setDoubleParam(i, encRawPosIndex[i], 0.0); } setDoubleParam(0, encPosIndex[0], 0.0); setDoubleParam(1, encPosIndex[1], 0.0); for (int i=0; i < encIndex; ++i) { callParamCallbacks(i, i); } unlock(); }
void omsMAXv::motorIsrSetup(volatile unsigned int vector, volatile epicsUInt8 level) { const char* functionName = "motorIsrSetup"; STATUS1 status1_irq; long status; Debug(64, "omsMAXv::isrSetup: start\n"); status = pdevLibVirtualOS->pDevConnectInterruptVME( vector, &omsMAXv::InterruptHandler, this); if (status) { errlogPrintf("%s:%s:%s: Can't connect to interrupt vector %d\n", driverName, functionName, portName, vector); return; } Debug(64, "omsMAXv::isrSetup: set level\n"); status = devEnableInterruptLevel(intVME, level); if (status) { errlogPrintf("%s:%s:%s: Can't enable interrupt level %d\n", driverName, functionName, portName, level); return; } /* Setup card for interrupt-on-done */ status1_irq.All = 0; status1_irq.Bits.done = 0xFF; status1_irq.Bits.cmndError = 1; pmotor->status1_irq_enable.All = status1_irq.All; /* Enable interrupts. */ pmotor->status2_irq_enable = 0x0; Debug(64, "omsMAXv::isrSetup: done\n"); return; }
/* Function init_record initializes record - parses INP/OUT field string, * allocates private data storage area and sets initial configure values */ static long init_record(boRecord *pbo) { struct link *plink = &pbo->out; int size; char *buf; F3RP61SysCtl_BO_DPVT *dpvt; char device; char led; if (pbo->out.type != INST_IO) { recGblRecordError(S_db_badField,(void *)pbo, "devBoF3RP61SysCtl (init_record) Illegal OUT field"); pbo->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; /* Parse 'device' and possibly 'led'*/ if (sscanf(buf, "SYS,%c%c,", &device, &led) < 2) { if (sscanf(buf, "SYS,%c", &device) < 1) { errlogPrintf("devBoF3RP61SysCtl: can't get device for %s\n", pbo->name); pbo->pact = 1; return (-1); } } /* Check device validity*/ if (!(device == 'L')) { errlogPrintf("devBoF3RP61SysCtl: illegal device for %s\n", pbo->name); pbo->pact = 1; return (-1); } /* Check 'led' validity*/ if(device == 'L') { if (!(led == 'R' || led == 'A' || led == 'E')) { errlogPrintf("devBoF3RP61SysCtl: illegal LED address for %s\n", pbo->name); pbo->pact = 1; return (-1); } } dpvt = (F3RP61SysCtl_BO_DPVT *) callocMustSucceed(1, sizeof(F3RP61SysCtl_BO_DPVT), "calloc failed"); dpvt->device = device; if (device == 'L') { dpvt->led = led; } pbo->dpvt = dpvt; return(0); }
/* init routine */ int drvFzoomAsynConfigure(const char *portName, const char *octetPortName) { FZOOM_ID pfzoomPvt; asynStatus status; assert(sizeof(unsigned short) == 2); /* 32 bits required */ pfzoomPvt = callocMustSucceed(1, sizeof(*pfzoomPvt), "drvFzoomAsynConfigure"); pfzoomPvt->portName = epicsStrDup(portName); pfzoomPvt->octetPortName = epicsStrDup(octetPortName); pfzoomPvt->mutexId = epicsMutexMustCreate(); /* initialise position, error threshold */ pfzoomPvt->devInfo.zoomPosition = 1; pfzoomPvt->devInfo.posThreshold = 1010; pfzoomPvt->devInfo.timeoutDelay = 1025; /* connect to asyn octet port with asynOctetSyncIO */ status = pasynOctetSyncIO->connect(octetPortName, 0, &pfzoomPvt->pasynUserOctet, 0); if (status != asynSuccess) { errlogPrintf("%s::drvFzoomAsynConfigure port %s" " can't connect to Octet port %s.\n", driver, portName, octetPortName); return asynError; } /* Create asynUser for asynTrace */ pfzoomPvt->pasynUserTrace = pasynManager->createAsynUser(0, 0); pfzoomPvt->pasynUserTrace->userPvt = pfzoomPvt; status = pasynManager->registerPort(pfzoomPvt->portName, ASYN_CANBLOCK, 1, /* autoconnect */ 0, /* medium priority */ 0); /* default stack size */ if (status != asynSuccess) { errlogPrintf("%s::drvFzoomAsynConfigure port %s" "%s:: can't register port\n", driver, pfzoomPvt->portName, pfzoomPvt->octetPortName); return(asynError); } /* Create asyn interfaces and register with asynManager */ pfzoomPvt->asynStdInterfaces.common.pinterface = (void *)&drvCommon; pfzoomPvt->asynStdInterfaces.drvUser.pinterface = (void *)&drvUser; pfzoomPvt->asynStdInterfaces.int32.pinterface = (void *)&drvInt32; status = pasynStandardInterfacesBase->initialize(pfzoomPvt->portName, &pfzoomPvt->asynStdInterfaces, pfzoomPvt->pasynUserTrace, pfzoomPvt); if (status != asynSuccess) { errlogPrintf("%s::drvFzoomAsynConfigure port %s" " can't register standard interfaces: %s\n", driver, pfzoomPvt->portName, pfzoomPvt->pasynUserTrace->errorMessage); return(asynError); } return (asynSuccess); }