2002-11-28 22:24:10 +00:00
|
|
|
/*
|
|
|
|
* Hamlib Rotator backend - Fodtrack parallel port
|
2010-04-25 21:15:54 +00:00
|
|
|
* Copyright (c) 2001-2010 by Stephane Fillod
|
2002-11-28 22:24:10 +00:00
|
|
|
*
|
|
|
|
*
|
2011-08-20 23:56:40 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2002-11-28 22:24:10 +00:00
|
|
|
*
|
2011-08-20 23:56:40 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2002-11-28 22:24:10 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-20 23:56:40 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2002-11-28 22:24:10 +00:00
|
|
|
*
|
2011-08-20 23:56:40 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2002-11-28 22:24:10 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-20 23:56:40 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-11-28 22:24:10 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-04-07 22:42:11 +00:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
2002-11-28 22:24:10 +00:00
|
|
|
#include <sys/ioctl.h>
|
2003-04-07 22:42:11 +00:00
|
|
|
#endif
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2022-12-10 05:32:51 +00:00
|
|
|
#ifdef HAVE_PARALLEL
|
2003-06-22 19:52:40 +00:00
|
|
|
#ifdef HAVE_LINUX_PARPORT_H
|
2002-11-28 22:24:10 +00:00
|
|
|
#include <linux/parport.h>
|
|
|
|
#endif
|
2022-12-10 05:32:51 +00:00
|
|
|
#endif
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#include "hamlib/rotator.h"
|
2004-10-02 20:37:24 +00:00
|
|
|
#include "parallel.h"
|
2003-04-07 22:42:11 +00:00
|
|
|
#include "misc.h"
|
2003-04-16 22:30:43 +00:00
|
|
|
#include "register.h"
|
2002-11-28 22:24:10 +00:00
|
|
|
|
|
|
|
#include "fodtrack.h"
|
|
|
|
|
2003-09-28 15:34:44 +00:00
|
|
|
#ifndef CP_ACTIVE_LOW_BITS
|
|
|
|
#define CP_ACTIVE_LOW_BITS 0x0B
|
|
|
|
#endif
|
|
|
|
|
2002-11-28 22:24:10 +00:00
|
|
|
/* ************************************************************************* */
|
|
|
|
|
|
|
|
/** outputs an direction to the interface */
|
2019-11-30 16:19:08 +00:00
|
|
|
static int setDirection(hamlib_port_t *port, unsigned char outputvalue,
|
|
|
|
int direction)
|
2002-11-28 22:24:10 +00:00
|
|
|
{
|
2023-10-13 22:36:29 +00:00
|
|
|
int retval;
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char outputstatus;
|
|
|
|
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_lock(port);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
// set the data bits
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_write_data(port, outputvalue);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
|
|
|
// autofd=true --> azimuth otherwise elevation
|
2019-11-30 16:19:08 +00:00
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
outputstatus = PARPORT_CONTROL_AUTOFD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outputstatus = 0;
|
|
|
|
}
|
|
|
|
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
// and now the strobe impulse
|
2020-01-08 05:18:56 +00:00
|
|
|
hl_usleep(1);
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
outputstatus = PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_STROBE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outputstatus = PARPORT_CONTROL_STROBE;
|
|
|
|
}
|
|
|
|
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2020-01-08 05:18:56 +00:00
|
|
|
hl_usleep(1);
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
outputstatus = PARPORT_CONTROL_AUTOFD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outputstatus = 0;
|
|
|
|
}
|
|
|
|
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_write_control(port, outputstatus ^ CP_ACTIVE_LOW_BITS);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2023-10-13 22:36:29 +00:00
|
|
|
retval = par_unlock(port);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\n", __func__, __LINE__, rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
2002-11-28 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fodtrack_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
int retval;
|
|
|
|
hamlib_port_t *pport;
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el);
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
pport = &rot->state.rotport;
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
retval = setDirection(pport, el / (float)rot->state.max_el * 255.0, 0);
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
retval = setDirection(pport, az / (float)rot->state.max_az * 255.0, 1);
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return RIG_OK;
|
2002-11-28 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
/*
|
|
|
|
* Fodtrack rotator capabilities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Fodtrack implement essentially only the set position function.
|
|
|
|
*/
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct rot_caps fodtrack_rot_caps =
|
|
|
|
{
|
2020-03-06 05:48:14 +00:00
|
|
|
ROT_MODEL(ROT_MODEL_FODTRACK),
|
2019-11-30 16:19:08 +00:00
|
|
|
.model_name = "Fodtrack",
|
|
|
|
.mfg_name = "XQ2FOD",
|
2020-06-08 21:13:08 +00:00
|
|
|
.version = "20200107.0",
|
2019-11-30 16:19:08 +00:00
|
|
|
.copyright = "LGPL",
|
|
|
|
.status = RIG_STATUS_STABLE,
|
|
|
|
.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 = 450,
|
|
|
|
.min_el = 0,
|
|
|
|
.max_el = 180,
|
|
|
|
|
|
|
|
.priv = NULL, /* priv */
|
|
|
|
|
|
|
|
.set_position = fodtrack_set_position,
|
2002-11-28 22:24:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
|
2003-04-16 22:30:43 +00:00
|
|
|
DECLARE_INITROT_BACKEND(fodtrack)
|
2002-11-28 22:24:10 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rot_register(&fodtrack_rot_caps);
|
2002-11-28 22:24:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2002-11-28 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
/* end of file */
|