示例#1
0
int TestMod11B(PDOT11_MOD_ARGS pArgs)
{
    MDL                                 Mdl;
    PACKET_BASE                         Packet;
    DOT11B_PLCP_TXVECTOR                Dot11BTxVector;
    Dot11BTxVector.PreambleType         = DOT11B_PLCP_IS_LONG_PREAMBLE;
    Dot11BTxVector.ModSelect            = DOT11B_PLCP_IS_CCK;

    if (!Dot11BRate_KbpsValid(pArgs->nBitRate))
    {
        printf("Data rate %d kbps is not supported by 802.11b mode\n", pArgs->nBitRate);
        return -1;
    }
    Dot11BTxVector.DateRate = Dot11BDataRate_Kbps2Code(pArgs->nBitRate);

    // Measure modulation speed
    const int RUN_TIMES = 100;
	ULONGLONG ts1 = SoraGetCPUTimestamp ( &tsinfo );
    for (int ii = 0; ii < RUN_TIMES; ii++)
    {
        if (PreparePacket(pArgs->pcInFileName, &Mdl, &Packet, DataBuffer, (PUCHAR)SymbolBuffer, SAMPLE_BUFFER_SIZE) < 0)
            return -1;
        // Note: BB11BPMDPacketGenSignal() will modify Packet.pMdl and Packet.pReserved (data crc)
        //   so if run multiple times, please reload these data before calling it.
        BB11BPMDPacketGenSignal(&Packet, &Dot11BTxVector, (PUCHAR)TempBuffer, sizeof(TempBuffer)/sizeof(COMPLEX8));
    }
	ULONGLONG ts2 = SoraGetCPUTimestamp ( &tsinfo );

    printf("Signal data rate:    %d kbps\n", Dot11BDataRate_Code2Kbps(Dot11BTxVector.DateRate));
    printf("Signal packet size:  %d\n", Packet.PacketSize);
    printf("Signal encoded size: %d\n", Packet.Reserved3);
    printf("Time cost average:   %.3f us \n", SoraTimeElapsed (ts2-ts1, &tsinfo) * 1.0 / 1000 / RUN_TIMES);

    FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
    pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
    if (!pOut)
    {
        printf("Cannot create output file.\n");
        return -1;
    }

    fwrite(Packet.pReserved, Packet.Reserved3, 1, pOut);
    fclose(pOut);

    return 0;
}
示例#2
0
BOOLEAN RxThread ( void * pParam ) {
	ulong& err = BB11aDemodCtx.CF_Error::error_code();
	
	while (test_count) {
		BB11aDemodCtx.Reset ();
		ssrc->Reset ();
		if ( err != E_ERROR_SUCCESS ) {
			printf ( "Reset error (%X)!\n", err );
		} 

		FB_11A_DemodBuffer(ssrc);
		
		if (  err == E_ERROR_FRAME_OK ) {	
	//    	printf("Time cost average:   %.3fus \n", SoraTimeElapsed (tts2-tts1, &tsinfo) * 1.0 / 1000 );		
	//		printf ( "one good frame\n" );
			if ( test_count == TEST_NUM ) {
				printf ( "one good frame - data rate %d frame length %d\n", 
                    BB11aDemodCtx.CF_11aRxVector::data_rate_kbps(),
                    BB11aDemodCtx.CF_11aRxVector::frame_length() 
                );
				tts1 = SoraGetCPUTimestamp ( &tsinfo );
			}
		} else {	
			printf ( "error code: %08x \n", err );
		}

		test_count --;
		if ( test_count == 0 ) {
			tts2 = SoraGetCPUTimestamp ( &tsinfo );
			fRunning = false;
	//		return false;
		} else {
			BB11aDemodCtx.Init ( (COMPLEX16*)InputBuf, (bCnt)*sizeof(COMPLEX16), OutputBuf, OUT_BUF_SIZE);
	//		return true;
		}
	}
	return false;
}
示例#3
0
int Test11B_FB_Demod()
{
	printf ( "Demodulate 11b with Fine Brick!\n" );


	ISource * ssrc = CreateDemodGraph ();

//	int bCnt = LoadSoraDumpFile ( "c:\\11b-1M-1.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\noise.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
	int bCnt = LoadSoraDumpFile ( "d:\\test.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );


	printf ( "Load sample %d\n", bCnt );



	ULONGLONG ts1 = SoraGetCPUTimestamp ( &tsinfo );
	for ( int i=0; i<100; i++) {
		
		InitFBDemodContext ((COMPLEX16*)InputBuf, (bCnt)*sizeof(COMPLEX16), OutputBuf, OUT_BUF_SIZE);

		ssrc->Reset ();
		if ( BB11bDemodCtx.CF_Error::error_code() == E_ERROR_SUCCESS ) {
			FB_11B_DemodBuffer (ssrc);
		} else {
			printf ( "Reset error!\n" );
		}
	}	
	ULONGLONG ts2 = SoraGetCPUTimestamp ( &tsinfo );
	
	ulong& err = BB11bDemodCtx.CF_Error::error_code();
	if (  err == E_ERROR_FRAME_OK ) {	
		printf ( "one good frame find!\n" );
	} else {
		printf ( "error code: %08x \n", err );
	}


	printf("Signal data rate:	 %dk\n",BB11bDemodCtx.CF_11bRxVector::data_rate_kbps() ); 
	printf("Bytes decoded: %d\n",   	BB11bDemodCtx.CF_11bRxVector::frame_length() );
    printf("Time cost average:   %.3fus \n", SoraTimeElapsed (ts2-ts1, &tsinfo) * 1.0 / 1000 / 100 );

/*
	if ( pArgs->pcOutFileName != NULL ) {
		FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
		pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
		if (!pOut)
		{
			printf("Cannot create output file.\n");
			return -1;
		}

		fwrite(	OutputBuf, 
				fb11bDemodCtx.CF_MPDU_Info::frame_len(), 
				1, pOut);
		fclose(pOut);
	}
*/
	IReferenceCounting::Release (ssrc);

	return 0;
}
示例#4
0
int Test11A_FB_Demod()
{
	printf ( "Demodulate 11a with Fine Brick!\n" );

	// test usin/ucos

//	int bCnt = LoadSoraDumpFile ( "c:\\11b-1M-1.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\noise.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\test-real.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\test-ideal.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
	bCnt = LoadSoraDumpFile ( "c:\\a48-40.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );



	printf ( "Load sample %d\n", bCnt );


	BB11aDemodCtx.Init ( (COMPLEX16*)InputBuf, (bCnt)*sizeof(COMPLEX16), OutputBuf, OUT_BUF_SIZE);
	
	CreateDemodGraph11a (ssrc, svit);
	fRunning = true;
	ULONGLONG tts1 = SoraGetCPUTimestamp ( &tsinfo );	
	
	thread2 = AllocStartThread ( ViterbiThread, NULL );
	thread1 = AllocStartThread ( RxThread, NULL );

	while ( fRunning ) {
		Sleep (1);
	}

	StopFreeThread (thread1 );
	StopFreeThread (thread2 );
	
//	printf("Signal data rate:	 %dk\n",BB11bDemodCtx.CF_11bRxVector::data_rate_kbps() ); 
//	printf("Bytes decoded: %d\n",   	BB11bDemodCtx.CF_11bRxVector::frame_length() );
    printf("Time cost average:   %.3fus \n", SoraTimeElapsed (tts2-tts1, &tsinfo) * 1.0 / 1000 / (TEST_NUM-1));
	printf ( "Total symbol %d!\n", BB11aDemodCtx.CF_11aRxVector::total_symbols() );


/*
	if ( pArgs->pcOutFileName != NULL ) {
		FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
		pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
		if (!pOut)
		{
			printf("Cannot create output file.\n");
			return -1;
		}

		fwrite(	OutputBuf, 
				fb11bDemodCtx.CF_MPDU_Info::frame_len(), 
				1, pOut);
		fclose(pOut);
	}
*/

	IReferenceCounting::Release (ssrc);

	return 0;
}
示例#5
0
// no_threads - number of threads to start
// User_Routines[no_threads] - pointers to functions to be started
// sizes[no_threads-1] - size of data structure to be held by each buffer (in bytes)
int StartThreads(ULONGLONG * ttstart, 
                 ULONGLONG * ttend, 
		 TIMESTAMPINFO *tsinfo,
                 int no_threads, PSORA_UTHREAD_PROC* User_Routines)
{
	stop_program = 0;
	bool init_error = false;

	SetConsoleCtrlHandler(console_ctrl_handler, TRUE);

	for (int i=0; i<no_threads; i++)
	{
		if (User_Routines[i] != NULL)
		{
			t_info[i].threadID = i;
			t_info[i].fRunning = true;
			threads[i] = AllocStartThread ( User_Routines[i], (void *) (t_info+i) );
			if (threads[i] == NULL) init_error = true;
		}
		else
		{
			threads[i] = NULL;
		}
	}

	// Start measuring time
	*ttstart = SoraGetCPUTimestamp ( tsinfo );	
	
	if (!init_error)
	{
		bool not_finished = true;
		while (not_finished) 
		{
			// Threads will exit when stop_program = true
			// So no need to close them explicitly

			not_finished = false;
			for (int i=0; i<no_threads; i++)
			{
				not_finished = not_finished || t_info[i].fRunning;
			}
			Sleep (1); // NB: not Sleep(100) (!!)
			// Flush stdout to get any printout that could be out there
			fflush(stdout);
			/* Removed as it fails to compile with WinDDK
			if (kbhit())
			{
				stop_program = 1;
			}
			*/
		}
	}
	else
	{
		printf("Initialization error: couldn't start a thread!\n");
		exit(1);
	}


	// Stop measuring time
	*ttend = SoraGetCPUTimestamp ( tsinfo );

	return no_threads;
}
示例#6
0
int __ext_record_time_stop() {
	ULONGLONG record_end_time = SoraGetCPUTimestamp(&measurementInfo.tsinfo);
	printf("Elapsed(ns):%ul\n", record_end_time - record_time);
	fflush(stdout);
	return 0;
}
示例#7
0
int __ext_record_time_start() {
	record_time = SoraGetCPUTimestamp(&measurementInfo.tsinfo);
	return 0;
}
示例#8
0
// TODO: Once 64-bits numbers are supported convert this into getTime 
// and return the time as a 64-bit number
int __ext_print_time() {
	ULONGLONG time = SoraGetCPUTimestamp(&measurementInfo.tsinfo);
	printf("%ul\n", time);
	fflush(stdout);
	return 0;
}