2001-12-27 21:46:25 +00:00
|
|
|
/*
|
2002-01-27 14:55:30 +00:00
|
|
|
* Hamlib Interface - rotator configuration interface
|
2010-04-25 17:20:44 +00:00
|
|
|
* Copyright (c) 2000-2010 by Stephane Fillod
|
2001-12-27 21:46:25 +00:00
|
|
|
*
|
|
|
|
*
|
2011-08-22 01:07:57 +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.
|
2001-12-27 21:46:25 +00:00
|
|
|
*
|
2011-08-22 01:07:57 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2001-12-27 21:46:25 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-22 01:07:57 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-12-27 21:46:25 +00:00
|
|
|
*
|
2011-08-22 01:07:57 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2001-12-27 21:46:25 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-22 01:07:57 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-12-27 21:46:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \addtogroup rotator
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Rotator Configuration Interface
|
|
|
|
* \file rot_conf.c
|
|
|
|
*/
|
|
|
|
|
2001-12-27 21:46:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2017-10-05 02:32:08 +00:00
|
|
|
# include "config.h"
|
2001-12-27 21:46:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h> /* Standard input/output definitions */
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
|
|
|
|
#include <hamlib/rotator.h>
|
|
|
|
|
|
|
|
#include "rot_conf.h"
|
2002-01-27 14:55:30 +00:00
|
|
|
#include "token.h"
|
2001-12-27 21:46:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-04-25 17:20:44 +00:00
|
|
|
* Configuration options available in the rot->state struct.
|
2001-12-27 21:46:25 +00:00
|
|
|
*/
|
2017-10-05 02:32:08 +00:00
|
|
|
static const struct confparams rotfrontend_cfg_params[] =
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
{
|
|
|
|
TOK_PATHNAME, "rot_pathname", "Rig path name",
|
|
|
|
"Path name to the device file of the rotator",
|
|
|
|
"/dev/rotator", RIG_CONF_STRING,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_WRITE_DELAY, "write_delay", "Write delay",
|
|
|
|
"Delay in ms between each byte sent out",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { 0, 1000, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_POST_WRITE_DELAY, "post_write_delay", "Post write delay",
|
|
|
|
"Delay in ms between each command sent out",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { 0, 1000, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_TIMEOUT, "timeout", "Timeout", "Timeout in ms",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { 0, 10000, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_RETRY, "retry", "Retry", "Max number of retry",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { 0, 10, 1 } }
|
|
|
|
},
|
2020-12-03 05:47:30 +00:00
|
|
|
{
|
|
|
|
TOK_FLUSHX, "flushx", "Flush with read instead of TCFLUSH",
|
|
|
|
"True enables flushing serial port with read instead of TCFLUSH -- MicroHam",
|
|
|
|
"0", RIG_CONF_CHECKBUTTON, { }
|
|
|
|
},
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TOK_MIN_AZ, "min_az", "Minimum azimuth",
|
|
|
|
"Minimum rotator azimuth in degrees",
|
|
|
|
"-180", RIG_CONF_NUMERIC, { .n = { -360, 360, .001 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_MAX_AZ, "max_az", "Maximum azimuth",
|
|
|
|
"Maximum rotator azimuth in degrees",
|
|
|
|
"180", RIG_CONF_NUMERIC, { .n = { -360, 360, .001 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_MIN_EL, "min_el", "Minimum elevation",
|
|
|
|
"Minimum rotator elevation in degrees",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { -90, 180, .001 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_MAX_EL, "max_el", "Maximum elevation",
|
|
|
|
"Maximum rotator elevation in degrees",
|
|
|
|
"90", RIG_CONF_NUMERIC, { .n = { -90, 180, .001 } }
|
|
|
|
},
|
2019-11-24 05:08:27 +00:00
|
|
|
{
|
|
|
|
TOK_SOUTH_ZERO, "south_zero", "South is zero deg",
|
|
|
|
"Adjust azimuth 180 degrees for south oriented rotators",
|
|
|
|
"0", RIG_CONF_CHECKBUTTON,
|
|
|
|
},
|
2017-08-05 14:09:12 +00:00
|
|
|
|
|
|
|
{ RIG_CONF_END, NULL, }
|
2010-04-25 17:20:44 +00:00
|
|
|
};
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
static const struct confparams rotfrontend_serial_cfg_params[] =
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
{
|
|
|
|
TOK_SERIAL_SPEED, "serial_speed", "Serial speed",
|
|
|
|
"Serial port baud rate",
|
|
|
|
"0", RIG_CONF_NUMERIC, { .n = { 300, 115200, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_DATA_BITS, "data_bits", "Serial data bits",
|
|
|
|
"Serial port data bits",
|
|
|
|
"8", RIG_CONF_NUMERIC, { .n = { 5, 8, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_STOP_BITS, "stop_bits", "Serial stop bits",
|
|
|
|
"Serial port stop bits",
|
|
|
|
"1", RIG_CONF_NUMERIC, { .n = { 0, 3, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_PARITY, "serial_parity", "Serial parity",
|
|
|
|
"Serial port parity",
|
|
|
|
"None", RIG_CONF_COMBO, { .c = {{ "None", "Odd", "Even", "Mark", "Space", NULL }} }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TOK_HANDSHAKE, "serial_handshake", "Serial handshake",
|
|
|
|
"Serial port handshake",
|
|
|
|
"None", RIG_CONF_COMBO, { .c = {{ "None", "XONXOFF", "Hardware", NULL }} }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ RIG_CONF_END, NULL, }
|
2001-12-27 21:46:25 +00:00
|
|
|
};
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \brief Set rotator state info from alpha input
|
|
|
|
* \param rot
|
|
|
|
* \param token TOK_... specifying which info to set
|
|
|
|
* \param val input
|
|
|
|
* \return RIG_OK or < 0 error
|
|
|
|
*
|
2001-12-27 21:46:25 +00:00
|
|
|
* assumes rot!=NULL, val!=NULL
|
|
|
|
*/
|
|
|
|
int frontrot_set_conf(ROT *rot, token_t token, const char *val)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
struct rot_state *rs;
|
|
|
|
int val_i;
|
|
|
|
|
|
|
|
rs = &rot->state;
|
|
|
|
|
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
case TOK_PATHNAME:
|
|
|
|
strncpy(rs->rotport.pathname, val, FILPATHLEN - 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_WRITE_DELAY:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.write_delay = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_POST_WRITE_DELAY:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.post_write_delay = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_TIMEOUT:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.timeout = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_RETRY:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.retry = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_SERIAL_SPEED:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.parm.serial.rate = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_DATA_BITS:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.parm.serial.data_bits = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_STOP_BITS:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (1 != sscanf(val, "%d", &val_i))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->rotport.parm.serial.stop_bits = val_i;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_PARITY:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!strcmp(val, "None"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.parity = RIG_PARITY_NONE;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "Odd"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.parity = RIG_PARITY_ODD;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "Even"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.parity = RIG_PARITY_EVEN;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "Mark"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.parity = RIG_PARITY_MARK;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "Space"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.parity = RIG_PARITY_SPACE;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_HANDSHAKE:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!strcmp(val, "None"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_NONE;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "XONXOFF"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_XONXOFF;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(val, "Hardware"))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
2017-10-05 02:32:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-12-03 05:47:30 +00:00
|
|
|
case TOK_FLUSHX:
|
|
|
|
rs->rotport.flushx = atoi(val);
|
|
|
|
break;
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
case TOK_MIN_AZ:
|
|
|
|
rs->min_az = atof(val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MAX_AZ:
|
|
|
|
rs->max_az = atof(val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MIN_EL:
|
|
|
|
rs->min_el = atof(val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MAX_EL:
|
|
|
|
rs->max_el = atof(val);
|
|
|
|
break;
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2019-11-24 05:08:27 +00:00
|
|
|
case TOK_SOUTH_ZERO:
|
|
|
|
rs->south_zero = atoi(val);
|
|
|
|
break;
|
2017-08-05 14:09:12 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2001-12-27 21:46:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \brief Get data from rotator state in alpha form
|
|
|
|
* \param rot non-null
|
|
|
|
* \param token TOK_... specifying which data to get
|
|
|
|
* \param val result non-null
|
|
|
|
* \return RIG_OK or < 0 if error
|
2001-12-27 21:46:25 +00:00
|
|
|
*/
|
|
|
|
int frontrot_get_conf(ROT *rot, token_t token, char *val)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
struct rot_state *rs;
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
rs = &rot->state;
|
|
|
|
|
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
case TOK_PATHNAME:
|
|
|
|
strcpy(val, rs->rotport.pathname);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_WRITE_DELAY:
|
|
|
|
sprintf(val, "%d", rs->rotport.write_delay);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_POST_WRITE_DELAY:
|
|
|
|
sprintf(val, "%d", rs->rotport.post_write_delay);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_TIMEOUT:
|
|
|
|
sprintf(val, "%d", rs->rotport.timeout);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_RETRY:
|
|
|
|
sprintf(val, "%d", rs->rotport.retry);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_SERIAL_SPEED:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(val, "%d", rs->rotport.parm.serial.rate);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_DATA_BITS:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(val, "%d", rs->rotport.parm.serial.data_bits);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_STOP_BITS:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(val, "%d", rs->rotport.parm.serial.stop_bits);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_PARITY:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
switch (rs->rotport.parm.serial.parity)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
case RIG_PARITY_NONE:
|
|
|
|
s = "None";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_PARITY_ODD:
|
|
|
|
s = "Odd";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_PARITY_EVEN:
|
|
|
|
s = "Even";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_PARITY_MARK:
|
|
|
|
s = "Mark";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_PARITY_SPACE:
|
|
|
|
s = "Space";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(val, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_HANDSHAKE:
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rs->rotport.type.rig != RIG_PORT_SERIAL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
switch (rs->rotport.parm.serial.handshake)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
case RIG_HANDSHAKE_NONE:
|
|
|
|
s = "None";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_HANDSHAKE_XONXOFF:
|
|
|
|
s = "XONXOFF";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_HANDSHAKE_HARDWARE:
|
|
|
|
s = "Hardware";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(val, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MIN_AZ:
|
|
|
|
sprintf(val, "%f", rs->min_az);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MAX_AZ:
|
|
|
|
sprintf(val, "%f", rs->max_az);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MIN_EL:
|
|
|
|
sprintf(val, "%f", rs->min_el);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOK_MAX_EL:
|
|
|
|
sprintf(val, "%f", rs->max_el);
|
|
|
|
break;
|
|
|
|
|
2020-03-10 22:00:44 +00:00
|
|
|
case TOK_SOUTH_ZERO:
|
|
|
|
sprintf(val, "%d", rs->south_zero);
|
|
|
|
break;
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2001-12-27 21:46:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \brief Executes cfunc on all the elements stored in the conf table
|
|
|
|
* \param rot non-null
|
|
|
|
* \param cfunc function(..)
|
|
|
|
* \param data
|
2011-08-22 01:07:57 +00:00
|
|
|
*
|
2001-12-27 21:46:25 +00:00
|
|
|
* start first with backend conf table, then finish with frontend table
|
|
|
|
*/
|
2017-08-05 14:09:12 +00:00
|
|
|
int HAMLIB_API rot_token_foreach(ROT *rot,
|
2017-10-05 02:32:08 +00:00
|
|
|
int (*cfunc)(const struct confparams *,
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_ptr_t),
|
2017-08-05 14:09:12 +00:00
|
|
|
rig_ptr_t data)
|
2001-12-27 21:46:25 +00:00
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
const struct confparams *cfp;
|
|
|
|
|
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!rot || !rot->caps || !cfunc)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
for (cfp = rotfrontend_cfg_params; cfp->name; cfp++)
|
|
|
|
{
|
|
|
|
if ((*cfunc)(cfp, data) == 0)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rot->caps->port_type == RIG_PORT_SERIAL)
|
|
|
|
{
|
|
|
|
for (cfp = rotfrontend_serial_cfg_params; cfp->name; cfp++)
|
|
|
|
{
|
|
|
|
if ((*cfunc)(cfp, data) == 0)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
for (cfp = rot->caps->cfgparams; cfp && cfp->name; cfp++)
|
|
|
|
{
|
|
|
|
if ((*cfunc)(cfp, data) == 0)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2001-12-27 21:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \brief lookup conf token by its name, return pointer to confparams struct.
|
|
|
|
* \param rot
|
|
|
|
* \param name
|
|
|
|
* \return confparams or NULL
|
2001-12-27 21:46:25 +00:00
|
|
|
*
|
|
|
|
* lookup backend config table first, then fall back to frontend.
|
|
|
|
* TODO: should use Lex to speed it up, strcmp hurts!
|
|
|
|
*/
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct confparams *HAMLIB_API rot_confparam_lookup(ROT *rot,
|
|
|
|
const char *name)
|
2001-12-27 21:46:25 +00:00
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
const struct confparams *cfp;
|
|
|
|
token_t token;
|
|
|
|
|
2020-03-10 13:43:42 +00:00
|
|
|
//rot_debug(RIG_DEBUG_VERBOSE, "%s called lookup=%s\n", __func__, name);
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!rot || !rot->caps)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0 returned for invalid format */
|
|
|
|
token = strtol(name, NULL, 0);
|
|
|
|
|
2020-03-10 13:43:42 +00:00
|
|
|
//rig_debug(RIG_DEBUG_TRACE, "%s: token=%d\n", __func__, (int)token);
|
2017-10-05 02:32:08 +00:00
|
|
|
for (cfp = rot->caps->cfgparams; cfp && cfp->name; cfp++)
|
|
|
|
{
|
2020-03-10 13:43:42 +00:00
|
|
|
//rig_debug(RIG_DEBUG_TRACE, "%s: name=%s cfp->name=%s cfp->token=%d, token=%d\n", __func__, name, cfp->name, (int)cfp->token, (int)token);
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!strcmp(cfp->name, name) || token == cfp->token)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return cfp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 13:43:42 +00:00
|
|
|
//rig_debug(RIG_DEBUG_TRACE, "%s: frontend check\n", __func__);
|
2017-10-05 02:32:08 +00:00
|
|
|
for (cfp = rotfrontend_cfg_params; cfp->name; cfp++)
|
|
|
|
{
|
2020-03-10 13:43:42 +00:00
|
|
|
//rig_debug(RIG_DEBUG_TRACE, "%s: name=%s cfp->name=%s cfp->token=%d, token=%d\n", __func__, name, cfp->name, (int)cfp->token, (int)token);
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!strcmp(cfp->name, name) || token == cfp->token)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return cfp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rot->caps->port_type == RIG_PORT_SERIAL)
|
|
|
|
{
|
|
|
|
for (cfp = rotfrontend_serial_cfg_params; cfp->name; cfp++)
|
|
|
|
{
|
|
|
|
if (!strcmp(cfp->name, name) || token == cfp->token)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return cfp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2001-12-27 21:46:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/**
|
|
|
|
* \brief Simple lookup returning token id associated with name
|
|
|
|
* \param rot
|
|
|
|
* \param name
|
2011-08-22 01:07:57 +00:00
|
|
|
* \return token enum
|
2001-12-27 21:46:25 +00:00
|
|
|
*/
|
2004-10-02 10:32:09 +00:00
|
|
|
token_t HAMLIB_API rot_token_lookup(ROT *rot, const char *name)
|
2001-12-27 21:46:25 +00:00
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
const struct confparams *cfp;
|
|
|
|
|
2019-11-24 05:08:27 +00:00
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called lookup %s\n", __func__, name);
|
2001-12-27 21:46:25 +00:00
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
cfp = rot_confparam_lookup(rot, name);
|
2001-12-27 21:46:25 +00:00
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!cfp)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return RIG_CONF_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cfp->token;
|
2001-12-27 21:46:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2010-04-25 17:20:44 +00:00
|
|
|
/**
|
|
|
|
* \brief set a rotator configuration parameter
|
2017-08-05 14:09:12 +00:00
|
|
|
* \param rot The rot handle
|
|
|
|
* \param token The parameter
|
|
|
|
* \param val The value to set the parameter to
|
2010-04-25 17:20:44 +00:00
|
|
|
*
|
2011-08-22 01:07:57 +00:00
|
|
|
* Sets a configuration parameter.
|
2010-04-25 17:20:44 +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
|
|
|
* \return RIG_OK if the operation has been successful, otherwise
|
|
|
|
* a negative value if an error occurred (in which case, cause is
|
2010-04-25 17:20:44 +00:00
|
|
|
* set appropriately).
|
|
|
|
*
|
|
|
|
* \sa rot_get_conf()
|
|
|
|
*/
|
|
|
|
int HAMLIB_API rot_set_conf(ROT *rot, token_t token, const char *val)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!rot || !rot->caps)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rig_need_debug(RIG_DEBUG_VERBOSE))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
const struct confparams *cfp;
|
|
|
|
char tokenstr[12];
|
|
|
|
sprintf(tokenstr, "%ld", token);
|
|
|
|
cfp = rot_confparam_lookup(rot, tokenstr);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!cfp)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rot_debug(RIG_DEBUG_VERBOSE, "%s: %s='%s'\n", __func__, cfp->name, val);
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (IS_TOKEN_FRONTEND(token))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return frontrot_set_conf(rot, token, val);
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rot->caps->set_conf == NULL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_ENAVAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rot->caps->set_conf(rot, token, val);
|
2010-04-25 17:20:44 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
|
2010-04-25 17:20:44 +00:00
|
|
|
/**
|
|
|
|
* \brief get the value of a configuration parameter
|
2017-08-05 14:09:12 +00:00
|
|
|
* \param rot The rot handle
|
|
|
|
* \param token The parameter
|
|
|
|
* \param val The location where to store the value of config \a token
|
2010-04-25 17:20:44 +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
|
|
|
* Retrieves the value of a configuration parameter associated with \a token.
|
2010-04-25 17:20:44 +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
|
|
|
* \return RIG_OK if the operation has been successful, otherwise
|
|
|
|
* a negative value if an error occurred (in which case, cause is
|
2010-04-25 17:20:44 +00:00
|
|
|
* set appropriately).
|
|
|
|
*
|
|
|
|
* \sa rot_set_conf()
|
|
|
|
*/
|
|
|
|
int HAMLIB_API rot_get_conf(ROT *rot, token_t token, char *val)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (!rot || !rot->caps || !val)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2010-04-25 17:20:44 +00:00
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (IS_TOKEN_FRONTEND(token))
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return frontrot_get_conf(rot, token, val);
|
|
|
|
}
|
2010-04-25 17:20:44 +00:00
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
if (rot->caps->get_conf == NULL)
|
|
|
|
{
|
2017-08-05 14:09:12 +00:00
|
|
|
return -RIG_ENAVAIL;
|
|
|
|
}
|
2010-04-25 17:20:44 +00:00
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
return rot->caps->get_conf(rot, token, val);
|
2010-04-25 17:20:44 +00:00
|
|
|
}
|
|
|
|
|
2006-10-15 00:27:52 +00:00
|
|
|
/** @} */
|