예제 #1
0
파일: dot11atx.c 프로젝트: PaulJing/Sora
void Dot11ATxApp(const Config& config)
{
    SampleBufferSize = _M(2);
    SampleBuffer = SoraUAllocBuffer(SampleBufferSize);
	printf("tx buffer: %08x\n", SampleBuffer);
	printf("tx buffer size: %08x\n", SampleBufferSize);
	if (SampleBuffer == NULL) return;

	PreparePacket(config, (PVOID)SampleBuffer, (ULONG)SampleBufferSize);

    HRESULT hr;
	do
	{
		//Generate Signal
		hr = BB11ATxFrameMod(&TxVector, &Packet);
		printf("GenSignal return %08x\n", hr);
		printf("Signal bytes = %d\n", Packet.Reserved3);

        /*{
            PCOMPLEX8 pSampleBuffer = (PCOMPLEX8)SampleBuffer;
            for (i = 0; i < Packet.Reserved3; i++)
                printf("(%5d, %5d)\t", pSampleBuffer[i].re, pSampleBuffer[i].im);
            printf("\n");
        }*/

		hr = SoraURadioTransferEx(TARGET_RADIO, SampleBuffer, Packet.Reserved3, &TxID);
		printf("transfer, hr=%08x, id=%d\n", hr, TxID);
        FAILED_BREAK(hr);

        Monitor monitor;
        TxContext ctx(config, monitor);
        HANDLE hTxThread = AllocStartThread(DoDot11ATx, &ctx);

		if (SUCCEEDED(hr) && hTxThread)
		{
            printf("\n\nPress any key to exit the program\n");			
            time_t start = time(NULL);
	        while(!_kbhit())
            {
                if (config.Interval() != 0 && difftime(time(NULL), start) >= config.Interval()) break;
	        }

            StopFreeThread(hTxThread);
			hr = SoraURadioTxFree(TARGET_RADIO, TxID);
			printf("tx free return %08x\n", hr);
		}
	} while (FALSE);

	SoraUReleaseBuffer((PVOID)SampleBuffer);
	printf("unmap tx buffer ret: %08x\n", hr);

	printf("Tx out.\n");
}
예제 #2
0
void Dot11BTxApp(const Config& config)
{
	HRESULT hr;

	if (Dot11BTxInit() < 0)
		return;

	Dot11BPreparePacket(config, (PVOID)SampleBuffer, (ULONG)SampleBufferSize);

	do
	{
		// Generate Signal
		hr = BB11BPMDPacketGenSignal(&Packet, &TxVector, (PUCHAR)TempBuffer, TempBufferSize);
		printf("[dot11b:tx] GenSignal return %08x\n", hr);
        printf("[dot11b:tx] Signal bytes=%d\n", Packet.Reserved3);

		hr = SoraURadioTransferEx(TARGET_RADIO, SampleBuffer, Packet.Reserved3, &TxID);
		printf("[dot11b:tx] transfer, hr=%08x, id=%d\n", hr, TxID);
        FAILED_BREAK(hr);

        Monitor monitor;
        TxContext ctx(config, monitor);
        HANDLE hTxThread = AllocStartThread(DoDot11BTx, &ctx);

		if (SUCCEEDED(hr))
		{
            printf("\n\nPress any key to exit the program\n");
            time_t start = time(NULL);
	        while(!_kbhit())
            {
                if (config.Interval() != 0 && difftime(time(NULL), start) >= config.Interval()) break;
	        }

            StopFreeThread(hTxThread);

			hr = SoraURadioTxFree(TARGET_RADIO, TxID);
			printf("[dot11b:tx] tx free return %08x\n", hr);
		}
	} while(false);

	Dot11BTxClean();

	printf("[dot11b:tx] Tx out.\n");
}
예제 #3
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;
}
예제 #4
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;
}