//================================================================================================== int main(int argc, char **argv) { struct sigaction sigact; int chose, res; int closeFlag = 0; struct timeval; Byte handleNum; options_t options; get_options(argc, argv, &options); print_options(&options); if (DTV_Initialize(options.dev_handle) == ERR_INVALID_DEV_TYPE) { return 0; } sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGPIPE, &sigact, NULL); fprintf(stderr, "\n========== ITEtech Linux DTV receiver control program ==========\n"); GetDriverInfo(); fprintf(stderr, "================================================================\n"); if (ChannelLock(&options) < 0) { fprintf(stderr, "Lock channel fail!\n"); } else { if (options.stat_count >= 0) { ChannelStatisticTest(&options); } else { if (options.ts_filename) { dvbout(&options); } else { dvbtraffic(&options); } } } DTV_Finalize(); return 0; }
//================================================================================================== int dvbout(options_t *options) { int tempCount = 0; int packets = 0; int infinite_loop = 0; Byte buffer[BSIZE*BBLOCK]; int i = 0, j = 0; FILE *pFile = NULL; if (options->ts_filename) { if (strcmp("-", options->ts_filename) == 0) { pFile = stdout; } else { pFile = fopen(options->ts_filename, "wb"); } } DTV_StartCapture(); usleep(2000000); j = 0; if (options->packet_limit == 0) { infinite_loop = 1; // for Burn in test } while (!gDoExit && (infinite_loop || (i < options->packet_limit))) { int pid, ok; Dword r; r = 188*BBLOCK; DTV_GetData(buffer, &r); //printf("DTV_GetData - %d\n", r); if (r <= 0) { if (options->verbose) { fprintf(stderr, "read %d (%lu, %d) \n", j, r, packets); } usleep(100000); // was 100 ms j++; if (j>10) // was 10 sec { fprintf(stderr, "Read timeout\n", r); if (options->relock) { if (ChannelLock(options) < 0) { fprintf(stderr, "Re-lock channel fail!\n"); break; } } else { break; } } continue; } j = 0; if (r != 188*BBLOCK) { fprintf(stderr, "only read %lu\n", r); break; } packets++; if (pFile) { i = (packets*188*2) / 1024 / 1024; // MB fwrite(buffer, 1, sizeof(buffer), pFile); } } DTV_StopCapture(); if (pFile) { fclose(pFile); fprintf(stderr, "\n*** Save File to %s (%dM) ***\n", options->ts_filename, i); } return 0; }
//int main(int argc, char **argv) int rx(Byte handleNum) { int chose, res; int closeFlag = 0; struct timeval; //Byte handleNum; if(DTV_Initialize(handleNum) == ERR_INVALID_DEV_TYPE) return 0; printf("\n========== ITEtech Linux DTV Testkit ==========\n"); GetDriverInfo(); printf("\n===============================================\n"); while (!closeFlag) { printf("\n======= ITEtech Linux DTV Testkit =======\n"); printf("\n1. Lock Channel "); printf("\n2. Singal Quality Statistics "); printf("\n3. Record & Analyze Packets "); printf("\n4. Mutil-Channel Lock Test "); printf("\n5. Read/Write Register "); printf("\n6. echo "); printf("\n7. ULE rx "); printf("\n0. Quit "); printf("\n=> Please Input Your Choice: "); res = scanf("%d", &chose); switch (chose) { case 1: if (ChannelLock() < 0) { printf("Lock channel fail!\n"); } break; case 2: ChannelStatisticTest(); break; case 3: PacketTest(); break; case 4: MultiChannelTest(); break; case 5: RWRegister(); break; case 6: echoRX(); break; case 7: ule_rx(); break; case 0: closeFlag = 1; break; } } DTV_Finalize(); return 0; }