예제 #1
0
QPpsAttributeList QPpsObjectPrivate::decodeArray(pps_decoder_t *decoder, bool *ok)
{
    QPpsAttributeList list;

    int length = pps_decoder_length(decoder);
    for (int i = 0; i < length; ++i) {
        // Force movement to a specific index.
        pps_decoder_error_t error = pps_decoder_goto_index(decoder, i);
        if (error != PPS_DECODER_OK) {
            qWarning() << "QPpsObjectPrivate::decodeArray: pps_decoder_goto_index failed";
            *ok = false;
            return QPpsAttributeList();
        }

        QPpsAttribute ppsAttribute = decodeData(decoder);
        if (!ppsAttribute.isValid()) {
            *ok = false;
            return QPpsAttributeList();
        }

        list << ppsAttribute;
    }

    *ok = true;
    return list;
}
예제 #2
0
QPpsAttributeMap QPpsObjectPrivate::decodeObject(pps_decoder_t *decoder, bool *ok)
{
    QPpsAttributeMap map;

    int length = pps_decoder_length(decoder);
    for (int i = 0; i < length; ++i) {
        // Force movement to a specific index.
        pps_decoder_error_t error = pps_decoder_goto_index(decoder, i);
        if (error != PPS_DECODER_OK) {
            qWarning() << "QPpsObjectPrivate::decodeObject: pps_decoder_goto_index failed";
            *ok = false;
            return QPpsAttributeMap();
        }
        QString name = QString::fromUtf8(pps_decoder_name(decoder));
        QPpsAttribute ppsAttribute = decodeData(decoder);
        if (!ppsAttribute.isValid()) {
            *ok = false;
            return QPpsAttributeMap();
        }
        map[name] = ppsAttribute;
    }

    *ok = true;
    return map;
}
예제 #3
0
/*
bool BufferedAudioSource::init(float* interleavedData, Int64 numSamples)
{
    return true;
}
*/
bool BufferedAudioSource::init(const RString& path, bool loadIntoMemory)
{
	if(loadIntoMemory)
	{
		RPRINT("loading sound into memory...\n");
        int channels = getNumChannels();
        double length = getLength();
		double srate = getSampleRate();
		UInt32 totalFrames = getSampleRate() * getLength();
		mBuffer.resize(getNumChannels(), totalFrames);
		float *pWritePos = mBuffer.getData();
		UInt32 numFrames = (UInt32)(getSampleRate());
		UInt32 framesRead = 0;
		UInt32 remainingFrames = totalFrames;
		UInt32 tf = 0;
		do
		{
            int version = 0;
			framesRead = decodeData(pWritePos, remainingFrames >= numFrames ? numFrames : remainingFrames, version);
			pWritePos += framesRead * getNumChannels();
			tf += framesRead;
			remainingFrames -= framesRead;
		}
		while(remainingFrames > 0 && framesRead > 0);
		mEOF = true;
		mLoadedInMemory = loadIntoMemory;
		mBuffer.resize(getNumChannels(), tf);
	}
	else
	{
		mBuffer = RAudioBuffer(getNumChannels(), 0);
	}

	return true;
}
예제 #4
0
bool BufferedAudioSource::init(const RString& path, bool loadIntoMemory) 
{ 
	if(loadIntoMemory)
	{
		//RPRINT("loading sound into memory...\n");
        int channels = getNumChannels();
        double length = getLength();
		mBuffer.resize(getNumChannels(), getSampleRate() * getLength());
		float *pWritePos = mBuffer.getData();
		UInt32 numFrames = (UInt32)(getSampleRate());
		UInt32 framesRead = 0;
		do
		{
			framesRead = decodeData(pWritePos, numFrames);
			pWritePos += framesRead * getNumChannels();
		}
		while(framesRead > 0);
		mLoadedInMemory = loadIntoMemory; 
		doneDecoding();
	}
	else
	{
        RScopedLock l(&mLock);
		mBuffer = RAudioBuffer(getNumChannels(), getSampleRate() * SECONDS_TO_BUFFER);
		BufferedAudioSourceThread::getInstance()->addSource(this);
	}

	return true;
}
예제 #5
0
void MainWindow::readRxChannel()
{
    QByteArray raw = rxTcpSocket->readAll();
    if (raw.size() > 0) {
        rxBytes += raw.size();
        decodeData(rxDecode, raw);
    }
}
void MessageBuilder::decodeMessageFields(String message,
	char& flags, String& address_from, String& address_to,
	char& type,char& sub_type,String& data){
		flags = decodeFlags(message);
		address_from =decodeAddressFrom(message);
		address_to =decodeAddressTo(message);
		type = decodeType(message);
		sub_type = decodeSubType(message);
		data = decodeData(message);
}
예제 #7
0
UEyeCaptureInterface::FramePair UEyeCaptureInterface::getFrame()
{
    CaptureStatistics  stats;
    PreciseTimer start = PreciseTimer::currentTime();
    FramePair result( NULL, NULL);

//    printf("Called getFrame\n");

    protectFrame.lock();
        decodeData(&leftCamera , currentLeft,  &(result.bufferLeft));
        decodeData(&rightCamera, currentRight, &(result.bufferRight));

        result.leftTimeStamp  = currentLeft->usecsTimeStamp();
        result.rightTimeStamp = currentRight->usecsTimeStamp();

        stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0;
        skippedCount = 0;

        stats.triggerSkipped = triggerSkippedCount;
        triggerSkippedCount = 0;

        int64_t internalDesync =  currentLeft->internalTimestamp - currentRight->internalTimestamp;
    protectFrame.unlock();

    stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow();
    stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay;

    int64_t desync =  result.leftTimeStamp - result.rightTimeStamp;
    stats.values[CaptureStatistics::DESYNC_TIME] = desync > 0 ? desync : -desync;
    stats.values[CaptureStatistics::INTERNAL_DESYNC_TIME] = internalDesync > 0 ? internalDesync : -internalDesync;

    /* Get temperature data */
    stats.temperature[0] = leftCamera.getTemperature();
    stats.temperature[1] = rightCamera.getTemperature();

    //stats.values[CaptureStatistics::DATA_SIZE] = currentLeft.bytesused;

    emit newStatisticsReady(stats);

//    printf("Finished getFrame\n");
    return result;
}
예제 #8
0
SNMPPdu::SNMPPdu(unsigned char *buf,int len,VariableBinding* vbs,int vbsmemlen) //��buffer��PDU����
{
    version = SNMPPdu::version2c;						   	//�汾��ֻ֧��V2c��v1����ݰ���V2c��ʽ����
	cmtylen = 6;
	memcpy(Community,"public",6);
	commond = SNMPPdu::GET;							//��ݰ�����
	requestID = rqid++;						//����ID
	if(rqid == 0) rqid = 1;
	errorStatus = SNMPPdu::SNMP_ERROR_SUCCESS;						//���״̬
	errorIndex = 0;						//�������
	isValid = true;
	
	variableBindings.variableBinding = vbs;
	variableBindings.vbsmemsize = vbsmemlen;
	if( decodeData(buf,len) )
	{
		isValid	= true;
	}
	else
	{
		isValid	= false;
	}
}
예제 #9
0
파일: dht11.c 프로젝트: jluzonpr/aerobal
void readDataBit(){
	if(dataBitReadStatus < 40){
	switch(bitTimingStatus){

		case 0:
			HWREG(GPIO_PORTB | GPIO_OFFSET_INTERRUPT_CLEAR) |= 0x02;
			bitEntryTime = count1uS;
			endTimeControlModule();
			bitTimingStatus = 1;
			break;
		case 1:
			HWREG(GPIO_PORTB | GPIO_OFFSET_INTERRUPT_CLEAR) |= 0x02;
			bitExitTime = count1uS;

			bitTimeElapsed();
			initTimeControlModule();

			bitTimingStatus = 0;
			count1uS = 0;
			break;

	}
	}
	else{
		convertTimetoBits();
		decodeData();
		IntDisable(INT_GPIOB);
		IntMasterDisable();
		IntDisable(INT_TIMER0A);
		TimerDisable(TIMER0_BASE, TIMER_A);
		TimerIntDisable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
		IntDisable(INT_TIMER1A);
		TimerDisable(TIMER1_BASE, TIMER_A);
		TimerIntDisable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
		dhtSetInactive();
	}
}
예제 #10
0
//Om det är 1 i början av filen packas filen upp på samma sätt som förut
//Annars läses storleken på frekvenstbellen in först och sen byte för byte värden som sedan sätts in i frekvenstabellen
void decompress(ibitstream& input, ostream& output) {
    map<int, int> freqTable;
    int testForSize = input.get();
    if(testForSize == '1'){
        bool switchSide = false;
        string value = "";
        string freq = "";
        decompressHelper(input,freqTable,value,freq,switchSide);
    }else{
        int inputSize = input.get();
        for(int i = 0; i < inputSize; ++i){
            char tempByte = input.get();
            int tempValue = tempByte;
            int tempFreq = input.get();
            --inputSize;    //Eftersom både frekvensen samt karaktären tagits ut minska inputSize
            freqTable.insert(make_pair(tempValue,tempFreq));
        }
        //Eftersom "endoffile" karaktären inte lades till om vi inte hade tal större än en byte läggs den till här
        freqTable.insert(make_pair(PSEUDO_EOF,1));
    }
    HuffmanNode* encodingTree = buildEncodingTree(freqTable);
    decodeData(input,encodingTree,output);
    freeTree(encodingTree);
}
예제 #11
0
파일: UPCScanner.c 프로젝트: limtbk/sandbox
int scanAndReadUPC(uint8_t *imgAddress, size_t imgHeight, size_t imgWidth, char *resultCString, int resultMaxLength)
{
    int resCStrLength = 0;
    
    unsigned char *imageBytes = imgAddress;
    
    int *scanDataArr = malloc(imgHeight*sizeof(int));
    
    for (int jj = 0; jj < imgHeight; jj++) {
        if (scanDataArr[jj]!=0) {
            scanDataArr[jj]=0;
        }
    }
    
    int scanThick = 2;
    scanHorizLine(scanDataArr, imageBytes, imgWidth, imgHeight, scanThick);

    drawHorizScanLine(imageBytes, imgWidth, imgHeight, scanThick);
    
    drawHorizHistogram(imageBytes, imgWidth, scanDataArr, imgHeight);
    
    int *scanDataDerivArr = malloc((imgHeight-1)*sizeof(int));
    
    int noiseThreshold = 150;

    derivative(scanDataArr, scanDataDerivArr, imgHeight);

    int *scanDataFilteredArr = malloc((imgHeight-1)*sizeof(int));

    noiseReduction(scanDataDerivArr, scanDataFilteredArr, imgHeight, noiseThreshold);
    free(scanDataDerivArr);

//    free(scanDataArr);
    
    int maxMinCount = concentrateData(scanDataFilteredArr, imgHeight);
    
    underivative(scanDataFilteredArr, scanDataArr, imgHeight);
    drawHorizHistogram(imageBytes, imgWidth, scanDataArr, imgHeight);
    
    free(scanDataArr);
    
    
    drawHorizLineHistogram(imageBytes, imgWidth, imgHeight, scanDataFilteredArr);
    
    int *extrDataArr = malloc(maxMinCount*sizeof(int));
    int *intrDataArr = malloc(maxMinCount*sizeof(int));
    
    extractChangepoints(extrDataArr, scanDataFilteredArr, imgHeight);
    free(scanDataFilteredArr);
    
    changepointsToIntervals(extrDataArr, intrDataArr, maxMinCount);
    maxMinCount--;
    
    //float maxMinThreshold = 4.625;
    float maxMinThreshold = 4.2;
    
    if (maxMinCount>2)
    {
        int js;
        int je;
        
        int absMin;
        int absMax;

        calcAbsMaxMin(intrDataArr, maxMinCount, &js, &je, &absMin, &absMax, maxMinThreshold);
        
        float avgMin = calcAvgMin(absMin, intrDataArr, je, js);
                
        int normDataLength = je - js + 1;
        int *normDataArr = malloc((normDataLength)*sizeof(int));
        
        normalize(avgMin, je, intrDataArr, js, normDataArr);
        
        
        int startLeft = -1;
        int endLeft = -1;
        int startRight = -1;
        int endRight = -1;
        startLeft = findLeftDataStart(normDataArr, normDataLength);
        
        endLeft = findLeftDataEnd(normDataArr, normDataLength, startLeft);
        
        if (endLeft+5 < normDataLength)
        {
            startRight = endLeft+5;
            if ((endLeft - startLeft) + startRight < normDataLength)
                endRight = (endLeft - startLeft) + startRight;
        }
        
        if (startLeft>=0)
            drawLine(imageBytes, imgWidth, imgHeight, extrDataArr[startLeft], 0, extrDataArr[startLeft], imgWidth);
        if (endLeft>=0)
            drawLine(imageBytes, imgWidth, imgHeight, extrDataArr[endLeft], 0, extrDataArr[endLeft], imgWidth);
        if (startRight>=0)
            drawLine(imageBytes, imgWidth, imgHeight, extrDataArr[startRight], 0, extrDataArr[startRight], imgWidth);
        if (endRight>=0)
            drawLine(imageBytes, imgWidth, imgHeight, extrDataArr[endRight], 0, extrDataArr[endRight], imgWidth);


        decodeData(&resCStrLength, resultCString, resultMaxLength, normDataArr, endLeft, startLeft);
        decodeData(&resCStrLength, resultCString, resultMaxLength, normDataArr, endRight, startRight);        
        free(normDataArr);

        
        char correctResult;
        
        correctResult = checkControlDigit(resultCString, resCStrLength);
        
        if (correctResult == 0) {
            resCStrLength = 0;
        }
    }

    free(extrDataArr);
    free(intrDataArr);
    return resCStrLength;
}
예제 #12
0
void decompress(ibitstream& input, ostream& output) {
    HuffmanNode* encodingTree = readHeader(input);
    decodeData(input, encodingTree, output);
    freeTree(encodingTree);
}
예제 #13
0
BOOL LLTemplateMessageReader::readMessage(const U8* buffer, 
										  const LLHost& sender)
{
	return decodeData(buffer, sender);
}
예제 #14
0
QString IrcMessagePrivate::decodeParam(int index) const
{
    return decodeData(parser.params().value(index));
}
예제 #15
0
	static void inputCaptureInterrupt()
	{
#ifndef ENHANCEDPRECISION
		// simple reset of the timer
		// (not accounting for past time)
		TCNT3 = 0;
#endif
		//------------------------------------------------
		// toggle input config to wait for the next "edge"
		//------------------------------------------------

		if(waitingOn == FALLING_EDGE)
		{
			waitingOn = RISING_EDGE;
			sbi(TCCR3B, ICES3);
			pulselevel = HIGH;
		}
		else
		{
			waitingOn = FALLING_EDGE;
			cbi(TCCR3B, ICES3);
			pulselevel = LOW;
		}

		uint16_t capturedCounter = ICR3;

#ifdef ENHANCEDPRECISION
		// account for the time spent since the input capture
		TCNT3 = TCNT3 - capturedCounter;
#endif

		// adjust

		// time in microseconds (us)
		pulseTime = capturedCounter/TIMER3DIVISION_FOR_US;

		switch(state)
		{
			default:
				signalError(21); // invalid internal state on input capture interrupt
				break;
			case stop_to_start_in:
				if(pulseTime < STOP2START_TIME_MIN_US)
				{
					errorAndResetDecoder(13); // invalid stop2start (too small)
#ifdef DEBUG_SUPPORT
					console::printP(STR_STOP2START_TIME_TOO_SMALL);
					console::printNumber(pulseTime);
					console::println(" us");
#endif
					break;
				}

				if(pulseTime > STOP2START_TIME_MAX_US)
				{
					// the timeout interrupt should catch this "case" instead
					// of here, but it is safer to handle it here as well
					errorAndResetDecoder(14); // invalid stop2start (too large)
					break;
				}

				state = start_in;
				break;

			case start_in:
			{
				if(pulselevel == LOW)
				{
					decodeBitLowTime = pulseTime;
					break;
				}

				uint16_t bittime = decodeBitLowTime + pulseTime;

				if(bittime < BIT_TIME_MIN_US ||
						bittime > BIT_TIME_MAX_US)
				{
					signalError(15);
					state = idle;	// invalid start bit
				}

				if(pulseTime < decodeBitLowTime)
				{
					signalError(16);
					state = idle;	// invalid start bit
				}

				state = data_in;
				initDecodeData();
				break;
			}
			case data_in:
			{
				ErrorStatus status = decodeData();

				switch(status)
				{
					case success:	state = idle; break;
					case failure: 	state = idle; break;
					case unfinished: break;
				}

				// the stop bit should trigger a timeout
				setTimeout(BIT_TIME_MAX_US);

				break;
			}
		}
	}
예제 #16
0
void CGPSDThread::run()
{
#if GPSD_API_MAJOR_VERSION >= 5
    gpsdata = new gps_data_t();
    if(gpsdata)
    {
        gps_open( "localhost", DEFAULT_GPSD_PORT, gpsdata );
    }
#else
    gpsdata = gps_open( "localhost", DEFAULT_GPSD_PORT );
#endif
    if( !gpsdata )
    {
        //        qDebug() << "gps_open failed.";
        return;
    }                            // if
    //    qDebug() << "connected to gpsd.";

    gps_stream( gpsdata, WATCH_NEWSTYLE, NULL );

    fd_set fds;

    while( true )
    {
        // sleep until either GPSD or our controlling thread has data for us.
        FD_ZERO(&fds);
        FD_SET(gpsdata->gps_fd, &fds);
        FD_SET(pipe_fd, &fds);
        int nfds = (pipe_fd > gpsdata->gps_fd ? pipe_fd : gpsdata->gps_fd) + 1;
        int data = select(nfds, &fds, NULL, NULL, NULL);

        if( data == -1 )
        {
            break;
        }                        // if

        else if( data )
        {
            if( FD_ISSET( pipe_fd, &fds ) )
            {
                //                qDebug() << "stop command received";
                char s;
                read( pipe_fd, &s, 1 );
                break;
            }                    // if
            else if( FD_ISSET( gpsdata->gps_fd, &fds ) )
            {
#if GPSD_API_MAJOR_VERSION >= 5
                gps_read( gpsdata );
#else
                gps_poll( gpsdata );
#endif
                if( !decodeData() ) break;
            }                    // else if
        }                        // else if
    }                            // while

    gps_close( gpsdata );
#if GPSD_API_MAJOR_VERSION >= 5
    delete gpsdata;
#endif
    //    qDebug() << "thread done";
}
예제 #17
0
bool UHokuyo::receiveData()
{
  bool gotData = false;
  int n, i = 0;
  char * dend = NULL;
  UTime t;
  bool gotRngData = false;
  const int MSL = 500;
  char s[MSL];
  //
  if (modeSimulated)
  {
    //gotData = receiveSimulatedData(&length);
    Wait(0.1);
  }
  else
  {
    if (dataCnt > 0)
    { // test for old data
      if (dataTime.getTimePassed() > 1.0)
      {
        printf("Discarded '%s'\n", dataBuf);
        for (n = 0; n < dataCnt; n++)
          printf("%02x,", dataBuf[n]);
        printf("\n");
        printf("Discarded %d bytes of old data\n", dataCnt);
        statBadCnt++;
        dataCnt = 0;
      }
    }
    lock();
    if (isPortOpen())
    {
      // set timeout to ~30 ms
      n = receiveFromDevice(&dataBuf[dataCnt], MAX_DATA_LNG - dataCnt - 1, 0.015);
      if (/*repeatGetScan and*/ (n > 0))
      { // request more data
        requestMoreData();
      }
      //if (n > 0)
      //  printf("(%d bytes)", n);
    }
    else
      n = 0;
    unlock();
    if (n > 0)
    {
      dataCnt += n;
      dataBuf[dataCnt] = '\0';
      dend = strstr(dataBuf, "\n\n");
      // debug
/*      if (verbose and (datalog != NULL))
      { // log the received part of the buffer
       dataBuf[n] = '\0';
       fprintf(datalog, "%4d (n=%3d) got:'%s'\n", dataCnt, n, dataBuf);
      }*/
      // debug end
      gotData = (dend != NULL);
    }
  }
  //
  while (gotData)
  { // message length
    badSeries++;
    n = dend - dataBuf;
    // debug
    if (n > dataCnt)
    {
      printf("UHokuyo::receiveData message end found after buffer end? n=%d dataCnt=%d\n", n, dataCnt);
    }
    if (verbose)
    {
      snprintf(s, MSL, "In %d 'gotData' dataCnt=%d n=%d  %c%c%c%c%c%c%c%c%c... after %g sec\n", i, dataCnt, n,
            dataBuf[0], dataBuf[1], dataBuf[2],dataBuf[3], dataBuf[4], dataBuf[5], dataBuf[6], dataBuf[7], dataBuf[8],
            dataTime.getTimePassed());
      laslog.toLog("urg:", s);
    }
    //printf("msg:%s", dataBuf);
    i++;
    // debug end
    switch (dataBuf[0])
    {
    case 'V':
      dend[1] = '\0';
      if (dataBuf[1] == '\n')
      { // some garbage may also start with a V
        if (versionInfoCnt < 5 or verbose)
          printf("Got version (%d) info ((grp %d) %d chars):'%s'\n", versionInfoCnt, i, dataCnt, dataBuf);
        decodeName(dataBuf);
        versionInfoCnt++;
        if (verbose)
          laslog.toLog(" - V:", &dataBuf[4]);
      }
      break;
    case 'G':
      if (dataBuf[10] != '0')
      { // must be '0 to be valid scandata
        // printf("Bad data set laser may be off (bdSeries=%d) - send an on-command (\\nL1\\n)\n", badSeries);
        sendToDevice("\nL1\n", 4);
        break;
      }
      badSeries = 0;
      if (lasData == NULL)
        lasData = new ULaserData();
      if (lasData != NULL)
      { // save data into decoded buffer
        lasData->lock();
        lasData->setDeviceNum(deviceNum);
        gotRngData = decodeData(dataBuf, n, lasData);
        lasData->setMaxValidRange(maxValidRange);
        //if (repeatGetScan and not gotRngData)
        //{ // error message - request new data
        //  // send request for more data right away
        //  lock();
        //  //sendToDevice("00038401\n", 9);
        //  //sendToDevice("00076801\n", 9);
        //  unlock();
        //}
        if (gotRngData)
          statGoodCnt++;
        lasData->setMirror(mirrorData);
        lasData->unlock();
        //
        if (gotRngData)
          // do pending push commands.
          // No need to set data as locked, as
          // a client scanGet may use data at the same time as a scanpush,
          // as none of these will modify the 'lasData' structure.
          gotNewScan(lasData);
        if (verbose)
        { // debug logging
          snprintf(s, MSL, "UHokuyo::receiveData: scan=%6s %drngs In %2d msgCnt=%4d/%4d : %c%c%c%c%c%c%c%c%c %c %c%c... after %g sec\n",
            bool2str(gotRngData), lasData->getRangeCnt(),  i, n, dataCnt,
            dataBuf[0], dataBuf[1], dataBuf[2],dataBuf[3], dataBuf[4], dataBuf[5], dataBuf[6], dataBuf[7], dataBuf[8],
            dataBuf[10], dataBuf[12], dataBuf[13],
            dataTime.getTimePassed());
          laslog.toLog(" - G:", s);
          // to screen also
          printf("%s", s);
        }
        dataTime.Now();
      }
      break;
    default:
      // got error
      // discard to first newline
/*      char * nl = strchr(dataBuf, '\n');
      if (nl < dend and nl > dataBuf)
      { // newline found,
        // set new data end (dend) to one earlier, as if it was
        // a real "\n\n" command termination.
        // this is to avoid a situation where OK scans
        // are part of an error-respond.
        dend = --nl;
      }*/
      // close string and restart
      dend[1] = '\0';
      // debug
      if (verbose)
      {
        snprintf(s, MSL, "UHokuyo::receiveData: garbage msg %4d of %4d chars in buffer:'%c%c%c...'\n", n, dataCnt, dataBuf[0], dataBuf[1], dataBuf[2]);
        laslog.toLog(" - ", s);
      }
      //printf("UHokuyo::receiveData: ignored garbage (%d chars):'%s'\n", dataCnt, dataBuf);
      //rp = true; //repeatGetScan;
      // no other than G???... should be
      // received in repeat mode, well
      //    sometimes a LFLF is in the error message
      //repeatGetScan = false;
        /*closePort();
        printf("Got unknown garbage:--------Closing port\n");
        Wait(0.2);
        if (rp)
        { // repeat is enabled - request dummy data
          printf("-------------restarting in repeat mode\n");
          getNewestData(NULL, 0, false);
          //repeatGetScan = true;
        }*/
      statBadCnt++;
      break;
    }
    // discard the used (or unknown) data
    n = dataCnt - (dend - dataBuf) - 2;
    memmove(dataBuf, dend + 2,  n);
    // reduce available data count
    dataCnt = n;
    dataBuf[dataCnt] = '\0';
    // test for more data in buffer
    gotData = dataCnt > 3;
    if (gotData)
    { // is it a full message
      dend = strstr(dataBuf, "\n\n");
      gotData = (dend != NULL);
      //printf("****Got more messages in one read (OK, but indicate latency)\n");
    }
  }
  return gotRngData;
}
예제 #18
0
 void
 decodeData(Data& data, const uint8_t *input, size_t inputLength)
 {
   size_t dummyBeginOffset, dummyEndOffset;
   decodeData(data, input, inputLength, &dummyBeginOffset, &dummyEndOffset);
 }
예제 #19
0
V4L2CaptureInterface::FramePair V4L2CaptureInterface::getFrame()
{

//    SYNC_PRINT(("V4L2CaptureInterface::getFrame(): called\n"));
    CaptureStatistics  stats;

    PreciseTimer start = PreciseTimer::currentTime();
    FramePair result;

    protectFrame.lock();
    G12Buffer **results[MAX_INPUTS_NUMBER] = {
            &result.buffers[LEFT_FRAME ].g12Buffer,
            &result.buffers[RIGHT_FRAME].g12Buffer,
            &result.buffers[LEFT_FRAME ].g12Buffer,
            &result.buffers[RIGHT_FRAME].g12Buffer,

    };

    result.setRgbBufferRight(NULL);
    result.setRgbBufferLeft (NULL);

    //SYNC_PRINT(("LF:%s RF:%s\n",
    //           currentFrame[Frames::LEFT_FRAME ].isFilled ? "filled" : "empty" ,
    //           currentFrame[Frames::RIGHT_FRAME].isFilled ? "filled" : "empty"));

    for (int i = 0; i < MAX_INPUTS_NUMBER; i++)
    {
        decodeData(&camera[i],  &currentFrame[i],  results[i]);

        if ((*results[i]) == NULL) {
            SYNC_PRINT(("V4L2CaptureInterface::getFrame(): Precrash condition\n"));
        }
    }

    if (currentFrame[LEFT_FRAME].isFilled)
        result.setTimeStampLeft (currentFrame[LEFT_FRAME].usecsTimeStamp());

    if (currentFrame[RIGHT_FRAME].isFilled)
        result.setTimeStampRight   (currentFrame[RIGHT_FRAME].usecsTimeStamp());

    if (skippedCount == 0)
    {
        //SYNC_PRINT(("Warning: Requested same frames twice. Is this by design?\n"));
    }

    stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0;
    skippedCount = 0;
    protectFrame.unlock();

    stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow();
    stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay;

    int64_t desync =  currentFrame[LEFT_FRAME].usecsTimeStamp() - currentFrame[RIGHT_FRAME].usecsTimeStamp();
    stats.values[CaptureStatistics::DESYNC_TIME] = desync > 0 ? desync : -desync;
    stats.values[CaptureStatistics::DATA_SIZE] = currentFrame[LEFT_FRAME].bytesused;

    if (imageInterfaceReceiver != NULL) {
        imageInterfaceReceiver->newStatisticsReadyCallback(stats);
    }

    return result;
}
예제 #20
0
void WatchItem::parseHelper(const GdbMi &input)
{
    setChildrenUnneeded();

    GdbMi mi = input["type"];
    if (mi.isValid())
        setType(mi.data());

    editvalue = input["editvalue"].data();
    editformat = DebuggerDisplay(input["editformat"].toInt());
    editencoding = DebuggerEncoding(input["editencoding"].data());

    mi = input["valueelided"];
    if (mi.isValid())
        elided = mi.toInt();

    mi = input["bitpos"];
    if (mi.isValid())
        bitpos = mi.toInt();

    mi = input["bitsize"];
    if (mi.isValid())
        bitsize = mi.toInt();

    mi = input["origaddr"];
    if (mi.isValid())
        origaddr = mi.toAddress();

    mi = input["address"];
    if (mi.isValid()) {
        address = mi.toAddress();
        if (exp.isEmpty()) {
            if (iname.startsWith("local.") && iname.count('.') == 1)
                // Solve one common case of adding 'class' in
                // *(class X*)0xdeadbeef for gdb.
                exp = name.toLatin1();
            else
                exp = "*(" + gdbQuoteTypes(type) + "*)" + hexAddress();
        }
    }

    mi = input["value"];
    QByteArray enc = input["valueencoded"].data();
    if (mi.isValid() || !enc.isEmpty()) {
        setValue(decodeData(mi.data(), enc));
    } else {
        setValueNeeded();
    }

    mi = input["size"];
    if (mi.isValid())
        size = mi.toInt();

    mi = input["exp"];
    if (mi.isValid())
        exp = mi.data();

    mi = input["valueenabled"];
    if (mi.data() == "true")
        valueEnabled = true;
    else if (mi.data() == "false")
        valueEnabled = false;

    mi = input["valueeditable"];
    if (mi.data() == "true")
        valueEditable = true;
    else if (mi.data() == "false")
        valueEditable = false;

    mi = input["numchild"]; // GDB/MI
    if (mi.isValid())
        setHasChildren(mi.toInt() > 0);
    mi = input["haschild"]; // native-mixed
    if (mi.isValid())
        setHasChildren(mi.toInt() > 0);

    mi = input["arraydata"];
    if (mi.isValid()) {
        DebuggerEncoding encoding(input["arrayencoding"].data());
        QByteArray childType = input["childtype"].data();
        decodeArrayData(this, mi.data(), encoding, childType);
    } else {
        const GdbMi children = input["children"];
        if (children.isValid()) {
            bool ok = false;
            // Try not to repeat data too often.
            const GdbMi childType = input["childtype"];
            const GdbMi childNumChild = input["childnumchild"];

            qulonglong addressBase = input["addrbase"].data().toULongLong(&ok, 0);
            qulonglong addressStep = input["addrstep"].data().toULongLong(&ok, 0);

            for (int i = 0, n = int(children.children().size()); i != n; ++i) {
                const GdbMi &subinput = children.children().at(i);
                WatchItem *child = new WatchItem;
                if (childType.isValid())
                    child->setType(childType.data());
                if (childNumChild.isValid())
                    child->setHasChildren(childNumChild.toInt() > 0);
                GdbMi name = subinput["name"];
                QByteArray nn;
                if (name.isValid()) {
                    nn = name.data();
                    child->name = QString::fromLatin1(nn);
                } else {
                    nn.setNum(i);
                    child->name = QString::fromLatin1("[%1]").arg(i);
                }
                GdbMi iname = subinput["iname"];
                if (iname.isValid())
                    child->iname = iname.data();
                else
                    child->iname = this->iname + '.' + nn;
                if (addressStep) {
                    child->address = addressBase + i * addressStep;
                    child->exp = "*(" + gdbQuoteTypes(child->type) + "*)" + child->hexAddress();
                }
                QByteArray key = subinput["key"].data();
                if (!key.isEmpty())
                    child->name = decodeData(key, subinput["keyencoded"].data());
                child->parseHelper(subinput);
                appendChild(child);
            }
        }
    }
}