From 9fe4d4ea9c054e539ab679ed2e9c076c35beb69d Mon Sep 17 00:00:00 2001 From: etobi Date: Tue, 3 Sep 2013 09:48:45 +0200 Subject: Imported Upstream version 1.1.1+rev1355 --- util/gotox/Makefile | 17 ++++++ util/gotox/gotox.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 util/gotox/Makefile create mode 100644 util/gotox/gotox.c (limited to 'util/gotox') diff --git a/util/gotox/Makefile b/util/gotox/Makefile new file mode 100644 index 0000000..673586a --- /dev/null +++ b/util/gotox/Makefile @@ -0,0 +1,17 @@ +# Makefile for linuxtv.org dvb-apps/util/gotox + +binaries = gotox + +inst_bin = $(binaries) + +CPPFLAGS += -I../../lib +LDFLAGS += -L../../lib/libdvbapi +LDFLAGS += -L../../lib/libdvbsec +LDLIBS += -ldvbapi +LDLIBS += -ldvbsec + +.PHONY: all + +all: $(binaries) + +include ../../Make.rules diff --git a/util/gotox/gotox.c b/util/gotox/gotox.c new file mode 100644 index 0000000..6616133 --- /dev/null +++ b/util/gotox/gotox.c @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2006 by Michel Verbraak + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +static char *usage_str = + "\nusage: gotox [options] -d \n" + " Goto the specified angle. Positive value for East rotation\n" + " Negative value for West rotation on Northern Hemisphere.\n" + " -d degrees : Angle to turn to in degrees (default 0)\n" + " -a number : use given adapter (default 0)\n" + " -f number : use given frontend (default 0)\n" + " -t seconds : leave power on to rotor for at least specified seconds of time (default 30)\n\n"; + +int main(int argc, char *argv[]) +{ + struct dvbfe_handle *fe; + unsigned int adapter = 0, frontend = 0; + double angle = 0; + int opt; + unsigned int sleepcount = 30; + static char *weststr = "west"; + static char *eaststr = "east"; + + while ((opt = getopt(argc, argv, "ha:f:t:d:")) != -1) { + + switch (opt){ + case '?': + case 'h': + default: + fprintf(stderr, "%s", usage_str); + return EXIT_SUCCESS; + + case 'a': + adapter = strtoul(optarg, NULL, 0); + break; + + case 'f': + frontend = strtoul(optarg, NULL, 0); + break; + + case 't': + sleepcount = strtoul(optarg, NULL, 0); + break; + + case 'd': + angle = strtod(optarg, NULL); + break; + } + } + + printf("Will try to rotate %s to %.2f degrees.\n", (angle < 0.0) ? weststr : eaststr, angle ); + + fe = dvbfe_open(adapter, frontend, 0); + if (fe == NULL) { + fprintf(stderr, "Could not open frontend %d on adapter %d.\n", frontend, adapter); + exit(1); + } + + if (dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_OFF) != 0) { + fprintf(stderr, "Could not turn off power.\n"); + dvbfe_close(fe); + return 1; + } + else + printf("Power OFF.\n"); + + sleep(1); + + if (dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_18) != 0) { + fprintf(stderr, "Could not turn on power.\n"); + dvbfe_close(fe); + return 1; + } + else + printf("Power on to 18V.\n"); + + sleep(1); + + if (abs(angle) == 0.0) { + + if (dvbsec_diseqc_goto_satpos_preset(fe, DISEQC_ADDRESS_POLAR_AZIMUTH_POSITIONER, 0) != 0) { + fprintf(stderr, "Could not goto 0.\n"); + dvbfe_close(fe); + return 2; + } else { + printf("Going to home base 0 degrees.\n"); + } + } else { + + if (dvbsec_diseqc_goto_rotator_bearing(fe, DISEQC_ADDRESS_POLAR_AZIMUTH_POSITIONER, angle) != 0) { + fprintf(stderr, "Could not rotate.\n"); + dvbfe_close(fe); + return 2; + } + } + + while (sleepcount != 0) { + printf("%d: Rotating to %.2f.\r", sleepcount, angle); + fflush(NULL); + sleepcount--; + sleep(1); + } + + printf("\nRotated.\n"); + + if (dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_OFF) != 0) { + fprintf(stderr, "Could not turn off power.\n"); + dvbfe_close(fe); + return 1; + } + else + printf("Power OFF.\n"); + + sleep(1); + + dvbfe_close(fe); + + return EXIT_SUCCESS; +} -- cgit v1.2.3