/* * ASYN UInt32Digital driver for MPS Unlatch Control */ #include #include #include #include #include #include #include #include #include "MachineStateBuffer.h" /* * Driver private storage */ typedef struct dpvtStruct { asynInterface asynCommon; asynInterface asynUInt32Digital; } dpvt; #if 0 #pragma mark - #pragma mark asynCommon methods #endif /* * asynCommon methods */ static void mpsUnlatchReport(void *pvt, FILE *fp, int details) { if (details >= 3) { fprintf(fp, "report\n"); } } static asynStatus mpsUnlatchConnect(void *pvt, asynUser *pasynUser) { pasynManager->exceptionConnect(pasynUser); return asynSuccess; } static asynStatus mpsUnlatchDisconnect(void *pvt, asynUser *pasynUser) { pasynManager->exceptionDisconnect(pasynUser); return asynSuccess; } static asynCommon asynCommonMethods = { mpsUnlatchReport, mpsUnlatchConnect, mpsUnlatchDisconnect }; #if 0 #pragma mark - #pragma mark asynUInt32Digital methods #endif static asynStatus noRead(void *pvt, asynUser *pasynUser, unsigned int *value, unsigned int mask) { epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "This record is write only."); return asynError; } static asynStatus writeMpsUnlatchState(void *pvt, asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask) { asynStatus status; unsigned int index; int writeStatus; /* Get index */ if ((status = pasynManager->getAddr(pasynUser, (int *) &index)) != asynSuccess) { return status; } /* Unlatch fault */ writeStatus = unlatchFault(index); if (writeStatus != MPS_SUCCESS) { epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "Invalid uint32Digital write address %u, error %d", index, writeStatus); return asynError; } return asynSuccess; } static asynUInt32Digital asynUInt32DigitalMethodsUnlatchControl = { writeMpsUnlatchState, noRead }; #if 0 #pragma mark - #pragma mark Configure Port Instances #endif /* * Configure and register the port instances */ void devMpsUnlatchControlRegistrar() { int attributes; dpvt *pdpvt; asynStatus status; const char *portName = "devMpsUnlatchBufferControl"; /* * Register with ASYN * * registerPort(portName, attributes, autoConnect, priority (for worker thread), stack size (for worker thread)) * Note: I/O actions do not block read thread. Therefore, no worker thread is created. Priority and stack size should be zero. */ attributes = 0; attributes |= ASYN_MULTIDEVICE; status = pasynManager->registerPort(portName, attributes, 1, 0, 0); if(status!=asynSuccess) { printf("devMpsUnlatchControlRegistrar: registerPort failed\n"); return; } pdpvt = callocMustSucceed(sizeof(dpvt), 1, portName); pdpvt->asynCommon.interfaceType = asynCommonType; pdpvt->asynCommon.pinterface = (void *)&asynCommonMethods; pdpvt->asynCommon.drvPvt = pdpvt; status = pasynManager->registerInterface(portName, &pdpvt->asynCommon); if (status!=asynSuccess) { printf("devMpsUnlatchControlRegistrar: registerInterface failed\n"); return; } pdpvt->asynUInt32Digital.interfaceType = asynUInt32DigitalType; pdpvt->asynUInt32Digital.pinterface = (void *) &asynUInt32DigitalMethodsUnlatchControl; pdpvt->asynUInt32Digital.drvPvt = pdpvt; status = pasynUInt32DigitalBase->initialize(portName, &pdpvt->asynUInt32Digital); if (status!=asynSuccess) { printf("devMpsUnlatchControlRegistrar: registerInterface failed\n"); return; } printf("devMpsUnlatchControlRegistrar finished\n"); } epicsExportRegistrar(devMpsUnlatchControlRegistrar);