Esempio n. 1
0
void I2sAnalyzer::WorkerThread()
{
	//UpArrow, DownArrow
	if( mSettings->mDataValidEdge == AnalyzerEnums::NegEdge )
		mArrowMarker = AnalyzerResults::DownArrow;
	else
		mArrowMarker = AnalyzerResults::UpArrow;

	mClock = GetAnalyzerChannelData( mSettings->mClockChannel );
	mFrame = GetAnalyzerChannelData( mSettings->mFrameChannel );
	mData = GetAnalyzerChannelData( mSettings->mDataChannel );

	SetupForGettingFirstBit();
	SetupForGettingFirstFrame();

	for( ; ; )
	{
		GetFrame();
		AnalyzeFrame();

		mResults->CommitResults();
		ReportProgress( mClock->GetSampleNumber() );
		CheckIfThreadShouldExit();
	}

}
Esempio n. 2
0
void JtagAnalyzer::WorkerThread()
{
	Setup();

	mState = JtagReset;
	mFirstSample = mTCK->GetSampleNumber();
	mDataIn = mDataOut = 0;
	mBits = 0;

	if (mTCK->GetBitState() != 0) {
		mTCK->AdvanceToNextEdge();
	}

	for ( ; ; ) {
		mTCK->AdvanceToNextEdge();
		mCurrentSample = mTCK->GetSampleNumber();

		ProcessStep();

		mTCK->AdvanceToNextEdge();

		CheckIfThreadShouldExit();
	}

	delete mInnerAnalyzer;
}
void ManchesterAnalyzer::SynchronizeManchester()
{
	//we should already be on an edge, the first one out of idle.
	while( mSynchronized == false )
	{
		CheckIfThreadShouldExit();
		U64 edge_location = mManchester->GetSampleNumber();
		mManchester->AdvanceToNextEdge();
		U64 next_edge_location = mManchester->GetSampleNumber();
		U64 edge_distance = next_edge_location - edge_location;
		if( ( edge_distance > ( mT - mTError ) ) && ( edge_distance < ( mT + mTError ) ) ) //short
		{
			mUnsyncedLocations.push_back( edge_location );
		}
		else if( ( edge_distance > ( (2*mT) - mTError ) ) && ( edge_distance < ( (2*mT) + mTError ) ) ) //long
		{
			mUnsyncedLocations.push_back( edge_location );
			mSynchronized = true;
			BitState current_bit_state = mManchester->GetBitState();
			bool inverted = mSettings->mInverted;
			U32 bit_value = 0;
			if( ( inverted == true ) && ( current_bit_state == BIT_LOW ) ) //we are on a neg edge with inverted true
				bit_value = 1;	//the old marker will be the opposite of the current value.
			else if( ( inverted == true ) && ( current_bit_state == BIT_HIGH ) )
				bit_value = 0;
			else if( ( inverted == false ) && ( current_bit_state == BIT_LOW ) ) //we are on a neg edge with inverted false
				bit_value = 0;
			else if( ( inverted == false ) && ( current_bit_state == BIT_HIGH ) )
				bit_value = 1;
			std::vector<U64> locations_to_save;
			while( mUnsyncedLocations.size() > 0 )
			{
				locations_to_save.push_back( mUnsyncedLocations.back() );
				mUnsyncedLocations.pop_back();
				if( mUnsyncedLocations.size() > 0 )
					mUnsyncedLocations.pop_back();
			}
			std::sort( locations_to_save.begin(), locations_to_save.end() );
			U32 count = locations_to_save.size();
			for( U32 i = 0; i < count; ++i )
				SaveBit( locations_to_save[i], bit_value );
			break;
		}
		else
		{
			//back to idle.
			Invalidate();
		}
	}
}
void ManchesterAnalyzer::SynchronizeDifferential()
{
	while( mSynchronized == false )
	{
		CheckIfThreadShouldExit();
		U64 edge_location = mManchester->GetSampleNumber();
		mManchester->AdvanceToNextEdge();
		U64 next_edge_location = mManchester->GetSampleNumber();
		U64 edge_distance = next_edge_location - edge_location;
		if( ( edge_distance > ( mT - mTError ) ) && ( edge_distance < ( mT + mTError ) ) ) //short
		{
			mUnsyncedLocations.push_back( edge_location );
		}
		else if( ( edge_distance > ( (2*mT) - mTError ) ) && ( edge_distance < ( (2*mT) + mTError ) ) ) //long
		{
			mUnsyncedLocations.push_back( edge_location );
			mSynchronized = true;

			bool last_bit_one = false;
			if( mUnsyncedLocations.size() % 2 == 1 )
				last_bit_one = true;
			std::vector<U64> locations_to_save;
			while( mUnsyncedLocations.size() > 0 )
			{
				locations_to_save.push_back( mUnsyncedLocations.back() );
				mUnsyncedLocations.pop_back();
				if( mUnsyncedLocations.size() > 0 )
					mUnsyncedLocations.pop_back();
			}
			std::sort( locations_to_save.begin(), locations_to_save.end() );
			U32 count = locations_to_save.size();
			for( U32 i = 0; i < count; ++i )
			{
				if( ( i == 0 ) && ( last_bit_one == true ) )
					SaveBit( locations_to_save[i], 1 );
				else
					SaveBit( locations_to_save[i], 0 );
			}

			SaveBit( next_edge_location, 1 );
			break;
		}
		else
		{
			//back to idle.
			Invalidate();
		}
	}
}
void ManchesterAnalyzer::SynchronizeBiPhase()
{
	while( mSynchronized == false )
	{
		CheckIfThreadShouldExit();
		U64 edge_location = mManchester->GetSampleNumber();
		mManchester->AdvanceToNextEdge();
		U64 next_edge_location = mManchester->GetSampleNumber();
		U64 edge_distance = next_edge_location - edge_location;
		if( ( edge_distance > ( mT - mTError ) ) && ( edge_distance < ( mT + mTError ) ) ) //short
		{
			mUnsyncedLocations.push_back( edge_location );
		}
		else if( ( edge_distance > ( (2*mT) - mTError ) ) && ( edge_distance < ( (2*mT) + mTError ) ) ) //long
		{
			mUnsyncedLocations.push_back( edge_location );
			mSynchronized = true;
			U32 bit_value = 0;
			if( mSettings->mMode == BI_PHASE_MARK ) //FM1
				bit_value = 1;
			else if( mSettings->mMode == BI_PHASE_SPACE ) //FM0
				bit_value = 0;

			std::vector<U64> locations_to_save;
			while( mUnsyncedLocations.size() > 0 )
			{
				locations_to_save.push_back( mUnsyncedLocations.back() );
				mUnsyncedLocations.pop_back();
				if( mUnsyncedLocations.size() > 0 )
					mUnsyncedLocations.pop_back();
			}
			std::sort( locations_to_save.begin(), locations_to_save.end() );
			U32 count = locations_to_save.size();
			for( U32 i = 0; i < count; ++i )
			{
				if( i == (count-1) )
					SaveBit( locations_to_save[i], bit_value ^ 0x1 );
				else
					SaveBit( locations_to_save[i], bit_value );
			}
			break;
		}
		else
		{
			//back to idle.
			Invalidate();
		}
	}
}
Esempio n. 6
0
void HD44780Analyzer::WorkerThread()
{
  U32 dbline;

  //get sample rate
	mSampleRateHz = GetSampleRate();

  //setup channels
	mE = GetAnalyzerChannelData( mSettings->mEChannel );
	mRS = GetAnalyzerChannelData( mSettings->mRSChannel );
	if( mSettings->mRWChannel != UNDEFINED_CHANNEL )
    mRW = GetAnalyzerChannelData( mSettings->mRWChannel );
	else mRW = NULL;
  for (dbline=0;dbline<8;dbline++)
    if( mSettings->mDBChannel[dbline] != UNDEFINED_CHANNEL )
      mDB[dbline] = GetAnalyzerChannelData( mSettings->mDBChannel[dbline] );
    else mDB[dbline] = NULL;

  //if we start high we need to move to low
	if( mE->GetBitState() == BIT_HIGH)
		mE->AdvanceToNextEdge();

  //we always start in 8-bit mode unless the force 4-bit mode option is selected
  //function set command can change modes
  bitmode8=!mSettings->mStartIn4BitMode;

  //reset between E high pulse measurements
  mLastEStart=0;

  //reset busy mode
  mWaitBusy=0;

  //get frames
	for( ; ; )
    {
      GetTransfer();
      CheckIfThreadShouldExit();
    }
}
Esempio n. 7
0
// ==============================================================================
// Main data parsing method
// ==============================================================================
void RFFEAnalyzer::WorkerThread() {
  U8 byte_count;

  mSampleRateHz = GetSampleRate();

  mSdata = GetAnalyzerChannelData(mSettings->mSdataChannel);
  mSclk = GetAnalyzerChannelData(mSettings->mSclkChannel);

  mResults->CancelPacketAndStartNewPacket();

  while (1) {
    try {
      // Look for an SSC
      // This method only returns false if there is no more data to be scanned
      // in which case, we call the Cancel and wait for new data method in the
      // API
      if (!FindStartSeqCondition()) {
        mResults->CancelPacketAndStartNewPacket();
        break;
      }

      // Find and parse the Slave Address and the RFFE Command
      // Return ByteCount field - depending on the command it may or may not be
      // relevent
      byte_count = FindCommandFrame();

      // We know what kind of packet we are handling now, and various parameters
      // including the number of data bytes.  Go ahead and handle the different
      // cases
      switch (mRffeCmdType) {
        case RFFEAnalyzerResults::RffeTypeExtWrite:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressField);
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeReserved:
          break;
        case RFFEAnalyzerResults::RffeTypeMasterRead:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressField);
          FindBusPark();
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeMasterWrite:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressField);
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeMasterHandoff:
          FindBusPark();
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeInterrupt:
          FindBusPark();
          if (FindISI()) {
            FindInterruptSlots();
          }
          break;
        case RFFEAnalyzerResults::RffeTypeExtRead:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressField);
          FindBusPark();
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeExtLongWrite:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressHiField);
          FindByteFrame(RFFEAnalyzerResults::RffeAddressLoField);
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeExtLongRead:
          FindByteFrame(RFFEAnalyzerResults::RffeAddressHiField);
          FindByteFrame(RFFEAnalyzerResults::RffeAddressLoField);
          FindBusPark();
          for (U32 i = 0; i <= byte_count; i += 1) {
            FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          }
          break;
        case RFFEAnalyzerResults::RffeTypeNormalWrite:
          FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          break;
        case RFFEAnalyzerResults::RffeTypeNormalRead:
          FindBusPark();
          FindByteFrame(RFFEAnalyzerResults::RffeDataField);
          break;
        case RFFEAnalyzerResults::RffeTypeWrite0:
          break;
      }

      // Finish up with a Bus Park (except for interrupts)
      if (mRffeCmdType != RFFEAnalyzerResults::RffeTypeInterrupt) {
        FindBusPark();
      }

    } catch (int exception) {
      if (exception == UNEXPECTED_SSC_EXCEPTION) {
        // Do nothing, this can happen
      }
    }

    // Commit the Result and call the API Required finished? method.
    mResults->CommitPacketAndStartNewPacket();
    CheckIfThreadShouldExit();
  }
}
Esempio n. 8
0
void SerialAnalyzer::WorkerThread()
{
	mSampleRateHz = GetSampleRate();
	ComputeSampleOffsets();
	U32 num_bits = mSettings->mBitsPerTransfer;

	if( mSettings->mSerialMode != SerialAnalyzerEnums::Normal )
		num_bits++;

	if( mSettings->mInverted == false )
	{
		mBitHigh = BIT_HIGH;
		mBitLow = BIT_LOW;
	}else
	{
		mBitHigh = BIT_LOW;
		mBitLow = BIT_HIGH;
	}

	U64 bit_mask = 0;
	U64 mask = 0x1ULL;
	for( U32 i=0; i<num_bits; i++ )
	{
		bit_mask |= mask;
		mask <<= 1;
	}
	
	mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
	mSerial->TrackMinimumPulseWidth();
	
	if( mSerial->GetBitState() == mBitLow )
		mSerial->AdvanceToNextEdge();

	for( ; ; )
	{
		//we're starting high.  (we'll assume that we're not in the middle of a byte. 

		mSerial->AdvanceToNextEdge();

		//we're now at the beginning of the start bit.  We can start collecting the data.
		U64 frame_starting_sample = mSerial->GetSampleNumber();

		U64 data = 0;
		bool parity_error = false;
		bool framing_error = false;
		bool mp_is_address = false;
		
		DataBuilder data_builder;
		data_builder.Reset( &data, mSettings->mShiftOrder, num_bits );
		U64 marker_location = frame_starting_sample;

		for( U32 i=0; i<num_bits; i++ )
		{
			mSerial->Advance( mSampleOffsets[i] );
			data_builder.AddBit( mSerial->GetBitState() );

			marker_location += mSampleOffsets[i];
			mResults->AddMarker( marker_location, AnalyzerResults::Dot, mSettings->mInputChannel );
		}

		if( mSettings->mInverted == true )
			data = (~data) & bit_mask;

		if( mSettings->mSerialMode != SerialAnalyzerEnums::Normal )
		{
			//extract the MSB
			U64 msb = data >> (num_bits - 1);
			msb &= 0x1;
			if( mSettings->mSerialMode == SerialAnalyzerEnums::MpModeMsbOneMeansAddress )
			{
				if( msb == 0x0 )
					mp_is_address = false;
				else
					mp_is_address = true;
			}
			if( mSettings->mSerialMode == SerialAnalyzerEnums::MpModeMsbZeroMeansAddress )
			{
				if( msb == 0x0 )
					mp_is_address = true;
				else
					mp_is_address = false;
			}
			//now remove the msb.
			data &= ( bit_mask >> 1 );
		}
			
		parity_error = false;

		if( mSettings->mParity != AnalyzerEnums::None )
		{
			mSerial->Advance( mParityBitOffset );
			bool is_even = AnalyzerHelpers::IsEven( AnalyzerHelpers::GetOnesCount( data ) );

			if( mSettings->mParity == AnalyzerEnums::Even )
			{
				if( is_even == true )
				{
					if( mSerial->GetBitState() != mBitLow ) //we expect a low bit, to keep the parity even.
						parity_error = true;
				}else
				{
					if( mSerial->GetBitState() != mBitHigh ) //we expect a high bit, to force parity even.
						parity_error = true;
				}
			}else  //if( mSettings->mParity == AnalyzerEnums::Odd )
			{
				if( is_even == false )
				{
					if( mSerial->GetBitState() != mBitLow ) //we expect a low bit, to keep the parity odd.
						parity_error = true;
				}else
				{
					if( mSerial->GetBitState() != mBitHigh ) //we expect a high bit, to force parity odd.
						parity_error = true;
				}
			}

			marker_location += mParityBitOffset;
			mResults->AddMarker( marker_location, AnalyzerResults::Square, mSettings->mInputChannel );
		}

		//now we must dermine if there is a framing error.
		framing_error = false;

		mSerial->Advance( mStartOfStopBitOffset );

		if( mSerial->GetBitState() != mBitHigh )
		{
			framing_error = true;
		}else
		{
			U32 num_edges = mSerial->Advance( mEndOfStopBitOffset );
			if( num_edges != 0 )
				framing_error = true;
		}

		if( framing_error == true )
		{
			marker_location += mStartOfStopBitOffset;
			mResults->AddMarker( marker_location, AnalyzerResults::ErrorX, mSettings->mInputChannel );

			if( mEndOfStopBitOffset != 0 )
			{
				marker_location += mEndOfStopBitOffset;
				mResults->AddMarker( marker_location, AnalyzerResults::ErrorX, mSettings->mInputChannel );
			}
		}

		//ok now record the value!
		//note that we're not using the mData2 or mType fields for anything, so we won't bother to set them.
		Frame frame;
		frame.mStartingSampleInclusive = frame_starting_sample;
		frame.mEndingSampleInclusive = mSerial->GetSampleNumber();
		frame.mData1 = data;
		frame.mFlags = 0;
		if( parity_error == true )
			frame.mFlags |= PARITY_ERROR_FLAG | DISPLAY_AS_ERROR_FLAG;

		if( framing_error == true )
			frame.mFlags |= FRAMING_ERROR_FLAG | DISPLAY_AS_ERROR_FLAG;

		if( mp_is_address == true )
			frame.mFlags |= MP_MODE_ADDRESS_FLAG;

		if( mp_is_address == true )
			mResults->CommitPacketAndStartNewPacket();

		mResults->AddFrame( frame );

		mResults->CommitResults();

		ReportProgress( frame.mEndingSampleInclusive );
		CheckIfThreadShouldExit();

		if( framing_error == true )  //if we're still low, let's fix that for the next round.
		{
			if( mSerial->GetBitState() == mBitLow )
				mSerial->AdvanceToNextEdge();
		}
	}
void ManchesterAnalyzer::WorkerThread()
{
	mManchester = GetAnalyzerChannelData( mSettings->mInputChannel );

	mSampleRateHz = this->GetSampleRate();

	double half_peroid = 1.0 / double( mSettings->mBitRate * 2 );
	half_peroid *= 1000000.0;
	mT = U32( ( mSampleRateHz * half_peroid ) / 1000000.0 );
	switch( mSettings->mTolerance )
	{
	case TOL25:
		mTError = mT / 2;
		break;
	case TOL5:
		mTError = mT / 10;
		break;
	case TOL05:
		mTError = mT / 100;
		break;
	}
	if( mTError < 3 )
		mTError = 3;
	//mTError = mT / 2;
	mSynchronized = false;
	//mResults->AddMarker( mManchester->GetSampleNumber(), AnalyzerResults::One, mSettings->mInputChannel );
	mManchester->AdvanceToNextEdge();
	mBitsForNextByte.clear();
	mUnsyncedLocations.clear();
	mIgnoreBitCount = mSettings->mBitsToIgnore;


	for( ; ; )
	{
		switch( mSettings->mMode )
		{
		case MANCHESTER:
			{
				SynchronizeManchester();
				ProcessManchesterData();
			}
			break;
		case DIFFERENTIAL_MANCHESTER:
			{
				SynchronizeDifferential();
				ProcessDifferential();
			}
			break;
		case BI_PHASE_MARK:
			{
				SynchronizeBiPhase();
				ProcessBiPhaseData();
			}
			break;
		case BI_PHASE_SPACE:
			{
				SynchronizeBiPhase();
				ProcessBiPhaseData();
			}
			break;
		}
		//mManchester->AdvanceToNextEdge();
		//mResults->CommitResults();
		ReportProgress( mManchester->GetSampleNumber() );
		CheckIfThreadShouldExit();

	}
}
void PS2KeyboardAnalyzer::WorkerThread()
{
	mData = GetAnalyzerChannelData( mSettings->mDataChannel );
	mClock = GetAnalyzerChannelData( mSettings->mClockChannel );

	//begin from here
	for( ; ; )
	{	
		//init all variables, these will be updated by the GetNextData function

		U64 DataPayload =0;
		U64 frame_starting_sample;
		U64 frame_ending_sample;
		
		bool DeviceTx = false;
		bool ParityError = false;
		bool ACKed = false;
		
		//get a data transmission
		GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
		
		Frame frame;	
		frame.mStartingSampleInclusive = frame_starting_sample;

		U8 flags =0x00;
		
		//begin to analyze the frame based on direction of transmission
		if(DeviceTx)
		{
			if(mSettings->mDeviceType==0)
			{
				//transmission is from Device->Host, device is keyboard
				flags = flags | TX_DEVICE_TO_HOST;
				
				bool EndOfFrame = false;

				while(!EndOfFrame)
				{
					if(DataPayload==0xE0)
					{
						//extended key code
						flags = flags | EXTENDED_KEY;
						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
						EndOfFrame=false;
					}
					else if (DataPayload==0xEE)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ECHO_FRAME;
						EndOfFrame = true;
					}
					else if (DataPayload==0xAA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = BAT_FRAME;
						EndOfFrame = true;
					}
					else if (DataPayload==0xFA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ACK_FRAME;
						EndOfFrame = true;
					}
					else if(DataPayload==0xF0)
					{
						//break code
						flags = flags | BREAK_CODE;
						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
						EndOfFrame=false;
					}
					else if(DataPayload==0xE1)
					{
						//Pause/break key
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[7] = {0x14,0x77,0xE1,0xF0,0x14,0xF0,0x77};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>6)
								finished=true;
						}

						if(finished)
							flags = flags | PAUSE_BREAK;
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else if(DataPayload==0x12 && (flags&EXTENDED_KEY))
					{
						//Print Screen Make
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[2] = {0xE0,0x7C};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>1)
								finished=true;
						}

						if(finished)
						{
							flags = flags | PRINT_SCREEN | MAKE_CODE;
						}
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else if(DataPayload==0x7C && flags&BREAK_CODE && flags&EXTENDED_KEY)
					{
						//Print Screen Break
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[3] = {0xE0,0xF0,0x12};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>2)
								finished=true;
						}

						if(finished)
						{
							flags = flags | PRINT_SCREEN | BREAK_CODE;
						}
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else
					{
						//value
						EndOfFrame=true;
					}
				}

				frame.mData1 = DataPayload;
			}
			else
			{
				//device is a mouse, transmission from device to house
				flags = flags | TX_DEVICE_TO_HOST;
		
					if(DataPayload==0xFA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ACK_FRAME;
					}
					else if (DataPayload==0xAA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = BAT_FRAME;
					}
					else if(DataPayload&0x08)
					{
						flags = flags | MOVEMENT_FRAME;

						U64 movement_packet[4] = {0x00, 0x00, 0x00, 0x00};
						movement_packet[0] = DataPayload;

						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[1], ParityError, ACKed);

						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[2], ParityError, ACKed);

						if(mSettings->mDeviceType==2)
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[3], ParityError, ACKed);					
						
						DataPayload = movement_packet[3]<<24 | movement_packet[2]<<16 | movement_packet[1]<<8 | movement_packet[0];
					}
					else
					{

					}
				frame.mData1 = DataPayload;
			}
		}
		else
		{
			//transmission is Host->Device
			flags = flags | TX_HOST_TO_DEVICE;
			frame.mData1 = DataPayload;

		}
		frame.mFlags = flags;
		frame.mEndingSampleInclusive = frame_ending_sample;
		
		mResults->AddFrame(frame);
		mResults->CommitResults();

		ReportProgress( frame.mEndingSampleInclusive );
		CheckIfThreadShouldExit();

	}

}