• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ epicsSnprintf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中epicsSnprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ epicsSnprintf函数的具体用法?C++ epicsSnprintf怎么用?C++ epicsSnprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了epicsSnprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getParamName

asynStatus isisdaeDriver::readArray(asynUser *pasynUser, const char* functionName, T *value, size_t nElements, size_t *nIn)
{
  int function = pasynUser->reason;
  asynStatus status = asynSuccess;
  const char *paramName = NULL;
	getParamName(function, &paramName);
	m_iface->resetMessages();
	try
	{
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, name=%s\n", 
              driverName, functionName, function, paramName);
		reportMessages();
		return status;
	}
	catch(const std::exception& ex)
	{
		*nIn = 0;
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d, name=%s, error=%s", 
                  driverName, functionName, status, function, paramName, ex.what());
		reportErrors(ex.what());
		return asynError;
	}
}
开发者ID:ISISComputingGroup,项目名称:EPICS-isisdae,代码行数:25,代码来源:isisdaeDriver.cpp


示例2: getIntegerParam

/** Called when asyn clients call pasynFloat64->write().
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Value to write. */
asynStatus testErrors::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
{
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    int itemp;
    const char *paramName;
    const char* functionName = "writeFloat64";

    /* Get the current error status */
    getIntegerParam(P_StatusReturn, &itemp);  status = (asynStatus)itemp;

    /* Fetch the parameter string name for use in debugging */
    getParamName(function, &paramName);

    /* Set the parameter in the parameter library. */
    setDoubleParam(function, value);
    /* Set the parameter status in the parameter library. */
    setParamStatus(function, status);

    /* Do callbacks so higher layers see any changes */
    callParamCallbacks();
    
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d, name=%s, value=%f", 
                  driverName, functionName, status, function, paramName, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, name=%s, value=%f\n", 
              driverName, functionName, function, paramName, value);
    return status;
}
开发者ID:ffeldbauer,项目名称:asyn,代码行数:35,代码来源:testErrors.cpp


示例3: gpibPortAddressedCmd

static asynStatus gpibPortAddressedCmd(void *pdrvPvt,asynUser *pasynUser,
    const char *data, int length)
{
    niport *pniport = (niport *)pdrvPvt;
    double     timeout = pasynUser->timeout;
    int        addr = 0;
    int        actual;
    asynStatus status;
    char cmdbuf[2] = {IBUNT,IBUNL};

    status = pasynManager->getAddr(pasynUser,&addr);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser,ASYN_TRACE_FLOW,
       "%s addr %d gpibPortAddressedCmd nchar %d\n",
        pniport->portName,addr,length);
    pniport->errorMessage[0] = 0;
    status = writeAddr(pniport,0,addr,timeout,transferStateIdle);
    if(status==asynSuccess) {
        status=writeCmd(pniport,data,length,timeout,transferStateIdle);
    }
    if(status!=asynSuccess) {
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
            "%s writeGpib failed %s",pniport->portName,pniport->errorMessage);
    }
    actual = length - pniport->bytesRemainingCmd;
    asynPrintIO(pasynUser,ASYN_TRACEIO_DRIVER,
        data,actual,"%s gpibPortAddressedCmd\n",pniport->portName);
    if(status!=asynSuccess) return status;
    writeCmd(pniport,cmdbuf,2,timeout,transferStateIdle);
    return status;
}
开发者ID:A2-Collaboration,项目名称:epics,代码行数:31,代码来源:drvNi1014.c


示例4: getIntegerParam

asynStatus mar345::erase()
{
    int numErase;
    int i;
    asynStatus status=asynSuccess;
    //const char *functionName = "erase";

    getIntegerParam(mar345NumErase, &numErase);
    if (numErase < 1) numErase=1;
    setIntegerParam(ADStatus, mar345StatusErase);
    setIntegerParam(mar345NumErased, 0);
    callParamCallbacks();
    for (i=0; i<numErase; i++) {
        if (epicsEventTryWait(this->abortEventId) == epicsEventWaitOK) {
            status = asynError;
            break;
        }
        epicsSnprintf(this->toServer, sizeof(this->toServer), "COMMAND ERASE");
        writeServer(this->toServer);
        status = waitForCompletion("SCAN_DATA    Ended o.k.", MAR345_COMMAND_TIMEOUT);
        if (status) break;
        setIntegerParam(mar345NumErased, i+1);
        callParamCallbacks();
    }
    setIntegerParam(ADStatus, mar345StatusIdle);
    setIntegerParam(mar345Erase, 0);
    callParamCallbacks();
    return(status);
}
开发者ID:NSLS-II-CSX,项目名称:xf23id1-ioc1,代码行数:29,代码来源:mar345.cpp


示例5: dbLoadRecordsLoop

/// Load a db file multiple times substituting a specified macro according to a number range.
///
/// The \a dbFile and \a macros arguments are like the normal dbLoadRecords() however
/// it is possible to embed a macro within these whose value follows the range \a start to \a stop.
/// You can either load the same \a dbFile multiple times with different macros, or even load
/// different database files by using \a loopVar as part of the filename. If you want to use a list
/// of (non-numeric) substitutions rather than an integer range see dbLoadRecordsList()
///
/// The name of the macro to be used for substitution is contained in \a loopVar and needs to be
/// reference in an \\ escaped way to make sure EPICS does not try to substitute it too soon.
/// as well as the \a macros the \a dbFile is also passed the \a loopVar macro value
/// @code
///     dbLoadRecordsLoop("file\$(I).db", "P=1,Q=Hello\$(I)", "I", 1, 4)
/// @endcode 
///
/// @param[in] dbFile @copydoc dbLoadRecordsLoopInitArg0
/// @param[in] macros @copydoc dbLoadRecordsLoopInitArg1
/// @param[in] loopVar @copydoc dbLoadRecordsLoopInitArg2
/// @param[in] start @copydoc dbLoadRecordsLoopInitArg3
/// @param[in] stop @copydoc dbLoadRecordsLoopInitArg4
/// @param[in] step @copydoc dbLoadRecordsLoopInitArg5
epicsShareFunc void dbLoadRecordsLoop(const char* dbFile, const char* macros, const char* loopVar, int start, int stop, int step)
{
    char loopVal[32];
    if (loopVar == NULL)
    {
        dbLoadRecords(dbFile, macros);
        return;
    }
    if (step <= 0)
    {
        step = 1;
    }
    std::string macros_s, dbFile_s;
    subMacros(macros_s, macros, loopVar);
    subMacros(dbFile_s, dbFile, loopVar);
    MAC_HANDLE* mh = NULL;
	char macros_exp[1024], dbFile_exp[1024];
    macCreateHandle(&mh, NULL);
	loadMacEnviron(mh);
    for(int i = start; i <= stop; i += step)
    {
		macPushScope(mh);
        epicsSnprintf(loopVal, sizeof(loopVal), "%d", i);
        macPutValue(mh, loopVar, loopVal);   
        macExpandString(mh, macros_s.c_str(), macros_exp, sizeof(macros_exp));
        macExpandString(mh, dbFile_s.c_str(), dbFile_exp, sizeof(dbFile_exp));
        std::ostringstream new_macros;
        new_macros << macros_exp << (strlen(macros_exp) > 0 ? "," : "") << loopVar << "=" << i;
        std::cout << "--> (" << i << ") dbLoadRecords(\"" << dbFile_exp << "\",\"" << new_macros.str() << "\")" << std::endl;
        dbLoadRecords(dbFile_exp, new_macros.str().c_str());
		macPopScope(mh);
    }
	macDeleteHandle(mh);		
}
开发者ID:ISISComputingGroup,项目名称:EPICS-utilities,代码行数:55,代码来源:dbLoadRecordsFuncs.cpp


示例6: getStringParam

/** Build a file name from component parts.
  * \param[in] maxChars  The size of the fullFileName string.
  * \param[out] fullFileName The constructed file name including the file path.
  * 
  * This is a convenience function that constructs a complete file name
  * from the NDFilePath, NDFileName, NDFileNumber, and
  * NDFileTemplate parameters. If NDAutoIncrement is true then it increments the
  * NDFileNumber after creating the file name.
  */
int asynNDArrayDriver::createFileName(int maxChars, char *fullFileName)
{
    /* Formats a complete file name from the components defined in NDStdDriverParams */
    int status = asynSuccess;
    char filePath[MAX_FILENAME_LEN];
    char fileName[MAX_FILENAME_LEN];
    char fileTemplate[MAX_FILENAME_LEN];
    int fileNumber;
    int autoIncrement;
    int len;
    
    this->checkPath();
    status |= getStringParam(NDFilePath, sizeof(filePath), filePath);
    status |= getStringParam(NDFileName, sizeof(fileName), fileName); 
    status |= getStringParam(NDFileTemplate, sizeof(fileTemplate), fileTemplate); 
    status |= getIntegerParam(NDFileNumber, &fileNumber);
    status |= getIntegerParam(NDAutoIncrement, &autoIncrement);
    if (status) return(status);
    len = epicsSnprintf(fullFileName, maxChars, fileTemplate, 
                        filePath, fileName, fileNumber);
    if (len < 0) {
        status |= asynError;
        return(status);
    }
    if (autoIncrement) {
        fileNumber++;
        status |= setIntegerParam(NDFileNumber, fileNumber);
    }
    return(status);   
}
开发者ID:NSLS-II-CSX,项目名称:xf23id1-ioc1,代码行数:39,代码来源:asynNDArrayDriver.cpp


示例7: getParamName

/// Read Values as Octet
asynStatus ReadASCII::readOctet(asynUser *pasynUser, char *value, size_t maxChars, size_t *nActual, int *eomReason)
{
	//Checks if directory has changed, reads file again if it has
	int function = pasynUser->reason;
	asynStatus status = asynSuccess;
	const char *paramName;
	const char* functionName = "readOctet";

	/* Fetch the parameter string name for possible use in debugging */
	getParamName(function, &paramName);

	if (function == P_DirBase) {
		char dirBase[DIR_LENGTH];
		getStringParam(P_DirBase, DIR_LENGTH, dirBase);

		strncpy(value, dirBase, maxChars);
		*nActual = strlen(dirBase);
		std::cerr << status << "new dir base " << dirBase << std::endl;
	} else {
		status = asynError;
		epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
				"%s:%s: status=%d, function=%d, name=%s function does not have read.",
				driverName, functionName, status, function, paramName);
	}

	return status;

}
开发者ID:ISISComputingGroup,项目名称:EPICS-ReadASCII,代码行数:29,代码来源:ReadASCII.cpp


示例8: getIntegerParam

asynStatus testErrors::doReadArray(asynUser *pasynUser, epicsType *value, 
                                   size_t nElements, size_t *nIn, int paramIndex, epicsType *pValue)
{
    int function = pasynUser->reason;
    size_t ncopy = MAX_ARRAY_POINTS;
    asynStatus status = asynSuccess;
    const char *functionName = "doReadArray";

    /* Get the current error status */
    getIntegerParam(P_StatusReturn, (int*)&status);

    if (nElements < ncopy) ncopy = nElements;
    if (function == paramIndex) {
        memcpy(value, pValue, ncopy*sizeof(epicsType));
        *nIn = ncopy;
    }

    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d", 
                  driverName, functionName, status, function);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d\n", 
              driverName, functionName, function);
    return status;
}
开发者ID:BCDA-APS,项目名称:epicsEdgeRoboArm,代码行数:27,代码来源:testErrors.cpp


示例9: getAddress

/** Called when asyn clients call pasynOctet->write().
  * This function performs actions for some parameters, including NDAttributesFile.
  * For all parameters it sets the value in the parameter library and calls any registered callbacks..
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Address of the string to write.
  * \param[in] nChars Number of characters to write.
  * \param[out] nActual Number of characters actually written. */
asynStatus asynNDArrayDriver::writeOctet(asynUser *pasynUser, const char *value, 
                                    size_t nChars, size_t *nActual)
{
    int addr=0;
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *functionName = "writeOctet";

    status = getAddress(pasynUser, &addr); if (status != asynSuccess) return(status);
    /* Set the parameter in the parameter library. */
    status = (asynStatus)setStringParam(addr, function, (char *)value);

    if (function == NDAttributesFile) {
        this->readNDAttributesFile(value);
    } else if (function == NDFilePath) {
        this->checkPath();
    }
     /* Do callbacks so higher layers see any changes */
    status = (asynStatus)callParamCallbacks(addr, addr);

    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d, value=%s", 
                  driverName, functionName, status, function, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, value=%s\n", 
              driverName, functionName, function, value);
    *nActual = nChars;
    return status;
}
开发者ID:NSLS-II-CSX,项目名称:xf23id1-ioc1,代码行数:38,代码来源:asynNDArrayDriver.cpp


示例10: getIntegerParam

/** Called when asyn clients call pasynFloat64Array->read().
  * Returns the value of the P_Waveform or P_TimeBase arrays.  
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Pointer to the array to read.
  * \param[in] nElements Number of elements to read.
  * \param[out] nIn Number of elements actually read. */
asynStatus testAsynPortDriver::readFloat64Array(asynUser *pasynUser, epicsFloat64 *value, 
                                         size_t nElements, size_t *nIn)
{
    int function = pasynUser->reason;
    size_t ncopy;
    int itemp;
    asynStatus status = asynSuccess;
    const char *functionName = "readFloat64Array";

    getIntegerParam(P_MaxPoints, &itemp); ncopy = itemp;
    if (nElements < ncopy) ncopy = nElements;
    if (function == P_Waveform) {
        memcpy(value, pData_, ncopy*sizeof(epicsFloat64));
        *nIn = ncopy;
    }
    else if (function == P_TimeBase) {
        memcpy(value, pTimeBase_, ncopy*sizeof(epicsFloat64));
        *nIn = ncopy;
    }
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d", 
                  driverName, functionName, status, function);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d\n", 
              driverName, functionName, function);
    return status;
}
开发者ID:ukaea,项目名称:epics,代码行数:35,代码来源:testAsynPortDriver.cpp


示例11: writeIt

/*
 * asynOctet methods
 */
static asynStatus
writeIt(void *drvPvt, asynUser *pasynUser, const char *data,
        size_t numchars,size_t *nbytesTransfered)
{
    usbController_t *usb = (usbController_t *)drvPvt;
    double          cmdstr[3];
    unsigned char   cmd[3];

    assert(usb);
    asynPrint(pasynUser, ASYN_TRACE_FLOW,
              "%s write.\n", usb->usbDeviceName);
    asynPrintIO(pasynUser, ASYN_TRACEIO_DRIVER, data, numchars,
                "%s write %d\n", usb->usbDeviceName, numchars);
    if (usb->dev == NULL) {
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
                      "%s disconnected:", usb->usbDeviceName);
        return asynError;
    }
    if (sscanf(data, "%lf %lf %lf", &cmdstr[0], &cmdstr[1], &cmdstr[2])!=3) return asynError;
    cmd[0] = cmdstr[0];
    cmd[1] = cmdstr[1];
    cmd[2] = cmdstr[2];
    if (numchars!=3) numchars = 3;
    *nbytesTransfered = 0;
    *nbytesTransfered = libusb_control_transfer(usb->handle, 0x40, 6, 0x100, 0,
                                                cmd, (uint16_t)numchars, 0);
    if (*nbytesTransfered>=numchars)
        return asynSuccess;
    else
        return asynError;
    return asynSuccess;
}
开发者ID:BCDA-APS,项目名称:epicsEdgeRoboArm,代码行数:35,代码来源:drvAsynUSBPort.c


示例12: switch

/**Enables or disables the flipping of the channel numbering. **/
asynStatus mythen::setBitDepth(epicsInt32 value)
{
    asynStatus status;
    epicsInt32 nbits;
    switch (value) {
      case 0: 
        nbits = 24;
        break;
      case 1: 
        nbits = 16;
        break;
      case 2:
        nbits = 8;
        break;
      case 3:
        nbits = 4;
        break;
      default:
        nbits = 24;
        break;
    }

    epicsSnprintf(outString_, sizeof(outString_), "-nbits %d", nbits);
    status = sendCommand();
    return status;
}
开发者ID:jsullivan-anl,项目名称:ADMythen,代码行数:27,代码来源:mythen.cpp


示例13: writeString

static int writeString(gpibDpvt *pgpibDpvt,int P1, int P2, char **P3)
{
    asynUser *pasynUser = pgpibDpvt->pasynUser;
    stringoutRecord *precord = (stringoutRecord*)pgpibDpvt->precord;
    int            nchars;
    gpibCmd *pgpibCmd = gpibCmdGet(pgpibDpvt);
    char *format = (pgpibCmd->format) ? pgpibCmd->format : "%s";

    if(!pgpibDpvt->msg) {
        asynPrint(pasynUser,ASYN_TRACE_ERROR,
            "%s no msg buffer. Must define gpibCmd.msgLen > 0.\n",
            precord->name);
        recGblSetSevr(precord,WRITE_ALARM, INVALID_ALARM);
        return -1;
    }
    nchars = epicsSnprintf(pgpibDpvt->msg,pgpibCmd->msgLen,format,precord->val);
    if(nchars>pgpibCmd->msgLen) { 
        asynPrint(pasynUser,ASYN_TRACE_ERROR, 
            "%s msg buffer too small. msgLen %d message length %d\n", 
            precord->name,pgpibCmd->msgLen,nchars); 
        recGblSetSevr(precord,WRITE_ALARM, INVALID_ALARM); 
        return -1; 
    } 
    asynPrint(pasynUser,ASYN_TRACE_FLOW,"%s writeMsgString\n",precord->name);
    return nchars;
}
开发者ID:A2-Collaboration,项目名称:epics,代码行数:26,代码来源:devGpibConvertExample.c


示例14: setIntegerParam

/** Called when asyn clients call pasynInt32->write().
  * This function sends a signal to the arrayGenTask thread if the value of P_RunStop has changed.
  * For all parameters it sets the value in the parameter library and calls any registered callbacks..
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Value to write. */
asynStatus testArrayRingBuffer::writeInt32(asynUser *pasynUser, epicsInt32 value)
{
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *paramName;
    const char* functionName = "writeInt32";

    /* Set the parameter in the parameter library. */
    status = (asynStatus) setIntegerParam(function, value);
    
    /* Fetch the parameter string name for possible use in debugging */
    getParamName(function, &paramName);

    if (function == P_RunStop) {
        if (value) epicsEventSignal(eventId_);
    } 
    else {
        /* All other parameters just get set in parameter list, no need to
         * act on them here */
    }
    
    /* Do callbacks so higher layers see any changes */
    status = (asynStatus) callParamCallbacks();
    
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d, name=%s, value=%d", 
                  driverName, functionName, status, function, paramName, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, name=%s, value=%d\n", 
              driverName, functionName, function, paramName, value);
    return status;
}
开发者ID:FreddieAkeroyd,项目名称:asyn,代码行数:39,代码来源:testArrayRingBuffer.cpp


示例15: testEpicsSnprintf

static void testEpicsSnprintf(void) {
    char exbuffer[80], buffer[80];
    const int ivalue = 1234;
    const float fvalue = 1.23e4f;
    const char *svalue = "OneTwoThreeFour";
    const char *format = "int %d float %8.2e string %s";
    const char *expected = exbuffer;
    int size;
    int rtn, rlen;
    
    sprintf(exbuffer, format, ivalue, fvalue, svalue);
    rlen = strlen(expected)+1;
    
    strcpy(buffer, "AAAA");
    
    for (size = 1; size < strlen(expected) + 5; ++size) {
        rtn = epicsSnprintf(buffer, size, format, ivalue, fvalue, svalue);
        testOk(rtn <= rlen-1, "epicsSnprintf(size=%d) = %d", size, rtn);
        if (rtn != rlen-1)
            testDiag("Return value does not indicate buffer size needed");
        testOk(strncmp(buffer, expected, size - 1) == 0,
            "buffer = '%s'", buffer);
        rtn = strlen(buffer);
        testOk(rtn == (size < rlen ? size : rlen) - 1,
            "length = %d", rtn);
    }
}
开发者ID:A2-Collaboration,项目名称:epics,代码行数:27,代码来源:epicsStdioTest.c


示例16: writeIt

/*
 * Double up IAC characters.
 * We assume that memchr and memcpy are  nicely optimized so we're better of
 * using them than looking at and copying the characters one at a time ourself.
 */
static asynStatus
writeIt(void *ppvt, asynUser *pasynUser,
    const char *data, size_t numchars, size_t *nbytesTransfered)
{
    interposePvt *pinterposePvt = (interposePvt *)ppvt;
    const char *iac;
    char *dst = pinterposePvt->xBuf;
    size_t nIAC = 0;
    asynStatus status;

    if ((iac = memchr(data, C_IAC, numchars)) != NULL) {
        size_t nLeft = numchars;
        size_t nCopy = iac - data + 1;
        for (;;) {
            size_t nNew = nCopy + 1;
            char *np;
            if (nNew > pinterposePvt->xBufCapacity) {
                /*
                 * Try to strike a balance between too many
                 * realloc calls and too much wasted space.
                 */
                size_t newSize = pinterposePvt->xBufCapacity + 1024;
                if (newSize < numchars)
                    newSize = numchars + 1024;
                if (newSize < nNew)
                    newSize = nNew + 1024;
                np = realloc(pinterposePvt->xBuf, newSize);
                if (np == NULL) {
                    epicsSnprintf(pasynUser->errorMessage,
                                  pasynUser->errorMessageSize, "Out of memory");
                    return asynError;
                }
                dst = np + (dst - pinterposePvt->xBuf);
                pinterposePvt->xBuf = np;
                pinterposePvt->xBufCapacity = newSize;
            }
            memcpy(dst, data, nCopy);
            dst += nCopy;
            if (iac != NULL) {
                *dst++ = C_IAC;
                nIAC++;
            }
            nLeft -= nCopy;
            if (nLeft == 0)
                break;
            data += nCopy;
            if ((iac = memchr(data, C_IAC, nLeft)) != NULL)
                nCopy = iac - data + 1;
            else
                nCopy = nLeft;
        }
        numchars += nIAC;
        data = pinterposePvt->xBuf;
    }
    status =  pinterposePvt->pasynOctetDrv->write(pinterposePvt->drvPvt,
                                pasynUser, data, numchars, nbytesTransfered);
    if (*nbytesTransfered == numchars)
        *nbytesTransfered -= nIAC;
    return status;
}
开发者ID:A2-Collaboration,项目名称:epics,代码行数:65,代码来源:asynInterposeCom.c


示例17: uint32Read

static asynStatus uint32Read(void *pvt,asynUser *pasynUser,
                             epicsUInt32 *value,epicsUInt32 mask)
{
    drvPvt *pdrvPvt = (drvPvt *)pvt;
    int        addr;
    asynStatus status;

    status = getAddr(pdrvPvt,pasynUser,&addr,0);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser, ASYN_TRACE_FLOW,
              "%s %d uint32DigitalDriver:readInt32\n",pdrvPvt->portName,addr);
    if(!pdrvPvt->connected) {
        asynPrint(pasynUser,ASYN_TRACE_ERROR,
                  "%s uint32DigitalDriver:read  not connected\n",pdrvPvt->portName);
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
                      "%s uint32DigitalDriver:read not connected",pdrvPvt->portName);
        return asynError;
    }
    epicsMutexMustLock(pdrvPvt->lock);
    *value = mask & pdrvPvt->channel[addr].value;
    epicsMutexUnlock(pdrvPvt->lock);
    asynPrint(pasynUser,ASYN_TRACEIO_DRIVER,
              "%s read %d\n",pdrvPvt->portName,*value);
    return asynSuccess;
}
开发者ID:ukaea,项目名称:epics,代码行数:25,代码来源:uint32DigitalDriver.c


示例18: float64Read

static asynStatus float64Read(void *pvt,asynUser *pasynUser,
                              epicsFloat64 *value)
{
    drvPvt *pdrvPvt = (drvPvt *)pvt;
    int        addr;
    asynStatus status;

    status = getAddr(pdrvPvt,pasynUser,&addr,0);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser, ASYN_TRACE_FLOW,
              "%s %d uint32DigitalDriver:float64Read\n",pdrvPvt->portName,addr);
    if(!pdrvPvt->connected) {
        asynPrint(pasynUser,ASYN_TRACE_ERROR,
                  "%s uint32DigitalDriver:read  not connected\n",pdrvPvt->portName);
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
                      "%s uint32DigitalDriver:read not connected",pdrvPvt->portName);
        return asynError;
    }
    epicsMutexMustLock(pdrvPvt->lock);
    *value = pdrvPvt->interruptDelay;
    epicsMutexUnlock(pdrvPvt->lock);
    asynPrint(pasynUser,ASYN_TRACEIO_DRIVER,
              "%s read %f\n",pdrvPvt->portName,*value);
    return asynSuccess;
}
开发者ID:ukaea,项目名称:epics,代码行数:25,代码来源:uint32DigitalDriver.c


示例19: getAddress

/** Sets an int32 parameter.
  * \param[in] pasynUser asynUser structure that contains the function code in pasynUser->reason. 
  * \param[in] value The value for this parameter 
  *
  * Takes action if the function code requires it.
  */
asynStatus NDPosPlugin::writeInt32(asynUser *pasynUser, epicsInt32 value)
{
  int function = pasynUser->reason;
  int oldvalue;
  int addr;
  asynStatus status = asynSuccess;
  static const char *functionName = "NDPosPlugin::writeInt32";

  // Set the parameter in the parameter library.
  status = getAddress(pasynUser, &addr);
  if (status == asynSuccess){
    getIntegerParam(function, &oldvalue);

    // By default we set the value in the parameter library. If problems occur we set the old value back.
    setIntegerParam(function, value);

    if (function == NDPos_Running){
      // Reset the expected ID to the starting value
      int expected = 0;
      getIntegerParam(NDPos_IDStart, &expected);
      setIntegerParam(NDPos_ExpectedID, expected);
    } else if (function == NDPos_Mode){
      // Reset the position index to 0 if the mode is changed
      setIntegerParam(NDPos_CurrentIndex, 0);
    } else if (function == NDPos_Restart){
      // Reset the position index to 0
      setIntegerParam(NDPos_CurrentIndex, 0);
      // Reset the last sent position
      setStringParam(NDPos_CurrentPos, "");
    } else if (function == NDPos_Delete){
      // Reset the position index to 0
      setIntegerParam(NDPos_CurrentIndex, 0);
      // Reset the last sent position
      setStringParam(NDPos_CurrentPos, "");
      // Clear out the position array
      positionArray.clear();
      setIntegerParam(NDPos_CurrentQty, positionArray.size());
    } else {
      // If this parameter belongs to a base class call its method
      if (function < FIRST_NDPOS_PARAM){
        status = NDPluginDriver::writeInt32(pasynUser, value);
      }
    }
  }

  // Do callbacks so higher layers see any changes
  status = (asynStatus)callParamCallbacks();

  if (status){
    epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
                  "%s: status=%d, function=%d, value=%d",
                  functionName, status, function, value);
  } else {
    asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
              "%s: function=%d, value=%d\n",
              functionName, function, value);
  }

  return status;
}
开发者ID:AdamBark,项目名称:ADCore,代码行数:66,代码来源:NDPosPlugin.cpp


示例20: setIntegerParam

/** Base method for closing a file
  * Calls the pure virtual function closeFile in the derived class. */
asynStatus NDPluginFile::closeFileBase()
{
    /* Closes a file */
    asynStatus status = asynSuccess;
    char errorMessage[256];
    const char* functionName = "closeFileBase";

    setIntegerParam(NDFileWriteStatus, NDFileWriteOK);
    setStringParam(NDFileWriteMessage, "");
     /* Call the closeFile method in the derived class */
    epicsMutexLock(this->fileMutexId);
    status = this->closeFile();
    if (status) {
        epicsSnprintf(errorMessage, sizeof(errorMessage)-1, 
            "Error closing file, status=%d", status);
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, 
              "%s:%s %s\n", 
              driverName, functionName, errorMessage);
        setIntegerParam(NDFileWriteStatus, NDFileWriteError);
        setStringParam(NDFileWriteMessage, errorMessage);
    }
    epicsMutexUnlock(this->fileMutexId);
    
    return(status);
}
开发者ID:NSLS-II-CSX,项目名称:xf23id1-ioc1,代码行数:27,代码来源:NDPluginFile.cpp



注:本文中的epicsSnprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ epicsThreadCreate函数代码示例发布时间:2022-05-30
下一篇:
C++ epicsMutexUnlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap