2003-06-22 19:36:37 +00:00
|
|
|
/*
|
|
|
|
* Hamlib backend library for the SARtek rotor command set.
|
|
|
|
*
|
|
|
|
* sartek.c - (C) Stephane Fillod 2003
|
|
|
|
*
|
|
|
|
*
|
2011-08-21 23:40:23 +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.
|
2003-06-22 19:36:37 +00:00
|
|
|
*
|
2011-08-21 23:40:23 +00:00
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
2003-06-22 19:36:37 +00:00
|
|
|
*
|
2011-08-21 23:40:23 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-06-22 19:36:37 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-10-01 19:32:04 +00:00
|
|
|
#include <stdio.h>
|
2003-06-22 19:36:37 +00:00
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
|
|
|
|
#include "hamlib/rotator.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "register.h"
|
|
|
|
|
|
|
|
#include "sartek.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* *************************************
|
|
|
|
*
|
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
|
|
|
* Separate model capabilities
|
2003-06-22 19:36:37 +00:00
|
|
|
*
|
|
|
|
* *************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SARtek rotor capabilities
|
|
|
|
*
|
|
|
|
* Documentation from:
|
2019-11-30 16:19:08 +00:00
|
|
|
* http://www.hosenose.com/sartek/ifcspecs.htm
|
2003-06-22 19:36:37 +00:00
|
|
|
*/
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct rot_caps sartek_rot_caps =
|
|
|
|
{
|
2020-03-06 05:48:14 +00:00
|
|
|
ROT_MODEL(ROT_MODEL_SARTEK1),
|
2019-11-30 16:19:08 +00:00
|
|
|
.model_name = "SARtek-1",
|
|
|
|
.mfg_name = "SARtek",
|
2020-06-08 21:13:08 +00:00
|
|
|
.version = "20061007.0",
|
2019-11-30 16:19:08 +00:00
|
|
|
.copyright = "LGPL",
|
2022-04-16 22:39:50 +00:00
|
|
|
.status = RIG_STATUS_BETA,
|
2019-11-30 16:19:08 +00:00
|
|
|
.rot_type = ROT_TYPE_OTHER,
|
|
|
|
.port_type = RIG_PORT_SERIAL,
|
|
|
|
.serial_rate_min = 1200,
|
|
|
|
.serial_rate_max = 1200,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 2,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
|
|
|
.write_delay = 0,
|
|
|
|
.post_write_delay = 0,
|
|
|
|
.timeout = 1000,
|
|
|
|
.retry = 3,
|
|
|
|
|
|
|
|
.min_az = 0,
|
|
|
|
.max_az = 360,
|
|
|
|
.min_el = 0,
|
|
|
|
.max_el = 0,
|
|
|
|
|
|
|
|
.priv = NULL, /* priv */
|
|
|
|
|
|
|
|
.set_position = sartek_rot_set_position,
|
|
|
|
.stop = sartek_rot_stop,
|
2003-06-22 19:36:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************
|
|
|
|
*
|
|
|
|
* API functions
|
|
|
|
*
|
|
|
|
* ************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set position
|
|
|
|
* SARtek protocol supports azimuth only--elevation is ignored
|
|
|
|
* Range is converted to an integer string, 0 to 360 degrees
|
|
|
|
*/
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|
|
|
elevation_t elevation)
|
2003-06-22 19:36:37 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
char cmdstr[8];
|
2022-01-23 04:28:32 +00:00
|
|
|
int err;
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (!rot)
|
|
|
|
{
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (azimuth < 0 || azimuth > 360)
|
|
|
|
{
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (azimuth < 2)
|
|
|
|
{
|
|
|
|
azimuth = 2;
|
|
|
|
}
|
|
|
|
else if (azimuth > 358)
|
|
|
|
{
|
|
|
|
azimuth = 358;
|
|
|
|
}
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2022-01-23 04:28:32 +00:00
|
|
|
SNPRINTF(cmdstr, sizeof(cmdstr), "P%c", (int)((azimuth * 255) / 360));
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
err = write_block(&rot->state.rotport, (unsigned char *) cmdstr,
|
|
|
|
strlen(cmdstr));
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (err != RIG_OK)
|
|
|
|
{
|
|
|
|
return err;
|
|
|
|
}
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2003-06-22 19:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop rotation
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int sartek_rot_stop(ROT *rot)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2021-12-18 21:49:45 +00:00
|
|
|
err = write_block(&rot->state.rotport, (unsigned char *) "P\0", 2);
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (err != RIG_OK)
|
|
|
|
{
|
|
|
|
return err;
|
|
|
|
}
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2003-06-22 19:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize backend
|
|
|
|
*/
|
|
|
|
|
|
|
|
DECLARE_INITROT_BACKEND(sartek)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rot_register(&sartek_rot_caps);
|
2003-06-22 19:36:37 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2003-06-22 19:36:37 +00:00
|
|
|
}
|
|
|
|
|