#include #include #include #include #include int main(int argc, char **argv) { int ch; int freq; int fd; fd = open("/dev/ufm0", O_RDWR); if (fd == -1) err(1, "/dev/ufm0"); while ((ch = getopt(argc, argv, "f:ms")) != -1) { switch (ch) { case 'f': freq = 1000000 * atof(optarg); if (ioctl(fd, FM_SET_FREQ, &freq) == -1) warn("FM_SET_FREQ"); break; case 'm': if (ioctl(fd, FM_STOP, &ch) == -1) warn("FM_STOP"); break; case 's': if (ioctl(fd, FM_START, &ch) == -1) warn("FM_START"); break; } } if (ioctl(fd, FM_GET_FREQ, &freq) == -1) err(1, "FM_GET_FREQ"); if (ioctl(fd, FM_GET_STAT, &ch) == -1) err(1, "FM_GET_STAT"); printf("Tuner at %5.2fMHz status %#x\n", (double) freq / 1000000.0, ch); close(fd); }