コード例 #1
0
ファイル: sora_radio.c プロジェクト: dimitriv/Ziria
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();
}
コード例 #2
0
ファイル: sora_radio.c プロジェクト: 601040605/OTP4LTE-U
void RadioStop(BlinkParams *params) {
	writeSoraCtx *ctx = (writeSoraCtx *)params->TXBuffer;

	for (int i = 0; i < no_tx_bufs; i++)
	{
		if (ctx->TXBuffers[i] != NULL)
		{
			SoraUReleaseBuffer((PVOID)params->TXBuffer);
		}
	}
	free(ctx);

	if (params->pRxBuf != NULL)
	{
		HRESULT hr;
		SoraURadioReleaseRxStream(&params->radioParams.dev->RxStream, params->radioParams.radioId);
        hr = SoraURadioUnmapRxSampleBuf(params->radioParams.radioId, params->pRxBuf);
	}
}
コード例 #3
0
ファイル: main.cpp プロジェクト: PaulJing/Sora
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;
}
コード例 #4
0
ファイル: dut.c プロジェクト: PaulJing/Sora
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();
}