Beispiel #1
0
BOOLEAN SoraUInitUserExtension(const char * szDevName)
{
	BOOLEAN ret = FALSE;

	if (!AllocBufferListHead.Flink &&
		!AllocBufferListHead.Blink)
		InitializeListHead(&AllocBufferListHead);

    if (SoraQueuedSendPacket == NULL ||
		SoraExitSendPacket == NULL ||
		SoraDevice == INVALID_HANDLE_VALUE) {

		SoraUCleanUserExtension();
		
		SoraQueuedSendPacket =
			CreateSemaphore(NULL, 
				0,
				MAX_QUEUED_SEND_PACKET,
				"SoraQueuedSendPacket");

		SoraExitSendPacket = 
			CreateEvent(NULL,
				TRUE,
				FALSE,
				NULL);
			
        SoraDevice = 
            CreateFileA ( 
                szDevName, GENERIC_READ | GENERIC_WRITE, 
                0,  
                NULL,
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,
                NULL );
		
		if (SoraQueuedSendPacket && 
			SoraExitSendPacket &&
			SoraDevice != INVALID_HANDLE_VALUE)
			ret = TRUE;
		else
			SoraUCleanUserExtension();
    }
	else
		ret = TRUE;
	
    return ret;
}
Beispiel #2
0
void RadioStop(BlinkParams *params) {
	if (params->TXBuffer != NULL)
	{
		SoraUReleaseBuffer((PVOID)params->TXBuffer);
	}

	if (params->pRxBuf != NULL)
	{
		HRESULT hr;
		SoraURadioReleaseRxStream(&params->radioParams.dev->RxStream, params->radioParams.radioId);
        hr = SoraURadioUnmapRxSampleBuf(params->radioParams.radioId, params->pRxBuf);
	}

	SoraUCleanUserExtension();
}
Beispiel #3
0
int __cdecl main(int argc, const char *argv[])
{
	if ( ParseCmdLine (argc, argv) == false )
	{
		usage();
		return 0;
	}

	if ( CheckParameters () == false ) {
		return 0;
	}

	// init DebugPlot library
	DebugPlotInit();

	InitializeTimestampInfo ( &tsinfo, true );
	
	// begin receive or transmit packets
	if (!SoraUInitUserExtension("\\\\.\\HWTest")) {
		printf ( "Error: fail to find the hwtest driver!\n" );
		getchar();
		return -1;
	}

	if ( bWarning ) {
		printf ( "Warnings - press enter to continue...\n" );
		getchar();
	}	
	
	// clear screen	
	system( "cls" );	
	
	// Start the main procedure
	Dot11_main ();

	// clear screen
	// system( "cls" );	
	
	SoraUCleanUserExtension();
	DebugPlotDeinit();

    return 0;
}
Beispiel #4
0
void stop_sora_hw()
{
	// Start Sora HW
	if (params_rx->inType == TY_SDR || params_tx->outType == TY_SDR)
	{
		RadioStop(params_tx);
	}
	// Start NDIS
	if (params_tx->inType == TY_IP)
	{
		if (hUplinkThread != NULL)
		{
			// Sora cleanup.
			SoraUThreadStop(hUplinkThread);
			SoraUThreadFree(hUplinkThread);
		}
		SoraUDisableGetTxPacket();
		// Winsock cleanup.
		closesocket(ConnectSocket);
		WSACleanup();

	}

	if (params_rx->outType == TY_IP)
	{
		// To be implemented
		/*
		if (hUplinkThread != NULL)
		{
		// Sora cleanup.
		SoraUThreadStop(hUplinkThread);
		SoraUThreadFree(hUplinkThread);
		}
		SoraUDisableGetTxPacket();
		// Winsock cleanup.
		closesocket(ConnectSocket);
		WSACleanup();
		*/
	}

	SoraUCleanUserExtension();
}
Beispiel #5
0
int __cdecl main(int argc, const char *argv[])
{
    HRESULT hr;

	if ( ParseCmdLine (argc, argv) == false )
	{
		usage();
		return 0;
	}

	// init DebugPlot library
	DebugPlotInit();

    // init sora timestamp library
	InitializeTimestampInfo ( &tsinfo, false );

    do {
    	// begin receive or transmit packets
    	if (!SoraUInitUserExtension("\\\\.\\HWTest")) {
    		printf ( "Error: fail to find the hwtest driver!\n" );
    		break;
    	}

        // start UMX
        // Map Rx Sample Buffer
        hr = SoraURadioMapRxSampleBuf(TARGET_RADIO, &RxBuffer, &RxBufferSize);
        if (FAILED(hr)) {
            printf ( "Fail to map rx buffer!\n" );
       		break;
        }   
    
        // Alloc Tx Sample Buffer
        SampleBuffer = SoraUAllocBuffer(SampleSize);
        if (!SampleBuffer) {
            printf ( "Fail to allocate Tx buffer!\n" );
            break;
        }   
    
        hr = SoraURadioAllocRxStream(&RxStream, TARGET_RADIO, (PUCHAR)RxBuffer, RxBufferSize);
        if (FAILED(hr)) {
            printf ( "Fail to allocate a RX stream!\n" );
            break;
        }

        printf ( "Configure radio...\n" );
        
        // configure radio parameters properly
        ConfigureRadio ();

		if ( sine.Create ( SampleBuffer, SampleSize ) ) {
			printf ("Sine source starts...\n" );
			sine.Start ();
		}
      
        // enter the message loop
        process_kb (); 
        
    }    while (false);

    
    sine.Stop ();
        
    SoraURadioReleaseRxStream(&RxStream, TARGET_RADIO);
    
    if (SampleBuffer) {
        SoraUReleaseBuffer(SampleBuffer);
        SampleBuffer = NULL;
    }
    
    if (RxBuffer) {
        hr = SoraURadioUnmapRxSampleBuf(TARGET_RADIO, RxBuffer);
    }
    
	SoraUCleanUserExtension();
	DebugPlotDeinit();

    return 0;
}
Beispiel #6
0
void DoDump(HANDLE hDevice, ULONG* RadioNo, ULONG Count, char UseTimeStamp, PCSTR szDumpFileName) {

	ULONG mask = 0;
	ULONG i;
	HRESULT err = S_OK;
	PVOID buf[MAX_RADIO_NUMBER] = { 0 };
	ULONG len[MAX_RADIO_NUMBER] = { 0 };
	SORA_RADIO_RX_STREAM RxStream[MAX_RADIO_NUMBER] = { 0 };
	do {
		if (!SoraUInitUserExtension("\\\\.\\HWTest")) {
			err = E_FAIL;
			break;
		}
		for(i=0; i < Count; i++) {
			if (mask & RadioNo[i]) {
				err = E_FAIL;
				break;
			}
			if (SoraURadioMapRxSampleBuf(RadioNo[i], &buf[i], &len[i]) != S_OK) {
				err = E_FAIL;
				break;
			}
			if (SoraURadioAllocRxStream(&RxStream[i], RadioNo[i], buf[i], len[i]) != S_OK) {
				err = E_FAIL;
				break;
			}
		}
		if (err == S_OK) {
			// raise to realtime to dump
			char** dump_buf = __MALLOC(sizeof(char*) * Count);
			memset(dump_buf, 0, sizeof(char*) * Count);
			for(i=0; i < Count; i++) {
				dump_buf[i] = __MALLOC(DUMP_BUFFER_SIZE);
				if (!dump_buf[i]) {
					err = E_FAIL;
					break;
				}
			}
			SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
			
			if (err == S_OK) {
				ULONG max_timestamp;
				ULONG last_timestamp = 0;
				ULONG clear_count = 0;				
#if 1
				if (UseTimeStamp) {
					for(clear_count=0; clear_count < 2; clear_count++) {
						for(i=0; i < Count; i++) {
							last_timestamp = ClearRxBuf(&RxStream[i]);
							printf("radio: %d, last_timestamp: 0x%08x\n", RadioNo[i], last_timestamp);
							if (i) {
								if (last_timestamp > max_timestamp) {
									if (last_timestamp - max_timestamp > 0x7fffffff) { 
										// timestamp overflow !!! max_timestamp is still the max, do nothing
									}
									else 
										max_timestamp = last_timestamp;
								}
								else
								if (max_timestamp > last_timestamp) {
									if (max_timestamp - last_timestamp > 0x7fffffff) { 
										// timestamp overflow !!! 
										max_timestamp = last_timestamp;
									}
								}
							}
							else
								max_timestamp = last_timestamp;
						}
					}
					printf("max_timestamp: 0x%08x\n", max_timestamp);

					DumpFromTimeStamp(RadioNo, RxStream, dump_buf, Count, max_timestamp + DUMP_BUFFER_DELAY_TIMESTAMP, UseTimeStamp, szDumpFileName);
				}
				else {
					last_timestamp = ClearRxBuf(&RxStream[0]);

					DumpFromTimeStamp(RadioNo, RxStream, dump_buf, Count, 0, UseTimeStamp, szDumpFileName);
				}
			}

#endif

#if 0
timestamp_for_dump:
				for(i=0; i < Count; i++) {					
					last_timestamp = ClearRxBuf(&RxStream[i]);
					printf("last_timestamp: 0x%08x\n", last_timestamp);
					if (i) {
						if (last_timestamp > max_timestamp) {
							if (last_timestamp - max_timestamp > 0x7fffffff) { // timestamp overflow !!!
								printf("timestamp overflow, retry...\n");
								goto timestamp_for_dump;
							}
							max_timestamp = last_timestamp;
						}
						else
						if (max_timestamp > last_timestamp) {
							if (max_timestamp - last_timestamp > 0x7fffffff) { // timestamp overflow !!! 
								printf("timestamp overflow, retry...\n");
								goto timestamp_for_dump;
							}
						}
						else
						if (last_timestamp < min_timestamp)
							min_timestamp = last_timestamp;
					}
					else {
						min_timestamp = last_timestamp;
						max_timestamp = last_timestamp;
					}					
				}
				printf("max_timestamp: 0x%08x, min_timestamp: 0x%08x\n", max_timestamp, min_timestamp);
				if ((max_timestamp - min_timestamp) > (DUMP_BUFFER_SIZE/sizeof(RX_BLOCK))/2) {
					printf("prevent out of sync, retry...\n");
					goto timestamp_for_dump;
				}					
				DumpFromTimeStamp(RadioNo, RxStream, dump_buf, Count, max_timestamp + DUMP_BUFFER_DELAY_TIMESTAMP);
			}
#endif			
			SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
			
			for(i=0; i < Count; i++)
				if (!dump_buf[i])
					__FREE(dump_buf[i]);				
			__FREE(dump_buf);
		}
	} while(0);
	for(i=0; i < Count; i++) {
		if (RxStream[i].__VStreamMask)
			SoraURadioReleaseRxStream(&RxStream[i], RadioNo[i]);
		if (buf[i])
			SoraURadioUnmapRxSampleBuf(RadioNo[i],	buf[i]);
	}
	SoraUCleanUserExtension();
}