From f5c26bf235c24aa7c1f1f02bf11f06a4c96e2dd3 Mon Sep 17 00:00:00 2001 From: "Matthew J. Wolf" Date: Fri, 10 Mar 2023 13:03:14 -0500 Subject: [PATCH] Inital add of rotator saebrtrack --- configure.ac | 3 +- include/hamlib/rotlist.h | 13 ++ rotators/saebrtrack/Android.mk | 12 ++ rotators/saebrtrack/Makefile.am | 5 + rotators/saebrtrack/saebrtrack.c | 197 +++++++++++++++++++++++++++++ rotators/saebrtrack/saebrtrack.h | 51 ++++++++ rotators/saebrtrack/saebrtrack.txt | 47 +++++++ src/rot_reg.c | 3 + 8 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 rotators/saebrtrack/Android.mk create mode 100644 rotators/saebrtrack/Makefile.am create mode 100644 rotators/saebrtrack/saebrtrack.c create mode 100644 rotators/saebrtrack/saebrtrack.h create mode 100644 rotators/saebrtrack/saebrtrack.txt diff --git a/configure.ac b/configure.ac index d38607d8e..92ce17f83 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ dnl Beware of duplication should a backend directory include both rig and dnl rotor definitions, e.g. "dummy". Optional backends will not be listed dnl here but will be added later, e.g. "winradio". RIG_BACKEND_LIST="rigs/adat rigs/alinco rigs/aor rigs/barrett rigs/codan rigs/dorji rigs/drake rigs/dummy rigs/elad rigs/flexradio rigs/icom rigs/icmarine rigs/jrc rigs/kachina rigs/kenwood rigs/kit rigs/lowe rigs/pcr rigs/prm80 rigs/racal rigs/rft rigs/rs rigs/skanti rigs/tapr rigs/tentec rigs/tuner rigs/uniden rigs/winradio rigs/wj rigs/yaesu rigs/gomspace rigs/mds" -ROT_BACKEND_LIST="rotators/amsat rotators/apex rotators/ars rotators/celestron rotators/cnctrk rotators/grbltrk rotators/easycomm rotators/ether6 rotators/flir rotators/fodtrack rotators/gs232a rotators/heathkit rotators/m2 rotators/meade rotators/rotorez rotators/sartek rotators/spid rotators/ts7400 rotators/prosistel rotators/ioptron rotators/satel rotators/radant" +ROT_BACKEND_LIST="rotators/amsat rotators/apex rotators/ars rotators/celestron rotators/cnctrk rotators/grbltrk rotators/easycomm rotators/ether6 rotators/flir rotators/fodtrack rotators/gs232a rotators/heathkit rotators/m2 rotators/meade rotators/rotorez rotators/sartek rotators/saebrtrack rotators/spid rotators/ts7400 rotators/prosistel rotators/ioptron rotators/satel rotators/radant" # Amplifiers are all in the amplifiers directory AMP_BACKEND_LIST="amplifiers/elecraft amplifiers/gemini" @@ -864,6 +864,7 @@ rotators/meade/Makefile rotators/prosistel/Makefile rotators/rotorez/Makefile rotators/sartek/Makefile +rotators/saebrtrack/Makefile rotators/spid/Makefile rotators/ts7400/Makefile rotators/indi/Makefile diff --git a/include/hamlib/rotlist.h b/include/hamlib/rotlist.h index 11c981bd7..d787c29cc 100644 --- a/include/hamlib/rotlist.h +++ b/include/hamlib/rotlist.h @@ -679,6 +679,19 @@ //! @endcond #define ROT_MODEL_APEX_SHARED_LOOP ROT_MAKE_MODEL(ROT_APEX, 1) +/** + * \brief A macro that returns the model number of the SAEBRTRACK backend. + * + * \def ROT_MODEL_SAEBRTRACK + * + * The SAEBRTRACK backend can be used with SAEBRTRACK * rotators. + */ +//! @cond Doxygen_Suppress +#define ROT_SAEBRTRACK 27 +#define ROT_BACKEND_SAEBRTRACK "SAEBRTrack" +//! @endcond +#define ROT_MODEL_SAEBRTRACK ROT_MAKE_MODEL(ROT_SAEBRTRACK, 1) + /** * \brief Convenience type definition for a rotator model. diff --git a/rotators/saebrtrack/Android.mk b/rotators/saebrtrack/Android.mk new file mode 100644 index 000000000..750cf035e --- /dev/null +++ b/rotators/saebrtrack/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := saebrtrack.c +LOCAL_MODULE := saebrtrack + +LOCAL_CFLAGS := +LOCAL_C_INCLUDES := android include src +LOCAL_LDLIBS := -lhamlib -Lobj/local/$(TARGET_ARCH_ABI) + +include $(BUILD_STATIC_LIBRARY) diff --git a/rotators/saebrtrack/Makefile.am b/rotators/saebrtrack/Makefile.am new file mode 100644 index 000000000..97ee390a6 --- /dev/null +++ b/rotators/saebrtrack/Makefile.am @@ -0,0 +1,5 @@ + +noinst_LTLIBRARIES = libhamlib-saebrtrack.la +libhamlib_saebrtrack_la_SOURCES = saebrtrack.c saebrtrack.h + +EXTRA_DIST = saebrtrack.txt Android.mk diff --git a/rotators/saebrtrack/saebrtrack.c b/rotators/saebrtrack/saebrtrack.c new file mode 100644 index 000000000..e10623770 --- /dev/null +++ b/rotators/saebrtrack/saebrtrack.c @@ -0,0 +1,197 @@ +/* + * Hamlib Rotator backend - SAEBRTrack + * Copyright (c) 2023 by Matthew J Wolf + * Contributed by Matthew J Wolf + * + * Hamlib Rotator backend - Easycom + * Copyright (c) 2001-2003 by Stephane Fillod + * Contributed by Francois Retief + * Copyright (c) 2014 by Alexander Schultze + * + * + * 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. + * + * 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. + * + * 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 + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include + +#include "hamlib/rotator.h" +#include "serial.h" +#include "misc.h" +#include "register.h" + +#include "saebrtrack.h" + +/* ************************************************************************* */ +/** + * saebrtrack_transaction + * + * Assumes rot!=NULL and cmdstr!=NULL + * + * cmdstr - string to send to rotator + * data - buffer for reply string + * data_len - (input) Maximum size of buffer + * (output) Number of bytes read. + */ +static int +saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len) +{ + struct rot_state *rs; + int retval; + + rig_debug(RIG_DEBUG_TRACE, "%s called: %s\n", __func__, cmdstr); + + if (!rot) + { + return -RIG_EINVAL; + } + + rs = &rot->state; + rig_flush(&rs->rotport); + retval = write_block(&rs->rotport, cmdstr, strlen(cmdstr)); + + if (retval != RIG_OK) + { + goto transaction_quit; + } + + if (data == NULL) + { + return RIG_OK; /* don't want a reply */ + } + + retval = read_string(&rs->rotport, data, data_len, "\n", 1); + + if (retval < 0) + { + rig_debug(RIG_DEBUG_TRACE, "%s read_string failed with status %d\n", __func__, + retval); + goto transaction_quit; + } + else + { + rig_debug(RIG_DEBUG_TRACE, "%s read_string: %s\n", __func__, data); + retval = RIG_OK; + } + +transaction_quit: + return retval; +} + +/* ************************************************************************* */ + +static int +saebrtrack_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) +{ + char cmdstr[64]; + int retval; + rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); + + /* Non Easycom standard */ + sprintf(cmdstr, "AZ%05.1f EL%05.1f UP000 XXX DN000 XXX\n", az, el); + + retval = saebrtrack_transaction(rot, cmdstr, NULL, 0); + + if (retval != RIG_OK) + { + return retval; + } + + /* TODO: Error processing */ + return RIG_OK; +} + +/* + * Get Info + * returns the model name string + */ +static const char *saebrtrack_rot_get_info(ROT *rot) +{ + const struct rot_caps *rc; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rot) + { + return (const char *) - RIG_EINVAL; + } + + rc = rot->caps; + + return rc->model_name; +} + + +/* ************************************************************************* */ +/* + * saebrtrack rotator capabilities. + */ + +/** saebrtrackI implement essentially only the set position function, but + * I included the stop command too. The radio control tags is only included + * as dummy entries because the spec require them. + */ +const struct rot_caps saebrtrack_rot_caps = +{ + ROT_MODEL(ROT_MODEL_SAEBRTRACK), + .model_name = "SAEBRTrack", + .mfg_name = "Hamlib", + .version = "20200810.0", + .copyright = "LGPL", + .status = RIG_STATUS_BETA, + .rot_type = ROT_TYPE_OTHER, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 9600, + .serial_rate_max = 19200, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 200, + .retry = 3, + + .min_az = 0.0, + .max_az = 360.0, + .min_el = 0.0, + .max_el = 180.0, + + .priv = NULL, /* priv */ + + .set_position = saebrtrack_rot_set_position, + .get_info = saebrtrack_rot_get_info, +}; + +/* ************************************************************************* */ + +DECLARE_INITROT_BACKEND(saebrtrack) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + rot_register(&saebrtrack_rot_caps); + return RIG_OK; +} + +/* ************************************************************************* */ +/* end of file */ diff --git a/rotators/saebrtrack/saebrtrack.h b/rotators/saebrtrack/saebrtrack.h new file mode 100644 index 000000000..e20586122 --- /dev/null +++ b/rotators/saebrtrack/saebrtrack.h @@ -0,0 +1,51 @@ +/* + * Hamlib Rotator backend - SAEBRTrack interface protocol + * Copyright (c) 2023 by Matthew J Wolf + * Contributed by Matthew J Wolf + * + * Hamlib Rotator backend - Easycomm interface protocol + * Copyright (c) 2001-2003 by Stephane Fillod + * Contributed by Francois Retief + * Copyright (c) 2014 by Alexander Schultze + * + * + * 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. + * + * 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. + * + * 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 + * + */ + +#ifndef _ROT_SABEBRTRACK_H +#define _ROT_SABEBRTRACK_H 1 + +#include "token.h" + +extern const struct rot_caps saebrtrack_rot_caps; +// extern const struct rot_caps easycomm2_rot_caps; +// extern const struct rot_caps easycomm3_rot_caps; + +/* + * Tokens used by rotorez_rot_set_conf and get_conf and the 'C' command in rotctl + * and rotctld. + */ + +#define TOK_GET_CONFIG TOKEN_BACKEND(1) +#define TOK_SET_CONFIG TOKEN_BACKEND(2) +#define TOK_GET_STATUS TOKEN_BACKEND(3) +#define TOK_GET_ERRORS TOKEN_BACKEND(4) +#define TOK_GET_VERSION TOKEN_BACKEND(5) +#define TOK_GET_INPUT TOKEN_BACKEND(6) +#define TOK_SET_OUTPUT TOKEN_BACKEND(7) +#define TOK_GET_ANALOG_INPUT TOKEN_BACKEND(8) + +#endif /* _ROT_SABEBRTRACK_H */ diff --git a/rotators/saebrtrack/saebrtrack.txt b/rotators/saebrtrack/saebrtrack.txt new file mode 100644 index 000000000..06f8b02fc --- /dev/null +++ b/rotators/saebrtrack/saebrtrack.txt @@ -0,0 +1,47 @@ +10-AUG-2020 Matthew J. Wolf Email: mwolf at speciosus.net + +I wanted to use Hamlib with my Amsat Tricked-Out WRAPS satellite antenna +rotator [1],[2] with Hamlib and gpredict. During testing I discovered that the + WARPS implementation of EASYCOMM I rotator protocol is not correct. + +The EASYCOMM I specification states "The Az and El values (aaa.a and eee.e) +are not fixed width." + +The WRAPS EASYCOMM implementation is FIXED WIDTH! The WRAPS does not work with +Hamlib's correct implementation of the EASYCOMM protocol. + +WARPS is expecting a zero padded number for the Az and El values. Leading +zeros need to be added. +Example for Az of 99 and El of 10: +WARPS: + AZ099.0 EL010.0 UP000 XXX DN000 XXX +EASYCOMM I: + AZ99.0 EL10.0 UP000 XXX DN000 XXX + +The SAEBRTrack rotator backend is a hack of the Hamlib EASYCOMM rotator +backend. I copied EASYCOMM backend and removed what was not needed. + +I named the Hamlib rotator backend SAEBRTrack because that is the rotator +protocol that is used with the WRAPS in the Microsoft windows pcsat32 program. + +The SAEBRTrack rotator backend only supports changing the rotor's Az and El. + +I have tested the rotator backend for Az and El changes with my Amsat WRAPS. + +The backend should work with original SAEBRTrack [3] and derivatives. + +The specification of EASYCOMM I protocol the are in the easycomm.txt file in +the EASYCOMM rotator backend source directory + +References: +[1] M. Spencer. + WRAPS Rotor Enhancements Add a Second Beam and Circular Polarization". + The AMSAT Journal. vol. 37, no. 3, pp. 25 to 31. 2014. + +[2] Amsat.org, 2020. [Online]. + Available: https://www.amsat.org/wordpress/xtra/WRAPSArticlewithStoreAd.pdf. + [Accessed: 10 Aug 2020]. + +[1]"saebrtrack - marklhammond", Sites.google.com, 2020. [Online]. +Available: https://sites.google.com/site/marklhammond/saebrtrack. +[Accessed: 10 Aug 2020]. diff --git a/src/rot_reg.c b/src/rot_reg.c index 26161b54d..44c0d88b9 100644 --- a/src/rot_reg.c +++ b/src/rot_reg.c @@ -92,6 +92,8 @@ DEFINE_INITROT_BACKEND(androidsensor); DEFINE_INITROT_BACKEND(grbltrk); DEFINE_INITROT_BACKEND(flir); DEFINE_INITROT_BACKEND(apex); +DEFINE_INITROT_BACKEND(saebrtrack); + //! @endcond /** @@ -142,6 +144,7 @@ static struct { ROT_GRBLTRK, ROT_BACKEND_GRBLTRK, ROT_FUNCNAMA(grbltrk) }, { ROT_FLIR, ROT_BACKEND_FLIR, ROT_FUNCNAMA(flir) }, { ROT_APEX, ROT_BACKEND_APEX, ROT_FUNCNAMA(apex) }, + { ROT_SAEBRTRACK, ROT_BACKEND_SAEBRTRACK, ROT_FUNCNAMA(saebrtrack)}, { 0, NULL }, /* end */ };