#include #include #include #include #include #include #include "/sys/dev/iicbus/iic.h" #include "tuner_ctrl.h" int main(int argc, char **argv) { struct iiccmd cmd; char buf[16]; float ofreq, freq; int fd; int i, rc = 0; if (argc < 2 || argc > 3) errx(1, "Usage: %s [freq]", argv[0]); if ( (fd = open(argv[1], O_RDWR)) < 0) err(errno, "Error opening device: %s", argv[1]); ofreq = freq = 0; if (argc == 3) { freq = strtof(argv[2], 0); redo_one: if ( (i = set_channel(fd, freq, ofreq, 0)) != 0) { if (++rc < 3) goto redo_one; err(errno, "Error switching channels"); } exit(0); } while (1) { ofreq = freq; printf("Enter scan frequency: "); if (scanf("%f", &freq) != 1) { if (feof(stdin)) { printf("\n"); break; } else { fpurge(stdin); fprintf(stderr, "Invalid frequency\n"); continue; } } rc = 0; redo_two: if ( (i = set_channel(fd, freq, ofreq, 0)) != 0) { if (++rc < 3) goto redo_two; warn("Error switching channels"); } } return 0; }