您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DEBUGF函数代码示例

51自学网 2021-06-01 20:19:26
  C++
这篇教程C++ DEBUGF函数代码示例写得很实用,希望能帮到您。

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

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

示例1: supported

/* Reserve space in the buffer for a file.   filename: name of the file to open   offset: offset at which to start buffering the file, useful when the first           (offset-1) bytes of the file aren't needed.   type: one of the data types supported (audio, image, cuesheet, others   user_data: user data passed possibly passed in subcalls specific to a              data_type (only used for image (albumart) buffering so far )   return value: <0 if the file cannot be opened, or one file already   queued to be opened, otherwise the handle for the file in the buffer*/int bufopen(const char *file, size_t offset, enum data_type type,            void *user_data){#ifndef HAVE_ALBUMART    /* currently only used for aa loading */    (void)user_data;#endif    if (type == TYPE_ID3)    {        /* ID3 case: allocate space, init the handle and return. */        struct memory_handle *h = add_handle(sizeof(struct mp3entry), false, true);        if (!h)            return ERR_BUFFER_FULL;        h->fd = -1;        h->filesize = sizeof(struct mp3entry);        h->filerem = sizeof(struct mp3entry);        h->offset = 0;        h->data = buf_widx;        h->ridx = buf_widx;        h->widx = buf_widx;        h->available = 0;        h->type = type;        strlcpy(h->path, file, MAX_PATH);        buf_widx += sizeof(struct mp3entry);  /* safe because the handle                                                 can't wrap */        /* Inform the buffering thread that we added a handle */        LOGFQUEUE("buffering > Q_HANDLE_ADDED %d", h->id);        queue_post(&buffering_queue, Q_HANDLE_ADDED, h->id);        return h->id;    }    /* Other cases: there is a little more work. */    int fd = open(file, O_RDONLY);    if (fd < 0)        return ERR_FILE_ERROR;    size_t size = filesize(fd);    bool can_wrap = type==TYPE_PACKET_AUDIO || type==TYPE_CODEC;    size_t adjusted_offset = offset;    if (adjusted_offset > size)        adjusted_offset = 0;    /* Reserve extra space because alignment can move data forward */    size_t padded_size = STORAGE_PAD(size-adjusted_offset);    struct memory_handle *h = add_handle(padded_size, can_wrap, false);    if (!h)    {        DEBUGF("%s(): failed to add handle/n", __func__);        close(fd);        return ERR_BUFFER_FULL;    }    strlcpy(h->path, file, MAX_PATH);    h->offset = adjusted_offset;    /* Don't bother to storage align bitmaps because they are not     * loaded directly into the buffer.     */    if (type != TYPE_BITMAP)    {        size_t alignment_pad;                /* Remember where data area starts, for use by reset_handle */        h->start = buf_widx;        /* Align to desired storage alignment */        alignment_pad = STORAGE_OVERLAP(adjusted_offset - (size_t)(&buffer[buf_widx]));        buf_widx = ringbuf_add(buf_widx, alignment_pad);    }    h->ridx = buf_widx;    h->widx = buf_widx;    h->data = buf_widx;    h->available = 0;    h->filerem = 0;    h->type = type;#ifdef HAVE_ALBUMART    if (type == TYPE_BITMAP)    {        /* Bitmap file: we load the data instead of the file */        int rc;        mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields *///.........这里部分代码省略.........
开发者ID:a-martinez,项目名称:rockbox,代码行数:101,


示例2: DEBUG

bool QHYCCD::StartExposure(float duration){  int ret = QHYCCD_ERROR;  if (streamer->isBusy())  {      DEBUG(INDI::Logger::DBG_ERROR, "Cannot take exposure while streaming/recording is active.");      return false;  }  //AbortPrimaryFrame = false;  if (duration < MINIMUM_CCD_EXPOSURE)  {    DEBUGF(INDI::Logger::DBG_WARNING, "Exposure shorter than minimum duration %g s requested. Setting exposure time to %g s.", duration, MINIMUM_CCD_EXPOSURE);    duration = MINIMUM_CCD_EXPOSURE;  }  imageFrameType = PrimaryCCD.getFrameType();  if (imageFrameType == CCDChip::BIAS_FRAME)  {    duration = MINIMUM_CCD_EXPOSURE;    DEBUGF(INDI::Logger::DBG_SESSION, "Bias Frame (s) : %g", duration);  }  else if(imageFrameType == CCDChip::DARK_FRAME)  {      ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_CLOSE);  }  else  {      ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_FREE);  }  DEBUGF(INDI::Logger::DBG_DEBUG, "Current exposure time is %f us",duration * 1000 * 1000);  ExposureRequest = duration;  PrimaryCCD.setExposureDuration(duration);  if (sim)      ret = QHYCCD_SUCCESS;  else      ret = SetQHYCCDParam(camhandle,CONTROL_EXPOSURE,ExposureRequest * 1000 * 1000);  if(ret != QHYCCD_SUCCESS)  {      DEBUGF(INDI::Logger::DBG_ERROR, "Set expose time failed (%d).", ret);      return false;  }  // lzr: we need to call the following apis every single exposure,the usleep(200000) is important  if (sim)      ret = QHYCCD_SUCCESS;  else      ret = SetQHYCCDBinMode(camhandle,camxbin,camybin);  if(ret != QHYCCD_SUCCESS)  {      DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD Bin mode failed (%d)", ret);      return false;  }  DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDBinMode %dx%d", camxbin, camybin);  if (sim)      ret = QHYCCD_SUCCESS;  else     ret = SetQHYCCDResolution(camhandle,camroix,camroiy,camroiwidth,camroiheight);  if(ret != QHYCCD_SUCCESS)  {      DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD ROI resolution failed (%d)", ret);      return false;  }  DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDResolution camroix %d camroiy %d camroiwidth %d camroiheight %d", camroix,camroiy,camroiwidth,camroiheight);    // Jasem: Removed QHY 300ms delay that was added without specifying the reason. It seems any delay less than 100ms results in QHY Frame error. Again no reason. This renders  // exposures less than 100ms useless, but there is nothing I can do about that.  usleep(100000);  if (sim)      ret = QHYCCD_SUCCESS;  else      ret = ExpQHYCCDSingleFrame(camhandle);  if(ret != QHYCCD_SUCCESS)  {      DEBUGF(INDI::Logger::DBG_SESSION, "Begin QHYCCD expose failed (%d)", ret);      return false;  }  gettimeofday(&ExpStart, NULL);  DEBUGF(INDI::Logger::DBG_DEBUG, "Taking a %g seconds frame...", ExposureRequest);  InExposure = true; // if (ExposureRequest*1000 < POLLMS) //     SetTimer(ExposureRequest*1000); // else      SetTimer(POLLMS);  return true;}
开发者ID:jochym,项目名称:indilib,代码行数:100,


示例3: search_files

intsearch_files(const char *path, const char *expr, TranslationFlags flags, const SearchOptions *opts, Callback found_file, Callback err_message, void *user_data){	int ret = -1;	assert(path != NULL);	assert(expr != NULL);	assert(opts != NULL);	int outfds[2];	int errfds[2];	memset(outfds, 0, sizeof(outfds));	memset(errfds, 0, sizeof(errfds));	TRACE("search", "Creating pipes.");	if(pipe2(outfds, 0) >= 0 && pipe2(errfds, 0) >= 0)	{		char **argv = NULL;		size_t argc = 0;		ParserResult *result;		TRACE("search", "Pipes created successfully, translating expression.");		result = _search_translate_expr(path, expr, flags, opts, &argc, &argv);		assert(result != NULL);		if(result->success)		{			DEBUG("search", "Expression parsed successfully, forking and running `find'.");			pid_t pid = fork();			if(pid == -1)			{				FATALF("search", "`fork' failed with result %ld.", pid);				perror("fork()");			}			else if(pid == 0)			{				if(_search_close_and_dup_child_fds(outfds, errfds))				{					_search_child_process(argv);				}				else				{					ERROR("search", "Couldn't initialize child's file descriptors.");				}			}			else			{				if(_search_close_parent_fds(outfds, errfds))				{					ParentCtx ctx;					memset(&ctx, 0, sizeof(ParentCtx));					ctx.child_pid = pid;					ctx.outfd = outfds[0];					ctx.errfd = errfds[0];					ctx.found_file = found_file;					ctx.err_message = err_message;					ctx.user_data = user_data;					_search_filter_args_init(&ctx.filter_args, result);					ret = _search_parent_process(&ctx);					_search_filter_args_free(&ctx.filter_args);				}				else				{					WARNING("search", "Couldn't close parent's file descriptors.");				}			}		}		else if(result->err)		{			TRACEF("search", "Couldn't parse expression: %s", result->err);		}		else		{			TRACE("search", "Couldn't parse expression, no error message set.");		}		DEBUGF("search", "Search finished with result %d.", ret);		if(argv)		{			for(size_t i = 0; i < argc; i++)			{				free(argv[i]);			}			free(argv);		}		parser_result_free(result);//.........这里部分代码省略.........
开发者ID:20centaurifux,项目名称:efind,代码行数:101,


示例4: processFilterSlot

bool QHYCCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n){    //  first check if it's for our device    //IDLog("INDI::CCD::ISNewNumber %s/n",name);    if(strcmp(dev,getDeviceName())==0)    {        if (strcmp(name,FilterSlotNP.name)==0)        {            processFilterSlot(getDeviceName(), values, names);            return true;        }        if(strcmp(name,GainNP.name) == 0)        {            IUUpdateNumber(&GainNP, values, names, n);            SetQHYCCDParam(camhandle,CONTROL_GAIN,GainN[0].value);            DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",GainNP.name,GainN[0].value);            GainNP.s = IPS_OK;            IDSetNumber(&GainNP, NULL);            //saveConfig();            return true;        }        if(strcmp(name,OffsetNP.name) == 0)        {            IUUpdateNumber(&OffsetNP, values, names, n);            SetQHYCCDParam(camhandle,CONTROL_OFFSET,OffsetN[0].value);            DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",OffsetNP.name,OffsetN[0].value);            OffsetNP.s = IPS_OK;            IDSetNumber(&OffsetNP, NULL);            saveConfig();            return true;        }        if(strcmp(name,SpeedNP.name) == 0)        {            IUUpdateNumber(&SpeedNP, values, names, n);            SetQHYCCDParam(camhandle,CONTROL_SPEED,SpeedN[0].value);            DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",SpeedNP.name,SpeedN[0].value);            SpeedNP.s = IPS_OK;            IDSetNumber(&SpeedNP, NULL);            saveConfig();            return true;        }        if(strcmp(name,USBTrafficNP.name) == 0)        {            IUUpdateNumber(&USBTrafficNP, values, names, n);            SetQHYCCDParam(camhandle,CONTROL_USBTRAFFIC,USBTrafficN[0].value);            DEBUGF(INDI::Logger::DBG_SESSION, "Current %s value %f",USBTrafficNP.name,USBTrafficN[0].value);            USBTrafficNP.s = IPS_OK;            IDSetNumber(&USBTrafficNP, NULL);            saveConfig();            return true;        }    }    //  if we didn't process it, continue up the chain, let somebody else    //  give it a shot    return INDI::CCD::ISNewNumber(dev,name,values,names,n);}
开发者ID:jochym,项目名称:indilib,代码行数:62,


示例5: defineSwitch

bool QHYCCD::updateProperties(){  INDI::CCD::updateProperties();  double min,max,step;  if (isConnected())  {      if (HasCooler())      {          defineSwitch(&CoolerSP);          defineNumber(&CoolerNP);          temperatureID = IEAddTimer(POLLMS, QHYCCD::updateTemperatureHelper, this);      }      if(HasUSBSpeed)      {          if (sim)          {              SpeedN[0].min = 1;              SpeedN[0].max = 5;              SpeedN[0].step = 1;              SpeedN[0].value = 1;          }          else          {              int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_SPEED,&min,&max,&step);              if(ret == QHYCCD_SUCCESS)              {                  SpeedN[0].min = min;                  SpeedN[0].max = max;                  SpeedN[0].step = step;              }              SpeedN[0].value = GetQHYCCDParam(camhandle,CONTROL_SPEED);              DEBUGF(INDI::Logger::DBG_DEBUG, "USB Speed. Value: %g Min: %g Max: %g Step %g", SpeedN[0].value, SpeedN[0].min, SpeedN[0].max, SpeedN[0].step);          }          defineNumber(&SpeedNP);      }      if(HasGain)      {          if (sim)          {              GainN[0].min = 0;              GainN[0].max = 100;              GainN[0].step = 10;              GainN[0].value = 50;          }          else          {              int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_GAIN,&min,&max,&step);              if(ret == QHYCCD_SUCCESS)              {                  GainN[0].min = min;                  GainN[0].max = max;                  GainN[0].step = step;              }              GainN[0].value = GetQHYCCDParam(camhandle,CONTROL_GAIN);              DEBUGF(INDI::Logger::DBG_DEBUG, "Gain. Value: %g Min: %g Max: %g Step %g", GainN[0].value, GainN[0].min, GainN[0].max, GainN[0].step);          }          defineNumber(&GainNP);      }      if(HasOffset)      {          if (sim)          {              OffsetN[0].min = 1;              OffsetN[0].max = 10;              OffsetN[0].step = 1;              OffsetN[0].value = 1;          }          else          {              int ret = GetQHYCCDParamMinMaxStep(camhandle,CONTROL_OFFSET,&min,&max,&step);              if(ret == QHYCCD_SUCCESS)              {                  OffsetN[0].min = min;                  OffsetN[0].max = max;                  OffsetN[0].step = step;              }              OffsetN[0].value = GetQHYCCDParam(camhandle,CONTROL_OFFSET);              DEBUGF(INDI::Logger::DBG_DEBUG, "Offset. Value: %g Min: %g Max: %g Step %g", OffsetN[0].value, OffsetN[0].min, OffsetN[0].max, OffsetN[0].step);          }          //Define the Offset          defineNumber(&OffsetNP);      }      if(HasFilters)      {          //Define the Filter Slot and name properties          defineNumber(&FilterSlotNP);//.........这里部分代码省略.........
开发者ID:jochym,项目名称:indilib,代码行数:101,


示例6: set_pinfo

staticvoid set_pinfo (        lame_global_flags *gfp,              gr_info        * const cod_info,        const III_psy_ratio  * const ratio,         const III_scalefac_t * const scalefac,        const int                    gr,        const int                    ch ){    lame_internal_flags *gfc=gfp->internal_flags;    int sfb;    int j,i,l,start,end,bw;    FLOAT8 en0,en1;    FLOAT ifqstep = ( cod_info->scalefac_scale == 0 ) ? .5 : 1.0;    III_psy_xmin l3_xmin;    calc_noise_result noise;    III_psy_xmin xfsf;    calc_xmin (gfp, ratio, cod_info, &l3_xmin);    calc_noise (gfc, cod_info->l3_enc, cod_info,		&l3_xmin, scalefac, &xfsf, &noise);    if (cod_info->block_type == SHORT_TYPE) {        for (j=0, sfb = 0; sfb < SBMAX_s; sfb++ )  {            start = gfc->scalefac_band.s[ sfb ];            end   = gfc->scalefac_band.s[ sfb + 1 ];            bw = end - start;            for ( i = 0; i < 3; i++ ) {                for ( en0 = 0.0, l = start; l < end; l++ ) {                    en0 += cod_info->xr[j] * cod_info->xr[j];                    ++j;                }                en0=Max(en0/bw,1e-20);#if 0{    double tot1,tot2;    if (sfb<SBMAX_s-1) {        if (sfb==0) {            tot1=0;            tot2=0;        }        tot1 += en0;        tot2 += ratio->en.s[sfb][i];        DEBUGF("%i %i sfb=%i mdct=%f fft=%f  fft-mdct=%f db /n",                gr,ch,sfb,                10*log10(Max(1e-25,ratio->en.s[sfb][i])),                10*log10(Max(1e-25,en0)),                10*log10((Max(1e-25,en0)/Max(1e-25,ratio->en.s[sfb][i]))));        if (sfb==SBMAX_s-2) {            DEBUGF("%i %i toti %f %f ratio=%f db /n",gr,ch,                    10*log10(Max(1e-25,tot2)),                    10*log(Max(1e-25,tot1)),                    10*log10(Max(1e-25,tot1)/(Max(1e-25,tot2))));        }    }    /*        masking: multiplied by en0/fft_energy        average seems to be about -135db.     */}#endif                /* convert to MDCT units */                en1=1e15;  /* scaling so it shows up on FFT plot */                gfc->pinfo->xfsf_s[gr][ch][3*sfb+i]                     = en1*xfsf.s[sfb][i]*l3_xmin.s[sfb][i]/bw;                gfc->pinfo->en_s[gr][ch][3*sfb+i] = en1*en0;                if (ratio->en.s[sfb][i]>0)                    en0 = en0/ratio->en.s[sfb][i];                else                    en0=0;                if (gfp->ATHonly || gfp->ATHshort)                    en0=0;                gfc->pinfo->thr_s[gr][ch][3*sfb+i] =                         en1*Max(en0*ratio->thm.s[sfb][i],gfc->ATH->s[sfb]);                 /* there is no scalefactor bands >= SBPSY_s */                if (sfb < SBPSY_s) {                    gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i]=                                            -ifqstep*scalefac->s[sfb][i];                } else {                    gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i]=0;                }                gfc->pinfo->LAMEsfb_s[gr][ch][3*sfb+i] -=                                             2*cod_info->subblock_gain[i];            }        }    } else {        for ( sfb = 0; sfb < SBMAX_l; sfb++ )   {//.........这里部分代码省略.........
开发者ID:TravisKraatz,项目名称:cinelerra,代码行数:101,


示例7: CalcTimeLeft

void FishCampCCD::TimerHit(){    int timerHitID = -1, state = -1, rc = -1;    long timeleft;    double ccdTemp;    if (isConnected() == false)        return; //  No need to reset timer if we are not connected anymore    if (InExposure)    {        timeleft = CalcTimeLeft();        if (timeleft < 1.0)        {            if (timeleft > 0.25)            {                //  a quarter of a second or more                //  just set a tighter timer                timerHitID = SetTimer(250);            }            else            {                if (timeleft > 0.07)                {                    //  use an even tighter timer                    timerHitID = SetTimer(50);                }                else                {                    //  it's real close now, so spin on it                    while (!sim && timeleft > 0)                    {                        state = fcUsb_cmd_getState(cameraNum);                        if (state == 0)                            timeleft = 0;                        int slv;                        slv = 100000 * timeleft;                        usleep(slv);                    }                    /* We're done exposing */                    DEBUG(INDI::Logger::DBG_DEBUG, "Exposure done, downloading image...");                    PrimaryCCD.setExposureLeft(0);                    InExposure = false;                    /* grab and save image */                    grabImage();                }            }        }        else        {            DEBUGF(INDI::Logger::DBG_DEBUG, "Image not yet ready. With time left %ld/n", timeleft);        }        PrimaryCCD.setExposureLeft(timeleft);    }    switch (TemperatureNP.s)    {        case IPS_IDLE:        case IPS_OK:            rc = fcUsb_cmd_getTemperature(cameraNum);            DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc);            ccdTemp = rc / 100.0;            DEBUGF(INDI::Logger::DBG_DEBUG, "Temperature %g", ccdTemp);            if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD)            {                TemperatureN[0].value = ccdTemp;                IDSetNumber(&TemperatureNP, NULL);            }            break;        case IPS_BUSY:            if (sim)            {                TemperatureN[0].value = TemperatureRequest;            }            else            {                rc = fcUsb_cmd_getTemperature(cameraNum);                DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc);                TemperatureN[0].value = rc / 100.0;            }            // If we're within threshold, let's make it BUSY ---> OK            if (fabs(TemperatureRequest - TemperatureN[0].value) <= TEMP_THRESHOLD)                TemperatureNP.s = IPS_OK;            IDSetNumber(&TemperatureNP, NULL);            break;//.........这里部分代码省略.........
开发者ID:rumengb,项目名称:indi,代码行数:101,


示例8: catch

bool QSICCD::setupParams(){    string name, model;    double temperature;    double pixel_size_x, pixel_size_y;    long sub_frame_x, sub_frame_y;    try    {        QSICam.get_Name(name);        QSICam.get_ModelNumber(model);        QSICam.get_PixelSizeX(&pixel_size_x);        QSICam.get_PixelSizeY(&pixel_size_y);        QSICam.get_NumX(&sub_frame_x);        QSICam.get_NumY(&sub_frame_y);        QSICam.get_CCDTemperature(&temperature);    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "Setup Params failed. %s.", err.what());        return false;    }    DEBUGF(INDI::Logger::DBG_SESSION, "The CCD Temperature is %f.", temperature);    TemperatureN[0].value = temperature; /* CCD chip temperatre (degrees C) */    IDSetNumber(&TemperatureNP, nullptr);    SetCCDParams(sub_frame_x, sub_frame_y, 16, pixel_size_x, pixel_size_y);    imageWidth  = PrimaryCCD.getSubW();    imageHeight = PrimaryCCD.getSubH();    int nbuf;    nbuf = PrimaryCCD.getXRes() * PrimaryCCD.getYRes() * PrimaryCCD.getBPP() / 8; //  this is pixel count    nbuf += 512;                                                                  //  leave a little extra at the end    PrimaryCCD.setFrameBufferSize(nbuf);    try    {        QSICam.get_Name(name);    }    catch (std::runtime_error &err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "get_Name() failed. %s.", err.what());        return false;    }    DEBUGF(INDI::Logger::DBG_SESSION, "%s", name.c_str());    try    {        QSICam.get_FilterCount(filterCount);        DEBUGF(INDI::Logger::DBG_SESSION, "The filter count is %d", filterCount);        FilterSlotN[0].min = 1;        FilterSlotN[0].max = filterCount;        FilterSlotNP.s     = IPS_OK;    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_SESSION, "get_FilterCount() failed. %s.", err.what());        return false;    }    // Only generate filter names if there are none initially    //if (FilterNameT == nullptr)        //GetFilterNames(FILTER_TAB);    double minDuration = 0;    try    {        QSICam.get_MinExposureTime(&minDuration);    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "get_MinExposureTime() failed. %s.", err.what());        return false;    }    PrimaryCCD.setMinMaxStep("CCD_EXPOSURE", "CCD_EXPOSURE_VALUE", minDuration, 3600, 1, true);    bool coolerOn = false;    try    {        QSICam.get_CoolerOn(&coolerOn);    }    catch (std::runtime_error err)    {        CoolerSP.s   = IPS_IDLE;        CoolerS[0].s = ISS_OFF;        CoolerS[1].s = ISS_ON;        DEBUGF(INDI::Logger::DBG_ERROR, "Error: CoolerOn() failed. %s.", err.what());        IDSetSwitch(&CoolerSP, nullptr);        return false;    }    CoolerS[0].s = coolerOn ? ISS_ON : ISS_OFF;    CoolerS[1].s = coolerOn ? ISS_OFF : ISS_ON;    CoolerSP.s   = IPS_OK;//.........这里部分代码省略.........
开发者ID:rrogge,项目名称:indi,代码行数:101,


示例9: CalcTimeLeft

void QSICCD::TimerHit(){    long timeleft = 0;    double ccdTemp = 0;    double coolerPower = 0;    if (isConnected() == false)        return; //  No need to reset timer if we are not connected anymore    if (InExposure)    {        bool imageReady;        timeleft = CalcTimeLeft(ExpStart, ExposureRequest);        if (timeleft < 1)        {            QSICam.get_ImageReady(&imageReady);            while (!imageReady)            {                usleep(100);                QSICam.get_ImageReady(&imageReady);            }            /* We're done exposing */            DEBUG(INDI::Logger::DBG_SESSION, "Exposure done, downloading image...");            PrimaryCCD.setExposureLeft(0);            InExposure = false;            /* grab and save image */            grabImage();        }        else        {            DEBUGF(INDI::Logger::DBG_DEBUG, "Image not ready, time left %ld/n", timeleft);            PrimaryCCD.setExposureLeft(timeleft);        }    }    switch (TemperatureNP.s)    {        case IPS_IDLE:        case IPS_OK:            try            {                QSICam.get_CCDTemperature(&ccdTemp);            }            catch (std::runtime_error err)            {                TemperatureNP.s = IPS_IDLE;                DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what());                IDSetNumber(&TemperatureNP, nullptr);                return;            }            if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD)            {                TemperatureN[0].value = ccdTemp;                IDSetNumber(&TemperatureNP, nullptr);            }            break;        case IPS_BUSY:            try            {                QSICam.get_CCDTemperature(&TemperatureN[0].value);            }            catch (std::runtime_error err)            {                TemperatureNP.s = IPS_ALERT;                DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what());                IDSetNumber(&TemperatureNP, nullptr);                return;            }            if (fabs(TemperatureN[0].value - targetTemperature) <= TEMP_THRESHOLD)                TemperatureNP.s = IPS_OK;            IDSetNumber(&TemperatureNP, nullptr);            break;        case IPS_ALERT:            break;    }    switch (CoolerNP.s)    {        case IPS_IDLE:        case IPS_OK:            try            {                QSICam.get_CoolerPower(&coolerPower);            }            catch (std::runtime_error err)            {                CoolerNP.s = IPS_IDLE;                DEBUGF(INDI::Logger::DBG_ERROR, "get_CoolerPower() failed. %s.", err.what());                IDSetNumber(&CoolerNP, nullptr);                return;            }//.........这里部分代码省略.........
开发者ID:rrogge,项目名称:indi,代码行数:101,


示例10: switch

void QSICCD::turnWheel(){    short current_filter = 0;    switch (FilterS[0].s)    {        case ISS_ON:            try            {                current_filter = QueryFilter();                if (current_filter < filterCount)                    current_filter++;                else                    current_filter = 1;                SelectFilter(current_filter);            }            catch (std::runtime_error err)            {                FilterSP.s   = IPS_IDLE;                FilterS[0].s = ISS_OFF;                FilterS[1].s = ISS_OFF;                DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());                return;            }            FilterSlotN[0].value = current_filter;            FilterS[0].s         = ISS_OFF;            FilterS[1].s         = ISS_OFF;            FilterSP.s           = IPS_OK;            DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d", current_filter);            IDSetSwitch(&FilterSP, nullptr);            break;        case ISS_OFF:            try            {                current_filter = QueryFilter();                if (current_filter > 1)                    current_filter--;                else                    current_filter = filterCount;                SelectFilter(current_filter);            }            catch (std::runtime_error err)            {                FilterSP.s   = IPS_IDLE;                FilterS[0].s = ISS_OFF;                FilterS[1].s = ISS_OFF;                DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());                return;            }            FilterSlotN[0].value = current_filter;            FilterS[0].s         = ISS_OFF;            FilterS[1].s         = ISS_OFF;            FilterSP.s           = IPS_OK;            DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d", current_filter);            IDSetSwitch(&FilterSP, nullptr);            IDSetNumber(&FilterSlotNP, nullptr);            break;    }}
开发者ID:rrogge,项目名称:indi,代码行数:63,


示例11: set_debugflags

/*Set the debug flags------------------------------------------------*/void set_debugflags(char *flags) {  debugflags = flags;  if (strchr(debugflags, '@') != NULL) alldebugflags = true;  DEBUGF('a', "Debugflags = /"%s/"/n", debugflags);}
开发者ID:kevinjesse,项目名称:UC-Santa-Cruz-Coursework,代码行数:6,


示例12: pbuf_alloc

/*-----------------------------------------------------------------------------------*/struct pbuf *pbuf_alloc(pbuf_layer l, uint16_t size, pbuf_flag flag){  struct pbuf *p, *q, *r;  uint16_t offset;  int32_t rsize;  offset = 0;  switch(l) {	  case PBUF_TRANSPORT:		  offset += PBUF_TRANSPORT_HLEN;		  /* FALLTHROUGH */	  case PBUF_IP:		  offset += PBUF_IP_HLEN;		  offset += PBUF_LINK_HLEN;		  /* FALLTHROUGH */	  case PBUF_LINK:		  break;	  case PBUF_RAW:		  break;	  default:		  ASSERT("pbuf_alloc: bad pbuf layer", 0);		  return NULL;  }  switch(flag)  {	  case PBUF_POOL:		  /* Allocate head of pbuf chain into p. */		  p = pbuf_pool_alloc();		  if(p == NULL) {#ifdef PBUF_STATS			  ++stats.pbuf.err;#endif /* PBUF_STATS */			  return NULL;		  }		  p->next = NULL;		  /* Set the payload pointer so that it points offset bytes into			 pbuf data memory. */		  p->payload = MEM_ALIGN((void *)((uint8_t *)p + (sizeof(struct pbuf) + offset)));		  /* The total length of the pbuf is the requested size. */		  p->tot_len = size;		  /* Set the length of the first pbuf is the chain. */		  p->len = size > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: size;		  p->flags = PBUF_FLAG_POOL;		  /* Allocate the tail of the pbuf chain. */		  r = p;		  rsize = size - p->len;		  while(rsize > 0) {			  q = pbuf_pool_alloc();			  if(q == NULL) {				  DEBUGF(PBUF_DEBUG, ("pbuf_alloc: Out of pbufs in pool,/n"));#ifdef PBUF_STATS				  ++stats.pbuf.err;#endif /* PBUF_STATS */				  pbuf_pool_free(p);				  return NULL;			  }			  q->next = NULL;			  r->next = q;			  q->len = rsize > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rsize;			  q->flags = PBUF_FLAG_POOL;			  q->payload = (void *)((uint8_t *)q + sizeof(struct pbuf));			  r = q;			  q->ref = 1;			  q = q->next;			  rsize -= PBUF_POOL_BUFSIZE;		  }		  r->next = NULL;		  ASSERT("pbuf_alloc: pbuf->payload properly aligned",				  ((uint32_t)p->payload % MEM_ALIGNMENT) == 0);		  break;	  case PBUF_RAM:		  /* If pbuf is to be allocated in RAM, allocate memory for it. */		  p = (struct pbuf*)mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + size + offset));		  if(p == NULL)		  { return NULL; }		  /* Set up internal structure of the pbuf. */		  p->payload = MEM_ALIGN((void *)((uint8_t *)p + sizeof(struct pbuf) + offset));		  p->len = p->tot_len = size;		  p->next = NULL;		  p->flags = PBUF_FLAG_RAM;		  ASSERT("pbuf_alloc: pbuf->payload properly aligned",				  ((uint32_t)p->payload % MEM_ALIGNMENT) == 0);		  break;	  case PBUF_ROM:		  /* If the pbuf should point to ROM, we only need to allocate			 memory for the pbuf structure. */		  p = (struct pbuf*)memp_mallocp(MEMP_PBUF);		  if(p == NULL) {			  return NULL;//.........这里部分代码省略.........
开发者ID:1573472562,项目名称:netfpga,代码行数:101,


示例13: DEBUG

bool QSICCD::Connect(){    bool connected;    DEBUG(INDI::Logger::DBG_SESSION, "Attempting to find QSI CCD...");    try    {        QSICam.get_Connected(&connected);    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "Error: get_Connected() failed. %s.", err.what());        return false;    }    if (!connected)    {        try        {            QSICam.put_Connected(true);        }        catch (std::runtime_error err)        {            DEBUGF(INDI::Logger::DBG_ERROR, "Error: put_Connected(true) failed. %s.", err.what());            return false;        }    }    bool hasST4Port = false;    try    {        QSICam.get_CanPulseGuide(&hasST4Port);    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "get_canPulseGuide() failed. %s.", err.what());        return false;    }    try    {        QSICam.get_CanAbortExposure(&canAbort);    }    catch (std::runtime_error err)    {        DEBUGF(INDI::Logger::DBG_ERROR, "get_CanAbortExposure() failed. %s.", err.what());        return false;    }    uint32_t cap = CCD_CAN_BIN | CCD_CAN_SUBFRAME | CCD_HAS_COOLER | CCD_HAS_SHUTTER;    if (canAbort)        cap |= CCD_CAN_ABORT;    if (hasST4Port)        cap |= CCD_HAS_ST4_PORT;    SetCCDCapability(cap);    /* Success! */    DEBUG(INDI::Logger::DBG_SESSION, "CCD is online. Retrieving basic data.");    return true;}
开发者ID:rrogge,项目名称:indi,代码行数:64,


示例14: curl_global_init

/** * curl_global_init() globally initializes cURL given a bitwise set of the * different features of what to initialize. */CURLcode curl_global_init(long flags){  if(initialized++)    return CURLE_OK;  /* Setup the default memory functions here (again) */  Curl_cmalloc = (curl_malloc_callback)malloc;  Curl_cfree = (curl_free_callback)free;  Curl_crealloc = (curl_realloc_callback)realloc;  Curl_cstrdup = (curl_strdup_callback)system_strdup;  Curl_ccalloc = (curl_calloc_callback)calloc;#if defined(WIN32) && defined(UNICODE)  Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;#endif  if(flags & CURL_GLOBAL_SSL)    if(!Curl_ssl_init()) {      DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed/n"));      return CURLE_FAILED_INIT;    }  if(flags & CURL_GLOBAL_WIN32)    if(win32_init() != CURLE_OK) {      DEBUGF(fprintf(stderr, "Error: win32_init failed/n"));      return CURLE_FAILED_INIT;    }#ifdef __AMIGA__  if(!Curl_amiga_init()) {    DEBUGF(fprintf(stderr, "Error: Curl_amiga_init failed/n"));    return CURLE_FAILED_INIT;  }#endif#ifdef NETWARE  if(netware_init()) {    DEBUGF(fprintf(stderr, "Warning: LONG namespace not available/n"));  }#endif#ifdef USE_LIBIDN  idna_init();#endif  if(Curl_resolver_global_init() != CURLE_OK) {    DEBUGF(fprintf(stderr, "Error: resolver_global_init failed/n"));    return CURLE_FAILED_INIT;  }#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT)  if(libssh2_init(0)) {    DEBUGF(fprintf(stderr, "Error: libssh2_init failed/n"));    return CURLE_FAILED_INIT;  }#endif  if(flags & CURL_GLOBAL_ACK_EINTR)    Curl_ack_eintr = 1;  init_flags  = flags;  return CURLE_OK;}
开发者ID:Angelcold,项目名称:curl,代码行数:67,


示例15: tcp_slowtmr

/*-----------------------------------------------------------------------------------*/voidtcp_slowtmr(void){  static struct tcp_pcb *pcb, *pcb2, *prev;  static struct tcp_seg *seg, *useg;  static uint32_t eff_wnd;  static uint8_t pcb_remove;      /* flag if a PCB should be removed */  ++tcp_ticks;  /* Steps through all of the active PCBs. */  prev = NULL;  pcb = tcp_active_pcbs;  while(pcb != NULL) {    ASSERT("tcp_timer_coarse: active pcb->state != CLOSED", pcb->state != CLOSED);    ASSERT("tcp_timer_coarse: active pcb->state != LISTEN", pcb->state != LISTEN);    ASSERT("tcp_timer_coarse: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);    pcb_remove = 0;    if(pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {      ++pcb_remove;    } else if(pcb->nrtx == TCP_MAXRTX) {      ++pcb_remove;    } else {      ++pcb->rtime;      seg = pcb->unacked;      if(seg != NULL && pcb->rtime >= pcb->rto) {        DEBUGF(TCP_RTO_DEBUG, ("tcp_timer_coarse: rtime %ld pcb->rto %d/n",                               tcp_ticks - pcb->rtime, pcb->rto));	/* Double retransmission time-out unless we are trying to           connect to somebody (i.e., we are in SYN_SENT). */	if(pcb->state != SYN_SENT) {	  pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];	}        /* Move all other unacked segments to the unsent queue. */        if(seg->next != NULL) {          for(useg = seg->next; useg->next != NULL; useg = useg->next);          /* useg now points to the last segment on the unacked queue. */          useg->next = pcb->unsent;          pcb->unsent = seg->next;          seg->next = NULL;          pcb->snd_nxt = ntohl(pcb->unsent->tcphdr->seqno);        }	/* Do the actual retransmission. */        tcp_rexmit_seg(pcb, seg);        /* Reduce congestion window and ssthresh. */        eff_wnd = MIN(pcb->cwnd, pcb->snd_wnd);        pcb->ssthresh = eff_wnd >> 1;        if(pcb->ssthresh < pcb->mss) {          pcb->ssthresh = pcb->mss * 2;        }        pcb->cwnd = pcb->mss;        DEBUGF(TCP_CWND_DEBUG, ("tcp_rexmit_seg: cwnd %u ssthresh %u/n",                                pcb->cwnd, pcb->ssthresh));      }    }
开发者ID:1573472562,项目名称:netfpga,代码行数:64,


示例16: iec_raw_write

/* * Write bytes to the drive via the CBM default protocol. * Returns number of successful written bytes or 0 on error. */static uint16_tiec_raw_write(uint16_t len, uint8_t flags){    uint8_t atn, talk, data;    uint16_t rv;    rv = len;    atn = flags & XUM_WRITE_ATN;    talk = flags & XUM_WRITE_TALK;    eoi = 0;    DEBUGF(DBG_INFO, "cwr %d, atn %d, talk %d/n", len, atn, talk);    if (len == 0)        return 0;    usbInitIo(len, ENDPOINT_DIR_OUT);    /*     * First, check if any device is present on the bus.     * If ATN and RST are both low (active), we know that at least one     * drive is attached but none are powered up. In this case, we     * bail out early. Otherwise, we'd get stuck in wait_for_listener().     */    if (!iec_wait_timeout_2ms(IO_ATN|IO_RESET, 0)) {        DEBUGF(DBG_ERROR, "write: no devs on bus/n");        usbIoDone();        return 0;    }    iec_release(IO_DATA);    iec_set(IO_CLK | (atn ? IO_ATN : 0));    IEC_DELAY();    // Wait for any device to pull data after we set CLK. This is actually    // IEC_T_AT (1 ms) but we allow a bit longer.    if (!iec_wait_timeout_2ms(IO_DATA, IO_DATA)) {        DEBUGF(DBG_ERROR, "write: no devs/n");        iec_release(IO_CLK | IO_ATN);        usbIoDone();        return 0;    }    /*     * Wait a short while for drive to be ready for us to release CLK.     * This uses the typical value for IEC_T_NE. Even though it has no     * minimum, the transfer starts to be unreliable for Tne somewhere     * below 10 us.     */    DELAY_US(IEC_T_NE);    // Respond with data as soon as device is ready (max time Tne, 200 us).    while (len != 0) {        // Be sure DATA line has been pulled by device. If not, we timed        // out without a device being ready.        if (!iec_get(IO_DATA)) {            DEBUGF(DBG_ERROR, "write: dev not pres/n");            rv = 0;            break;        }        // Release CLK and wait forever for listener to release data.        if (!wait_for_listener()) {            DEBUGF(DBG_ERROR, "write: w4l abrt/n");            rv = 0;            break;        }        /*         * Signal EOI by waiting so long (IEC_T_YE, > 200 us) that         * listener pulls DATA, then wait for it to be released.         * The device will do so in IEC_T_EI, >= 60 us.         *         * If we're not signalling EOI, we must set CLK (below) in less         * than 200 us after wait_for_listener() (IEC_T_RY).         */        if (len == 1 && !atn) {            iec_wait_timeout_2ms(IO_DATA, IO_DATA);            iec_wait_timeout_2ms(IO_DATA, 0);        }        iec_set(IO_CLK);        // Get a data byte from host, quitting if it signalled an abort.        if (usbRecvByte(&data) != 0) {            rv = 0;            break;        }        if (send_byte(data)) {            len--;            DELAY_US(IEC_T_BB);        } else {            DEBUGF(DBG_ERROR, "write: io err/n");            rv = 0;            break;        }        wdt_reset();//.........这里部分代码省略.........
开发者ID:Flaviowebit,项目名称:openCBM,代码行数:101,


示例17: main

int main(int argc, char *argv[]){    int fd, fd_dec;    int res, datasize,i;    int nb_frames = 0;#ifdef DUMP_RAW_FRAMES     char filename[15];    int fd_out;#endif    int32_t outbuf[2048];    uint16_t fs,sps,h;    uint32_t packet_count;    COOKContext q;    RMContext rmctx;    RMPacket pkt;    memset(&q,0,sizeof(COOKContext));    memset(&rmctx,0,sizeof(RMContext));    memset(&pkt,0,sizeof(RMPacket));    if (argc != 2) {        DEBUGF("Incorrect number of arguments/n");        return -1;    }    fd = open(argv[1],O_RDONLY);    if (fd < 0) {        DEBUGF("Error opening file %s/n", argv[1]);        return -1;    }        /* copy the input rm file to a memory buffer */    uint8_t * filebuf = (uint8_t *)calloc((int)filesize(fd),sizeof(uint8_t));    res = read(fd,filebuf,filesize(fd));      fd_dec = open_wav("output.wav");    if (fd_dec < 0) {        DEBUGF("Error creating output file/n");        return -1;    }    res = real_parse_header(fd, &rmctx);    packet_count = rmctx.nb_packets;    rmctx.audio_framesize = rmctx.block_align;    rmctx.block_align = rmctx.sub_packet_size;    fs = rmctx.audio_framesize;    sps= rmctx.block_align;    h = rmctx.sub_packet_h;    cook_decode_init(&rmctx,&q);        /* change the buffer pointer to point at the first audio frame */    advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE);    while(packet_count)    {          rm_get_packet(&filebuf, &rmctx, &pkt);        //DEBUGF("total frames = %d packet count = %d output counter = %d /n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt);        for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)        {             /* output raw audio frames that are sent to the decoder into separate files */#ifdef DUMP_RAW_FRAMES               snprintf(filename,sizeof(filename),"dump%d.raw",++x);              fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND, 0666);              write(fd_out,pkt.frames[i],sps);                close(fd_out);#endif            nb_frames = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i] , rmctx.block_align);            rmctx.frame_number++;            res = write(fd_dec,outbuf,datasize);                }        packet_count -= rmctx.audio_pkt_cnt;        rmctx.audio_pkt_cnt = 0;    }    close_wav(fd_dec, &rmctx, &q);    close(fd);  return 0;}
开发者ID:CrashSerious,项目名称:rockbox_psgroove,代码行数:77,


示例18: iec_raw_read

static uint16_tiec_raw_read(uint16_t len){    uint8_t ok, bit, b;    uint16_t to, count;    DEBUGF(DBG_INFO, "crd %d/n", len);    usbInitIo(len, ENDPOINT_DIR_IN);    count = 0;    do {        to = 0;        /* wait for clock to be released. typically times out during: */        /* directory read */        while (iec_get(IO_CLK)) {            if (to >= 50000 || !TimerWorker()) {                /* 1.0 (50000 * 20us) sec timeout */                DEBUGF(DBG_ERROR, "rd to/n");                usbIoDone();                return 0;            }            to++;            DELAY_US(20);        }        // XXX is this right? why treat EOI differently here?        if (eoi) {            usbIoDone();            return 0;        }        /* release DATA line */        iec_release(IO_DATA);        /* use special "timer with wait for clock" */        iec_wait_clk();        // Is the talking device signalling EOI?        if (iec_get(IO_CLK) == 0) {            eoi = 1;            iec_set(IO_DATA);            DELAY_US(70);            iec_release(IO_DATA);        }        /*         * Disable IRQs to make sure the byte transfer goes uninterrupted.         * This isn't strictly needed since the only interrupt we use is the         * one for USB control transfers.         */        cli();        // Wait up to 2 ms for CLK to be asserted        ok = iec_wait_timeout_2ms(IO_CLK, IO_CLK);        // Read all 8 bits of a byte        for (bit = b = 0; bit < 8 && ok; bit++) {            // Wait up to 2 ms for CLK to be released            ok = iec_wait_timeout_2ms(IO_CLK, 0);            if (ok) {                b >>= 1;                if (iec_get(IO_DATA) == 0)                    b |= 0x80;                // Wait up to 2 ms for CLK to be asserted                ok = iec_wait_timeout_2ms(IO_CLK, IO_CLK);            }        }        sei();        if (ok) {            // Acknowledge byte received ok            iec_set(IO_DATA);            // Send the data byte to host, quitting if it signalled an abort.            if (usbSendByte(b))                break;            count++;            DELAY_US(50);        }        wdt_reset();    } while (count != len && ok && !eoi);    if (!ok) {        DEBUGF(DBG_ERROR, "read io err/n");        count = 0;    }    DEBUGF(DBG_INFO, "rv=%d/n", count);    usbIoDone();    return count;}
开发者ID:Flaviowebit,项目名称:openCBM,代码行数:94,


示例19: if

void QHYCCD::updateTemperature(){    double ccdtemp=0,coolpower=0;    double nextPoll=POLLMS;    if (sim)    {        ccdtemp = TemperatureN[0].value;        if (TemperatureN[0].value < TemperatureRequest)            ccdtemp += TEMP_THRESHOLD;        else if (TemperatureN[0].value > TemperatureRequest)            ccdtemp -= TEMP_THRESHOLD;        coolpower = 128;    }    else    {        ccdtemp = GetQHYCCDParam(camhandle,CONTROL_CURTEMP);        coolpower = GetQHYCCDParam(camhandle,CONTROL_CURPWM);        ControlQHYCCDTemp(camhandle,TemperatureRequest);    }    DEBUGF(INDI::Logger::DBG_DEBUG, "CCD Temp: %g CCD RAW Cooling Power: %g, CCD Cooling percentage: %g", ccdtemp, coolpower, coolpower / 255.0 * 100);    TemperatureN[0].value = ccdtemp;    CoolerN[0].value = coolpower / 255.0 * 100;    if (coolpower > 0 && CoolerS[0].s == ISS_OFF)    {        CoolerNP.s = IPS_BUSY;        CoolerSP.s = IPS_OK;        CoolerS[0].s = ISS_ON;        CoolerS[1].s = ISS_OFF;        IDSetSwitch(&CoolerSP, NULL);    }    else if (coolpower <= 0 && CoolerS[0].s == ISS_ON)    {        CoolerNP.s = IPS_IDLE;        CoolerSP.s = IPS_IDLE;        CoolerS[0].s = ISS_OFF;        CoolerS[1].s = ISS_ON;        IDSetSwitch(&CoolerSP, NULL);    }    if (TemperatureNP.s == IPS_BUSY && fabs(TemperatureN[0].value - TemperatureRequest) <= TEMP_THRESHOLD)    {        TemperatureN[0].value = TemperatureRequest;        TemperatureNP.s = IPS_OK;    }/*    //we need call ControlQHYCCDTemp every second to control temperature    if (TemperatureNP.s == IPS_BUSY)        nextPoll = TEMPERATURE_BUSY_MS;*/    IDSetNumber(&TemperatureNP, NULL);    IDSetNumber(&CoolerNP, NULL);    temperatureID = IEAddTimer(nextPoll,QHYCCD::updateTemperatureHelper, this);}
开发者ID:jochym,项目名称:indilib,代码行数:62,


示例20: pciauto_setup_device

void pciauto_setup_device(struct pci_controller *hose,			  pci_dev_t dev, int bars_num,			  struct pci_region *mem,			  struct pci_region *prefetch,			  struct pci_region *io){	unsigned int bar_response;	pci_addr_t bar_value;	pci_size_t bar_size;	unsigned int cmdstat = 0;	struct pci_region *bar_res;	int bar, bar_nr = 0;	int found_mem64 = 0;	pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);	cmdstat = (cmdstat & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) | PCI_COMMAND_MASTER;	for (bar = PCI_BASE_ADDRESS_0; bar < PCI_BASE_ADDRESS_0 + (bars_num*4); bar += 4) {		/* Tickle the BAR and get the response */		pci_hose_write_config_dword(hose, dev, bar, 0xffffffff);		pci_hose_read_config_dword(hose, dev, bar, &bar_response);		/* If BAR is not implemented go to the next BAR */		if (!bar_response)			continue;		found_mem64 = 0;		/* Check the BAR type and set our address mask */		if (bar_response & PCI_BASE_ADDRESS_SPACE) {			bar_size = ((~(bar_response & PCI_BASE_ADDRESS_IO_MASK))				   & 0xffff) + 1;			bar_res = io;			DEBUGF("PCI Autoconfig: BAR %d, I/O, size=0x%llx, ", bar_nr, (u64)bar_size);		} else {			if ( (bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==			     PCI_BASE_ADDRESS_MEM_TYPE_64) {				u32 bar_response_upper;				u64 bar64;				pci_hose_write_config_dword(hose, dev, bar+4, 0xffffffff);				pci_hose_read_config_dword(hose, dev, bar+4, &bar_response_upper);				bar64 = ((u64)bar_response_upper << 32) | bar_response;				bar_size = ~(bar64 & PCI_BASE_ADDRESS_MEM_MASK) + 1;				found_mem64 = 1;			} else {				bar_size = (u32)(~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1);			}			if (prefetch && (bar_response & PCI_BASE_ADDRESS_MEM_PREFETCH))				bar_res = prefetch;			else				bar_res = mem;			DEBUGF("PCI Autoconfig: BAR %d, Mem, size=0x%llx, ", bar_nr, (u64)bar_size);		}		if (pciauto_region_allocate(bar_res, bar_size, &bar_value) == 0) {			/* Write it out and update our limit */			pci_hose_write_config_dword(hose, dev, bar, (u32)bar_value);			if (found_mem64) {				bar += 4;#ifdef CONFIG_SYS_PCI_64BIT				pci_hose_write_config_dword(hose, dev, bar, (u32)(bar_value>>32));#else				/*				 * If we are a 64-bit decoder then increment to the				 * upper 32 bits of the bar and force it to locate				 * in the lower 4GB of memory.				 */				pci_hose_write_config_dword(hose, dev, bar, 0x00000000);#endif			}			cmdstat |= (bar_response & PCI_BASE_ADDRESS_SPACE) ?				PCI_COMMAND_IO : PCI_COMMAND_MEMORY;		}		DEBUGF("/n");		bar_nr++;	}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:84,


示例21: isSimulation

bool QHYCCD::Connect(){    sim = isSimulation();    int ret;    uint32_t cap;    if (sim)    {        cap = CCD_CAN_SUBFRAME | CCD_CAN_ABORT | CCD_CAN_BIN | CCD_HAS_COOLER | CCD_HAS_ST4_PORT;        SetCCDCapability(cap);        HasUSBTraffic = true;        HasUSBSpeed = true;        HasGain = true;        HasOffset = true;        HasFilters = true;        return true;    }    camhandle = OpenQHYCCD(camid);    if(camhandle != NULL)    {        DEBUGF(INDI::Logger::DBG_SESSION, "Connected to %s.",camid);        cap = CCD_CAN_ABORT | CCD_CAN_SUBFRAME | CCD_HAS_STREAMING;        ret = InitQHYCCD(camhandle);        if(ret != QHYCCD_SUCCESS)        {            DEBUGF(INDI::Logger::DBG_ERROR, "Error: Init Camera failed (%d)", ret);            return false;        }        ret = IsQHYCCDControlAvailable(camhandle,CAM_MECHANICALSHUTTER);        if(ret == QHYCCD_SUCCESS)        {            cap |= CCD_HAS_SHUTTER;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Shutter Control: %s", cap & CCD_HAS_SHUTTER ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_COOLER);        if(ret == QHYCCD_SUCCESS)        {            cap |= CCD_HAS_COOLER;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Cooler Control: %s", cap & CCD_HAS_COOLER ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_ST4PORT);        if(ret == QHYCCD_SUCCESS)        {            cap |= CCD_HAS_ST4_PORT;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Guider Port Control: %s", cap & CCD_HAS_ST4_PORT  ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_SPEED);        if(ret == QHYCCD_SUCCESS)        {            HasUSBSpeed = true;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "USB Speed Control: %s", HasUSBSpeed ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_GAIN);        if(ret == QHYCCD_SUCCESS)        {            HasGain = true;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Gain Control: %s", HasGain ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_OFFSET);        if(ret == QHYCCD_SUCCESS)        {            HasOffset = true;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Offset Control: %s", HasOffset ? "True" : "False");        ret = IsQHYCCDControlAvailable(camhandle,CONTROL_CFWPORT);        if(ret == QHYCCD_SUCCESS)        {            HasFilters = true;        }        DEBUGF(INDI::Logger::DBG_DEBUG, "Has Filters: %s", HasFilters ? "True" : "False");        // Using software binning        cap |= CCD_CAN_BIN;        camxbin = 1;        camybin = 1;        /*ret = IsQHYCCDControlAvailable(camhandle,CAM_BIN1X1MODE);//.........这里部分代码省略.........
开发者ID:jochym,项目名称:indilib,代码行数:101,


示例22: ares_init_options

int ares_init_options(ares_channel *channelptr, struct ares_options *options,                      int optmask){  ares_channel channel;  int i;  int status = ARES_SUCCESS;  struct timeval now;#ifdef CURLDEBUG  const char *env = getenv("CARES_MEMDEBUG");  if (env)    curl_memdebug(env);  env = getenv("CARES_MEMLIMIT");  if (env) {    char *endptr;    long num = strtol(env, &endptr, 10);    if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))      curl_memlimit(num);  }#endif  if (ares_library_initialized() != ARES_SUCCESS)    return ARES_ENOTINITIALIZED;  channel = malloc(sizeof(struct ares_channeldata));  if (!channel) {    *channelptr = NULL;    return ARES_ENOMEM;  }  now = ares__tvnow();  /* Set everything to distinguished values so we know they haven't   * been set yet.   */  channel->flags = -1;  channel->timeout = -1;  channel->tries = -1;  channel->ndots = -1;  channel->rotate = -1;  channel->udp_port = -1;  channel->tcp_port = -1;  channel->socket_send_buffer_size = -1;  channel->socket_receive_buffer_size = -1;  channel->nservers = -1;  channel->ndomains = -1;  channel->nsort = -1;  channel->tcp_connection_generation = 0;  channel->lookups = NULL;  channel->domains = NULL;  channel->sortlist = NULL;  channel->servers = NULL;  channel->sock_state_cb = NULL;  channel->sock_state_cb_data = NULL;  channel->sock_create_cb = NULL;  channel->sock_create_cb_data = NULL;  channel->last_server = 0;  channel->last_timeout_processed = (time_t)now.tv_sec;  memset(&channel->local_dev_name, 0, sizeof(channel->local_dev_name));  channel->local_ip4 = 0;  memset(&channel->local_ip6, 0, sizeof(channel->local_ip6));  /* Initialize our lists of queries */  ares__init_list_head(&(channel->all_queries));  for (i = 0; i < ARES_QID_TABLE_SIZE; i++)    {      ares__init_list_head(&(channel->queries_by_qid[i]));    }  for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)    {      ares__init_list_head(&(channel->queries_by_timeout[i]));    }  /* Initialize configuration by each of the four sources, from highest   * precedence to lowest.   */  if (status == ARES_SUCCESS) {    status = init_by_options(channel, options, optmask);    if (status != ARES_SUCCESS)      DEBUGF(fprintf(stderr, "Error: init_by_options failed: %s/n",                     ares_strerror(status)));  }  if (status == ARES_SUCCESS) {    status = init_by_environment(channel);    if (status != ARES_SUCCESS)      DEBUGF(fprintf(stderr, "Error: init_by_environment failed: %s/n",                     ares_strerror(status)));  }  if (status == ARES_SUCCESS) {    status = init_by_resolv_conf(channel);    if (status != ARES_SUCCESS)      DEBUGF(fprintf(stderr, "Error: init_by_resolv_conf failed: %s/n",                     ares_strerror(status)));  }  /*//.........这里部分代码省略.........
开发者ID:337240552,项目名称:node,代码行数:101,


示例23: _search_parent_process

static int_search_parent_process(ParentCtx *ctx){	assert(ctx != NULL);	assert(ctx->child_pid > 0);	assert(ctx->outfd > 0);	assert(ctx->errfd > 0);	fd_set rfds;	Buffer outbuf;	Buffer errbuf;	ReaderArgs reader_args;	int lc = 0;	int status = PROCESS_STATUS_OK;	DEBUG("search", "Initializing parent process.");	buffer_init(&outbuf, 4096);	buffer_init(&errbuf, 4096);	_search_reader_args_init(&reader_args, &ctx->filter_args, ctx->user_data);	DEBUGF("search", "Reading data from child process (pid=%ld).", ctx->child_pid);	int maxfd = (ctx->errfd > ctx->outfd ? ctx->errfd : ctx->outfd) + 1;	while(status == PROCESS_STATUS_OK)	{		FD_ZERO(&rfds);		FD_SET(ctx->outfd, &rfds);		FD_SET(ctx->errfd, &rfds);		ssize_t bytes;		ssize_t sum = 0;		do		{			sum = 0;			if(select(maxfd, &rfds, NULL, NULL, NULL) > 0)			{				if(FD_ISSET(ctx->outfd, &rfds))				{					reader_args.buffer = &outbuf;					reader_args.cb = ctx->found_file;					reader_args.filter = true;					while(status == PROCESS_STATUS_OK && (bytes = buffer_fill_from_fd(&outbuf, ctx->outfd, 512)) > 0)					{						status = _search_process_lines_from_buffer(&reader_args);						TRACEF("search", "Received %ld byte(s) from stdout, read %d line(s) from stdout buffer.", bytes, reader_args.count);						if(status == PROCESS_STATUS_OK)						{							if(INT32_MAX - reader_args.count >= lc)							{								lc += reader_args.count;							}							else							{								ERROR("search", "Integer overflow.");							}						}						if(SSIZE_MAX - bytes >= sum)						{							sum += bytes;						}					}				}				if(FD_ISSET(ctx->errfd, &rfds))				{					reader_args.buffer = &errbuf;					reader_args.cb = ctx->err_message;					reader_args.filter = false;					while(status == PROCESS_STATUS_OK && (bytes = buffer_fill_from_fd(&errbuf, ctx->errfd, 512)) > 0)					{						TRACEF("search", "Read %ld byte(s) from stderr.", bytes);						_search_process_lines_from_buffer(&reader_args);						if(SSIZE_MAX - sum >= bytes)						{							sum += bytes;						}					}				}			}		} while(status == PROCESS_STATUS_OK && sum);		if(status == PROCESS_STATUS_STOP || status == PROCESS_STATUS_ERROR)		{			_search_kill_child(ctx->child_pid);		}		status = _search_wait_for_child(ctx, status);	}//.........这里部分代码省略.........
开发者ID:20centaurifux,项目名称:efind,代码行数:101,


示例24: init_by_resolv_conf

//.........这里部分代码省略.........    fp = fopen(PATH_RESOLV_CONF, "r");    if (fp) {      while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)      {        if ((p = try_config(line, "domain", ';')))          status = config_domain(channel, p);        else if ((p = try_config(line, "lookup", ';')) && !channel->lookups)          status = config_lookup(channel, p, "bind", "file");        else if ((p = try_config(line, "search", ';')))          status = set_search(channel, p);        else if ((p = try_config(line, "nameserver", ';')) &&                 channel->nservers == -1)          status = config_nameserver(&servers, &nservers, p);        else if ((p = try_config(line, "sortlist", ';')) &&                 channel->nsort == -1)          status = config_sortlist(&sortlist, &nsort, p);        else if ((p = try_config(line, "options", ';')))          status = set_options(channel, p);        else          status = ARES_SUCCESS;        if (status != ARES_SUCCESS)          break;      }      fclose(fp);    }    else {      error = ERRNO;      switch(error) {      case ENOENT:      case ESRCH:        status = ARES_EOF;        break;      default:        DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s/n",                       error, strerror(error)));        DEBUGF(fprintf(stderr, "Error opening file: %s/n", PATH_RESOLV_CONF));        status = ARES_EFILE;      }    }    if ((status == ARES_EOF) && (!channel->lookups)) {      /* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */      fp = fopen("/etc/nsswitch.conf", "r");      if (fp) {        while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)        {          if ((p = try_config(line, "hosts:", '/0')) && !channel->lookups)            /* ignore errors */            (void)config_lookup(channel, p, "dns", "files");        }        fclose(fp);      }      else {        error = ERRNO;        switch(error) {        case ENOENT:        case ESRCH:          status = ARES_EOF;          break;        default:          DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s/n",                         error, strerror(error)));          DEBUGF(fprintf(stderr, "Error opening file: %s/n", "/etc/nsswitch.conf"));          status = ARES_EFILE;        }      }
开发者ID:337240552,项目名称:node,代码行数:67,


示例25: Curl_ssh_connect

//.........这里部分代码省略.........  /*   * At this point we have an authenticated ssh session.   */  conn->sockfd = sock;  conn->writesockfd = CURL_SOCKET_BAD;  if (conn->protocol == PROT_SFTP) {    /*     * Start the libssh2 sftp session     */    ssh->sftp_session = libssh2_sftp_init(ssh->ssh_session);    if (ssh->sftp_session == NULL) {      failf(data, "Failure initialising sftp session/n");      libssh2_sftp_shutdown(ssh->sftp_session);      ssh->sftp_session = NULL;      libssh2_session_free(ssh->ssh_session);      ssh->ssh_session = NULL;      return CURLE_FAILED_INIT;    }    /*     * Get the "home" directory     */    i = libssh2_sftp_realpath(ssh->sftp_session, ".", tempHome, PATH_MAX-1);    if (i > 0) {      /* It seems that this string is not always NULL terminated */      tempHome[i] = '/0';      ssh->homedir = (char *)strdup(tempHome);      if (!ssh->homedir) {        libssh2_sftp_shutdown(ssh->sftp_session);        ssh->sftp_session = NULL;        libssh2_session_free(ssh->ssh_session);        ssh->ssh_session = NULL;        return CURLE_OUT_OF_MEMORY;      }    }    else {      /* Return the error type */      i = libssh2_sftp_last_error(ssh->sftp_session);      DEBUGF(infof(data, "error = %d/n", i));    }  }  /* Check for /~/ , indicating realative to the users home directory */  if (conn->protocol == PROT_SCP) {    real_path = (char *)malloc(working_path_len+1);    if (real_path == NULL) {      Curl_safefree(working_path);      libssh2_session_free(ssh->ssh_session);      ssh->ssh_session = NULL;      return CURLE_OUT_OF_MEMORY;    }    if (working_path[1] == '~')      /* It is referenced to the home directory, so strip the leading '/' */      memcpy(real_path, working_path+1, 1 + working_path_len-1);    else      memcpy(real_path, working_path, 1 + working_path_len);  }  else if (conn->protocol == PROT_SFTP) {    if (working_path[1] == '~') {      real_path = (char *)malloc(strlen(ssh->homedir) +                                 working_path_len + 1);      if (real_path == NULL) {        libssh2_sftp_shutdown(ssh->sftp_session);        ssh->sftp_session = NULL;        libssh2_session_free(ssh->ssh_session);        ssh->ssh_session = NULL;        Curl_safefree(working_path);        return CURLE_OUT_OF_MEMORY;      }      /* It is referenced to the home directory, so strip the leading '/' */      memcpy(real_path, ssh->homedir, strlen(ssh->homedir));      real_path[strlen(ssh->homedir)] = '/';      real_path[strlen(ssh->homedir)+1] = '/0';      if (working_path_len > 3) {        memcpy(real_path+strlen(ssh->homedir)+1, working_path + 3,               1 + working_path_len -3);      }    }    else {      real_path = (char *)malloc(working_path_len+1);      if (real_path == NULL) {        libssh2_session_free(ssh->ssh_session);        ssh->ssh_session = NULL;        Curl_safefree(working_path);        return CURLE_OUT_OF_MEMORY;      }      memcpy(real_path, working_path, 1+working_path_len);    }  }  else    return CURLE_FAILED_INIT;  Curl_safefree(working_path);  ssh->path = real_path;  *done = TRUE;  return CURLE_OK;}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:101,


示例26: buffer_handle

/* Buffer data for the given handle.   Return whether or not the buffering should continue explicitly.  */static bool buffer_handle(int handle_id){    logf("buffer_handle(%d)", handle_id);    struct memory_handle *h = find_handle(handle_id);    bool stop = false;    if (!h)        return true;    if (h->filerem == 0) {        /* nothing left to buffer */        return true;    }    if (h->fd < 0)  /* file closed, reopen */    {        if (*h->path)            h->fd = open(h->path, O_RDONLY);        if (h->fd < 0)        {            /* could not open the file, truncate it where it is */            h->filesize -= h->filerem;            h->filerem = 0;            return true;        }        if (h->offset)            lseek(h->fd, h->offset, SEEK_SET);    }    trigger_cpu_boost();    if (h->type == TYPE_ID3)    {        if (!get_metadata((struct mp3entry *)(buffer + h->data), h->fd, h->path))        {            /* metadata parsing failed: clear the buffer. */            memset(buffer + h->data, 0, sizeof(struct mp3entry));        }        close(h->fd);        h->fd = -1;        h->filerem = 0;        h->available = sizeof(struct mp3entry);        h->widx += sizeof(struct mp3entry);        send_event(BUFFER_EVENT_FINISHED, &h->id);        return true;    }    while (h->filerem > 0 && !stop)    {        /* max amount to copy */        size_t copy_n = MIN( MIN(h->filerem, BUFFERING_DEFAULT_FILECHUNK),                             buffer_len - h->widx);        ssize_t overlap;        uintptr_t next_handle = ringbuf_offset(h->next);        /* stop copying if it would overwrite the reading position */        if (ringbuf_add_cross(h->widx, copy_n, buf_ridx) >= 0)            return false;        /* FIXME: This would overwrite the next handle         * If this is true, then there's a handle even though we have still         * data to buffer. This should NEVER EVER happen! (but it does :( ) */        if (h->next && (overlap                = ringbuf_add_cross(h->widx, copy_n, next_handle)) > 0)        {            /* stop buffering data for now and post-pone buffering the rest */            stop = true;            DEBUGF( "%s(): Preventing handle corruption: h1.id:%d h2.id:%d"                    " copy_n:%lu overlap:%ld h1.filerem:%lu/n", __func__,                    h->id, h->next->id, (unsigned long)copy_n, overlap,                    (unsigned long)h->filerem);            copy_n -= overlap;        }        /* rc is the actual amount read */        int rc = read(h->fd, &buffer[h->widx], copy_n);        if (rc < 0)        {            /* Some kind of filesystem error, maybe recoverable if not codec */            if (h->type == TYPE_CODEC) {                logf("Partial codec");                break;            }            DEBUGF("File ended %ld bytes early/n", (long)h->filerem);            h->filesize -= h->filerem;            h->filerem = 0;            break;        }        /* Advance buffer */        h->widx = ringbuf_add(h->widx, rc);        if (h == cur_handle)            buf_widx = h->widx;//.........这里部分代码省略.........
开发者ID:a-martinez,项目名称:rockbox,代码行数:101,



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


C++ DEBUGFS_ADD函数代码示例
C++ DEBUGASSERT函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。