static int ChannelLock() { Dword dwFrequency = 0; Word wBandwidth = 0; Dword dwStatus = 0; Bool boolIsLock = 0; int res; printf("\n=> Please Input Frequency (KHz): "); res = scanf("%lu", &dwFrequency); gFreq = dwFrequency; 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; printf("\n\n**************** Lock Status ****************"); printf("\nFrequency = %lu KHz\n", dwFrequency); printf("Bandwidth = %i MHz\n\n", wBandwidth); dwStatus = DTV_AcquireChannel(dwFrequency, wBandwidth); if (dwStatus) printf("DTV_AcquireChannel() return error!\n"); dwStatus = DTV_DisablePIDTbl(); if (dwStatus) printf("DTV_DisablePIDTbl() return error!\n"); dwStatus = DTV_IsLocked((Bool *)&boolIsLock); if (dwStatus) printf("DTV_IsLocked() return error!\n"); if (boolIsLock) printf("*** Channel Locked ***\n"); else printf("*** Channel Unlocked ***\n"); return 0; }
//================================================================================================== static int ChannelLock(options_t *options) { Dword dwFrequency = 0; Word wBandwidth = 0; Dword dwStatus = 0; Bool boolIsLock = 0; int res; dwFrequency = options->frequency; gFreq = options->frequency; gChoseBand = options->bandwidth; fprintf(stderr, "\n"); if(gChoseBand>=2000 && gChoseBand<3000) wBandwidth = 2; else if(gChoseBand>=3000 && gChoseBand<4000) wBandwidth = 3; else if(gChoseBand>=4000 && gChoseBand<5000) wBandwidth = 4; else if(gChoseBand>=5000 && gChoseBand<6000) wBandwidth = 5; else if(gChoseBand>=6000 && gChoseBand<7000) wBandwidth = 6; else if(gChoseBand>=7000 && gChoseBand<8000) wBandwidth = 7; else if(gChoseBand>=8000 && gChoseBand<9000) wBandwidth = 8; else { fprintf(stderr, "No Supported Bandwidth!\n"); return ERR_INVALID_BW; } fprintf(stderr, "Trying to lock:\n"); fprintf(stderr, "Frequency ...: %lu KHz\n", dwFrequency); fprintf(stderr, "Bandwidth ...: %i MHz\n\n", wBandwidth); dwStatus = DTV_AcquireChannel(dwFrequency, wBandwidth); if (dwStatus) { fprintf(stderr, "DTV_AcquireChannel() returned error %s (%lx)\n", DTV_Error(dwStatus), dwStatus); } dwStatus = DTV_DisablePIDTbl(); if (dwStatus) { fprintf(stderr, "DTV_DisablePIDTbl() returned error %s (%lx)\n", DTV_Error(dwStatus), dwStatus); } dwStatus = DTV_IsLocked((Bool *)&boolIsLock); if (dwStatus) { fprintf(stderr, "DTV_IsLocked() returned error %s (%lx)\n", DTV_Error(dwStatus), dwStatus); } if (boolIsLock) { fprintf(stderr, "*** Channel Locked ***\n"); } else { fprintf(stderr, "*** Channel Unlocked ***\n"); } return 0; }