Example #1
0
//==================================================================================================
static int MultiChannelTest()
{
	Dword dwFrequency = 0;
    Word  wBandwidth = 0;
	Dword dwStatus = 0;
	Bool boolIsLock = 0;
	Dword dwpPostErrCnt;    // ErrorBitCount
	Dword dwpPostBitCnt;    // TotalBitCount
    Word  wpAbortCnt;       // number of abort RSD packet
    Word  wpQuality;        // signal quality (0 - 100)
    Word  wpStrength;		// signal strength (0 - 100)
	DTVStatistic StatisicEx;
	int startFreq, stopFreq;
	int channels = 0, res;
	FILE* pFile = NULL;

	pFile = fopen("scanlog.txt", "w");

	printf("\n=> Please Input Start Frequency (KHz): ");
	res = scanf("%d", &startFreq);
	
	printf("\n=> Please Input Stop Frequency (KHz): ");
	res = scanf("%d", &stopFreq);
	
	printf("\n=> Please Choose Bandwidth (0:8MHz  1:7MHz  2:6MHz): ");
	res = scanf("%d",&gChoseBand);

	if (gChoseBand == 0)
		wBandwidth = 8;
	else if (gChoseBand == 1)
		wBandwidth = 7;
	else
		wBandwidth = 6;

	gFreq = startFreq;

	while (gFreq <= stopFreq)
	{
		dwFrequency = gFreq;

		dwStatus = DTV_AcquireChannel(dwFrequency, wBandwidth);
		if (dwStatus)
			printf("DTV_AcquireChannel() return error!\n");

		usleep(2500000);

		dwStatus =  DTV_GetStatistic(10000,
										(Dword *)&dwpPostErrCnt,
										(Dword *)&dwpPostBitCnt,
										(Word *)&wpAbortCnt,
										(Word *)&wpQuality,
										(Word *)&wpStrength);

		if (dwStatus)
			printf("DTV_GetStatistic() return error!\n");

		dwStatus =  DTV_GetStatisticEx(&StatisicEx);
		if (dwStatus)
			printf("DTV_GetStatisticEx() return error!\n");

		dwStatus = DTV_IsLocked((Bool *)&boolIsLock);
		if (dwStatus)
			printf("DTV_IsLocked() return error!\n");

		if (boolIsLock) {
			channels ++;
			printf("\n======  Statistics   ======\n");
			printf("Frequency = %i KHz\n", gFreq);
			printf("Demod locked: %d\n", StatisicEx.signalLocked);
			printf("TPS locked :%d\n", StatisicEx.signalPresented);
			printf("Quality: %d\n", wpQuality);
			printf("Strength: %d\n", wpStrength);
			if (dwpPostBitCnt != 0)
				printf("BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
			else
				printf("BER: %3.3e\n", (double) dwpPostBitCnt);
			printf("Abort Count: %d\n", wpAbortCnt);

			printf("===============================\n");

			if (pFile) {
				fprintf(pFile, "\n======  Statistics   ======\n");
				fprintf(pFile, "Frequency = %i KHz\n", gFreq);
				fprintf(pFile, "Demod locked: %d\n", StatisicEx.signalLocked);
				fprintf(pFile, "TPS locked :%d\n", StatisicEx.signalPresented);
				fprintf(pFile, "Quality: %d\n", wpQuality);
				fprintf(pFile, "Strength: %d\n", wpStrength);
				if (dwpPostBitCnt != 0)
					fprintf(pFile, "BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
				else
					fprintf(pFile, "BER: %3.3e\n", (double) dwpPostBitCnt);
				fprintf(pFile, "Abort Count: %d\n", wpAbortCnt);

				fprintf(pFile, "===============================\n");
			}
		}

		if (gChoseBand == 0)
			gFreq = gFreq + 8000;
		else if (gChoseBand == 1)
			gFreq = gFreq + 7000;
		else
			gFreq = gFreq + 6000;

	}

	printf("\n============ Analysis ============");
	printf("\n Frequency %d(KHz) ~  %d(KHz)", startFreq, stopFreq);
	printf("\n Scan Channel : %d channels Locked  \n", channels);

	if (pFile) {
		fprintf(pFile, "\n============ Analysis ============");
		fprintf(pFile, "\n Frequency %d(KHz) ~  %d(KHz)", startFreq, stopFreq);
		fprintf(pFile, "\n Scan Channel : %d channels Locked  \n", channels);
		fclose(pFile);
		printf("\n Save log to file scanlog.txt\n\n");
	}

	return 0;
}
Example #2
0
//==================================================================================================
static int ChannelStatisticTest(options_t *options)
{
    Dword dwpPostErrCnt;    // ErrorBitCount
    Dword dwpPostBitCnt;    // TotalBitCount
    Word  wpAbortCnt;       // number of abort RSD packet
    Word  wpQuality;        // signal quality (0 - 100)
    Word  wpStrength;       // signal strength (0 - 100)
    Dword dwStatus;
    DTVStatistic StatisicEx;
    int res;
    int i = 0;
    FILE *pFile = NULL;

    do 
    {
        dwStatus =  DTV_GetStatistic(10000,
                                        (Dword *)&dwpPostErrCnt,
                                        (Dword *)&dwpPostBitCnt,
                                        (Word *)&wpAbortCnt,
                                        (Word *)&wpQuality,
                                        (Word *)&wpStrength);

        if (dwStatus)
        {
            fprintf(stderr, "DTV_GetStatistic() return error!\n");
        }

        dwStatus =  DTV_GetStatisticEx(&StatisicEx);
        
        if (dwStatus)
        {
            fprintf(stderr, "DTV_GetStatisticEx() return error!\n");
        }
        
        fprintf(stderr, "\n*******************************\n*** Channel Statistics: ***\n");

        fprintf(stderr, "Demod locked: %d\n", StatisicEx.signalLocked);
        fprintf(stderr, "TPS locked :%d\n", StatisicEx.signalPresented);
        fprintf(stderr, "Quality: %d\n", wpQuality);
        fprintf(stderr, "Strength: %d\n", wpStrength);
        
        if (dwpPostBitCnt != 0)
        {
            fprintf(stderr, "BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
        }
        else
        {
            fprintf(stderr, "BER: %3.3e\n", (double) dwpPostBitCnt);
        }
        
        fprintf(stderr, "Abort Count: %d\n", wpAbortCnt);

        if (options->stat_filename)
        {
            pFile = fopen(options->stat_filename, "w");
            
            fprintf(pFile, "\n*******************************\n*** Channel Statistics: ***\n");

            fprintf(pFile, "Demod locked: %d\n", StatisicEx.signalLocked);
            fprintf(pFile, "TPS locked :%d\n", StatisicEx.signalPresented);
            fprintf(pFile, "Quality: %d\n", wpQuality);
            fprintf(pFile, "Strength: %d\n", wpStrength);
            
            if (dwpPostBitCnt != 0)
            {
                fprintf(pFile, "BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
            }
            else
            {
                fprintf(pFile, "BER: %3.3e\n", (double) dwpPostBitCnt);
            }
            
            fprintf(pFile, "Abort Count: %d\n", wpAbortCnt);

            fprintf(pFile, "*******************************\n");
            fprintf(pFile, "\n");
        }

        usleep(1000000);
        i++;
    } while (((i < options->stat_count) || (options->stat_count == 0)) && !gDoExit);

    if (pFile)
    {
        fclose(pFile);
    }

    return 0;
}
Example #3
0
static int ChannelStatisticTest()
{
    Dword dwpPostErrCnt;    // ErrorBitCount
    Dword dwpPostBitCnt;    // TotalBitCount
    Word  wpAbortCnt;       // number of abort RSD packet
    Word  wpQuality;        // signal quality (0 - 100)
    Word  wpStrength;		// signal strength (0 - 100)
    Dword dwStatus;
    DTVStatistic StatisicEx;
    int chose, res;
    int count = 1, i = 0;
    FILE *pFile = NULL;

    printf("\n1. Display Statistics	      ");
    printf("\n2. Monitor Statistics        ");
    printf("\n3. Return to Main Menu       ");
    printf("\n=> Please Input Your Choice: ");
    res = scanf("%d", &chose);

    switch (chose)
    {
        case 1: 
            count = 1;
            break;

        case 2:
            pFile = fopen("Statistics.txt", "w");

            printf("\n=> Monitor Times: ");
            res = scanf("%d", &count);

            break;

        default:
            return 0;
    }

    do {
        dwStatus =  DTV_GetStatistic(10000,
                (Dword *)&dwpPostErrCnt,
                (Dword *)&dwpPostBitCnt,
                (Word *)&wpAbortCnt,
                (Word *)&wpQuality,
                (Word *)&wpStrength);

        if (dwStatus)
            printf("DTV_GetStatistic() return error!\n");

        dwStatus =  DTV_GetStatisticEx(&StatisicEx);
        if (dwStatus)
            printf("DTV_GetStatisticEx() return error!\n");

        printf("\n*******************************\n*** Channel Statistics: ***\n");

        printf("Demod locked: %d\n", StatisicEx.signalLocked);
        printf("TPS locked :%d\n", StatisicEx.signalPresented);
        printf("Quality: %d\n", wpQuality);
        printf("Strength: %d\n", wpStrength);
        if (dwpPostBitCnt != 0)
            printf("BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
        else
            printf("BER: %3.3e\n", (double) dwpPostBitCnt);
        printf("Abort Count: %d\n", wpAbortCnt);

        printf("*******************************\n");
        printf("\n");

        if (pFile) {
            fprintf(pFile, "\n*******************************\n*** Channel Statistics: ***\n");

            fprintf(pFile, "Demod locked: %d\n", StatisicEx.signalLocked);
            fprintf(pFile, "TPS locked :%d\n", StatisicEx.signalPresented);
            fprintf(pFile, "Quality: %d\n", wpQuality);
            fprintf(pFile, "Strength: %d\n", wpStrength);
            if (dwpPostBitCnt != 0)
                fprintf(pFile, "BER: %3.3e\n", ((float)dwpPostErrCnt)/dwpPostBitCnt);
            else
                fprintf(pFile, "BER: %3.3e\n", (double) dwpPostBitCnt);
            fprintf(pFile, "Abort Count: %d\n", wpAbortCnt);

            fprintf(pFile, "*******************************\n");
            fprintf(pFile, "\n");
        }

        usleep(1000000);
        i++;
    } while (i < count);

    if (pFile)
        fclose(pFile);

    return 0;
}