#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
#include <stdint.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
int main(int argc, char** argv) {
char adapter[1024];
int frontend_fd = -1;
struct dvb_frontend_info Info;
uint16_t Signal;
uint16_t Snr;
if(argc < 2) {
printf("Arguments: <int adapter nr>\n");
return -1;
}
sprintf(adapter, "/dev/dvb/adapter%s/frontend0", argv[1]);
if ((frontend_fd = open (adapter, O_RDWR | O_NONBLOCK)) < 0) {
printf("Failed to open %s\n", adapter);
}
if(ioctl(frontend_fd, FE_GET_INFO, &Info) < 0) {
printf("ioctl FE_GET_INFO failed\n");
return -1;
}
if (ioctl(frontend_fd, FE_READ_SIGNAL_STRENGTH, &Signal) != 0) {
printf("ioctl FE_READ_SIGNAL_STRENGTH failed\n");
}
if (ioctl(frontend_fd, FE_READ_SNR, &Snr) != 0) {
printf("ioctl FE_READ_SNR failed\n");
}
printf("%s:\nSignal: %d SNR: %d\n", Info.name, ((Signal * 100 + 0x8001) >> 16), ((Snr * 100 + 0x8001) >> 16));
close(frontend_fd);
}