#if 0 set -x gcc -W -Wall -O -s -I../DVB/include -o `basename $0 .c` $0 $* exit $? #endif #include #include #include #include #include #include char *invs[] = { "OFF", "ON", "AUTO" }; int main (int argc, char **argv) { struct dvb_frontend_parameters fr; int frontend_fd; uint16_t strength, snr; uint32_t ber, ucb; fe_status_t festatus; if (argc < 2) { fprintf (stderr, "Usage\n"); exit (2); } frontend_fd = open (argv[1], O_RDONLY); if (0 > frontend_fd) { perror (argv[1]); exit (1); } if (0 > ioctl (frontend_fd, FE_READ_BER, &ber)) { perror ("ioctl READ_BER"); exit (1); } if (0 > ioctl (frontend_fd, FE_READ_SIGNAL_STRENGTH, &strength)) { perror ("ioctl READ SIGNAL STRENGTH"); exit (1); } if (0 > ioctl (frontend_fd, FE_READ_SNR, &snr)) { perror ("ioctl READ SNR"); exit (1); } if (0 > ioctl (frontend_fd, FE_READ_UNCORRECTED_BLOCKS, &ucb)) { perror ("ioctl READ UNCORRECTED BLOCKS"); exit (1); } if (0 > ioctl (frontend_fd, FE_GET_FRONTEND, &fr)) { perror ("ioctl GET FRONTEND"); exit (1); } if (0 > ioctl (frontend_fd, FE_READ_STATUS, &festatus)) { perror ("ioctl READ STATUS"); exit (1); } close (frontend_fd); printf ("Signal=%u, Verror=%u, SNR=%udB, QAM_%d, FREQ=%.6fMHz, SR=%.6fMsym, INV=%s, BlockErrors=", strength, ber, snr, 16 * (1 << (fr.u.qam.modulation - QAM_16)), fr.frequency / 1000000.0, fr.u.qam.symbol_rate / 1000000.0, invs [fr.inversion]); if (0xffffffff == ucb) printf ("?, ("); else printf ("%u, (", ucb); if (festatus & FE_HAS_SIGNAL) printf("S|"); if (festatus & FE_HAS_LOCK) printf("L|"); if (festatus & FE_HAS_CARRIER) printf("C|"); if (festatus & FE_HAS_VITERBI) printf("V|"); if (festatus & FE_HAS_SYNC) printf("SY|"); puts (")\n"); return 0; }