From 99270142dcad07f123ca64b713fb600c6f958cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Fri, 31 Oct 2008 07:45:17 +0000 Subject: [PATCH] added PcRotor in a new kit rotor group git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2434 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- include/hamlib/rotlist.h | 12 +++- kit/Makefile.am | 4 +- kit/kit.c | 14 +++- kit/kit.h | 4 +- kit/pcrotor.c | 138 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 kit/pcrotor.c diff --git a/include/hamlib/rotlist.h b/include/hamlib/rotlist.h index 196467c20..eb5152efa 100644 --- a/include/hamlib/rotlist.h +++ b/include/hamlib/rotlist.h @@ -3,7 +3,7 @@ * Copyright (c) 2000-2008 by Stephane Fillod * Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton * - * $Id: rotlist.h,v 1.13 2008-09-21 19:34:16 fillods Exp $ + * $Id: rotlist.h,v 1.14 2008-10-31 07:45:17 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -150,6 +150,15 @@ #define ROT_BACKEND_GS232A "gs232a" #define ROT_MODEL_GS232A ROT_MAKE_MODEL(ROT_GS232A, 1) +/*! \def ROT_MODEL_PCROTOR + * \brief A macro that returns the model number of the PcRotor/WA6UFQ backend. + * + * The kit backend can be used with home brewed rotators. + */ +#define ROT_KIT 7 +#define ROT_BACKEND_KIT "kit" +#define ROT_MODEL_PCROTOR ROT_MAKE_MODEL(ROT_KIT, 1) + /*! \typedef typedef int rot_model_t \brief Convenience type definition for rotator model. */ @@ -170,6 +179,7 @@ typedef int rot_model_t; { ROT_ROTOREZ, ROT_BACKEND_ROTOREZ }, \ { ROT_SARTEK, ROT_BACKEND_SARTEK }, \ { ROT_GS232A, ROT_BACKEND_GS232A }, \ + { ROT_KIT, ROT_BACKEND_KIT }, \ { 0, NULL }, /* end */ \ } diff --git a/kit/Makefile.am b/kit/Makefile.am index 3b5cb17c0..bc16de2ce 100644 --- a/kit/Makefile.am +++ b/kit/Makefile.am @@ -5,8 +5,10 @@ AM_CXXFLAGS = @USRP_CFLAGS@ KITSRCLIST = elektor304.c drt1.c dwt.c usrp.c usrp_impl.cc elektor507.c \ dds60.c miniVNA.c +KITROTSRCLIST = pcrotor.c + lib_LTLIBRARIES = hamlib-kit.la -hamlib_kit_la_SOURCES = $(KITSRCLIST) kit.c +hamlib_kit_la_SOURCES = $(KITSRCLIST) $(KITROTSRCLIST) kit.c hamlib_kit_la_LDFLAGS = -no-undefined -module -avoid-version hamlib_kit_la_LIBADD = $(top_builddir)/lib/libmisc.la \ $(USRP_LIBS) \ diff --git a/kit/kit.c b/kit/kit.c index ad1e73cca..7e89bcc42 100644 --- a/kit/kit.c +++ b/kit/kit.c @@ -2,7 +2,7 @@ * Hamlib KIT backend - main file * Copyright (c) 2004-2008 by Stephane Fillod * - * $Id: kit.c,v 1.7 2008-04-11 18:03:53 fillods Exp $ + * $Id: kit.c,v 1.8 2008-10-31 07:45:17 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -59,4 +59,16 @@ DECLARE_INITRIG_BACKEND(kit) return RIG_OK; } +/* + * initrots_kit is called by rot_backend_load + */ +DECLARE_INITROT_BACKEND(kit) +{ + rig_debug(RIG_DEBUG_VERBOSE, "kit: _init called\n"); + + rot_register(&pcrotor_caps); + + return RIG_OK; +} + diff --git a/kit/kit.h b/kit/kit.h index 4c760bd7f..2a38cdf3c 100644 --- a/kit/kit.h +++ b/kit/kit.h @@ -2,7 +2,7 @@ * Hamlib KIT backend - main header * Copyright (c) 2004-2008 by Stephane Fillod * - * $Id: kit.h,v 1.6 2008-04-11 18:03:53 fillods Exp $ + * $Id: kit.h,v 1.7 2008-10-31 07:45:17 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -34,4 +34,6 @@ extern const struct rig_caps usrp_caps; extern const struct rig_caps dds60_caps; extern const struct rig_caps miniVNA_caps; +extern const struct rot_caps pcrotor_caps; + #endif /* _KIT_H */ diff --git a/kit/pcrotor.c b/kit/pcrotor.c new file mode 100644 index 000000000..9b7597efe --- /dev/null +++ b/kit/pcrotor.c @@ -0,0 +1,138 @@ +/* + * Hamlib Rotator backend - PcRotor/WA6UFQ parallel port + * Copyright (c) 2001-2008 by Stephane Fillod + * + * $Id: pcrotor.c,v 1.1 2008-10-31 07:45:17 fillods Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library 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 Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include /* String function definitions */ +#include /* UNIX standard function definitions */ + +#include "hamlib/rotator.h" +#include "parallel.h" +#include "misc.h" + + +/* ************************************************************************* */ +//pcrotor_set_position(ROT *rot, azimuth_t az, elevation_t el) + +#define PCROTOR_POWER 0x20 +#define PCROTOR_CW 0x40 +#define PCROTOR_CCW 0x80 +#define PCROTOR_MASK (PCROTOR_CCW|PCROTOR_CW|PCROTOR_POWER) + +static int setDirection(hamlib_port_t *port, unsigned char outputvalue) +{ + int ret; + + par_lock (port); + + /* set the data bits. + * Should we read before write to not trample the lower significant bits? + */ + ret = par_write_data(port, outputvalue); + + par_unlock (port); + + return ret; +} + + +static int +pcrotor_stop(ROT *rot) +{ + /* CW=0, CCW=0, Power-up=0 */ + return setDirection(&rot->state.rotport, 0); +} + +static int +pcrotor_move(ROT *rot, int direction, int speed) +{ + unsigned char outputvalue; + + rig_debug(RIG_DEBUG_TRACE, "%s called: %d %d\n", __FUNCTION__, direction, speed); + + switch(direction) { + case ROT_MOVE_CCW: + outputvalue = PCROTOR_POWER|PCROTOR_CCW; + break; + case ROT_MOVE_CW: + outputvalue = PCROTOR_POWER|PCROTOR_CCW; + break; + case 0: + /* Stop */ + outputvalue = 0; + break; + default: + return -RIG_EINVAL; + } + + return setDirection(&rot->state.rotport, outputvalue); +} + + +/* ************************************************************************* */ +/* + * PcRotor rotator capabilities. + * + * Control Interface schematics from, courtersy of Bob Hillard WA6UFQ: + * http://www.dxzone.com/cgi-bin/dir/jump2.cgi?ID=11173 + * + * DB25-7=Data-5= Power up/Sleep + * DB25-8=Data-6= CW + * DB25-9=Data-7= CCW + * + * There's no feedback. + */ + +/** Fodtrack implement essentially only the set position function. + * + */ +const struct rot_caps pcrotor_caps = { + .rot_model = ROT_MODEL_PCROTOR, + .model_name = "PcRotor", + .mfg_name = "WA6UFQ", + .version = "0.1", + .copyright = "LGPL", + .status = RIG_STATUS_UNTESTED, + .rot_type = ROT_TYPE_OTHER, + .port_type = RIG_PORT_PARALLEL, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 200, + .retry = 3, + + .min_az = 0, + .max_az = 360, + .min_el = 0, + .max_el = 0, + + .priv = NULL, /* priv */ + + .move = pcrotor_move, + .stop = pcrotor_stop, + //.set_position = pcrotor_set_position, + //.get_position = pcrotor_get_position, +}; + +/* end of file */