Add DF9GR's ERC model to rotorez backend. Implemented custom get_position for ERC,

custom dcu1_rot_stop() for DCU-1/ERC, and overloaded rotorez_rot_stop() as .reset 
for DCU-1/ERC.



git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2960 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.12
Nate Bargmann, N0NB 2010-08-23 20:09:30 +00:00
rodzic 39413a6842
commit 45b72a0e31
3 zmienionych plików z 436 dodań i 286 usunięć

Wyświetl plik

@ -123,11 +123,18 @@
* The Rotor-EZ backend can be used with rotators that support the * The Rotor-EZ backend can be used with rotators that support the
* DCU command set by Hy-Gain (currently the DCU-1). * DCU command set by Hy-Gain (currently the DCU-1).
*/ */
/*! \def ROT_MODEL_ERC
* \brief A macro that returns the model number of the ERC backend.
*
* The Rotor-EZ backend can be used with rotators that support the
* DCU command set by DF9GR (currently the ERC).
*/
#define ROT_ROTOREZ 4 #define ROT_ROTOREZ 4
#define ROT_BACKEND_ROTOREZ "rotorez" #define ROT_BACKEND_ROTOREZ "rotorez"
#define ROT_MODEL_ROTOREZ ROT_MAKE_MODEL(ROT_ROTOREZ, 1) #define ROT_MODEL_ROTOREZ ROT_MAKE_MODEL(ROT_ROTOREZ, 1)
#define ROT_MODEL_ROTORCARD ROT_MAKE_MODEL(ROT_ROTOREZ, 2) #define ROT_MODEL_ROTORCARD ROT_MAKE_MODEL(ROT_ROTOREZ, 2)
#define ROT_MODEL_DCU ROT_MAKE_MODEL(ROT_ROTOREZ, 3) #define ROT_MODEL_DCU ROT_MAKE_MODEL(ROT_ROTOREZ, 3)
#define ROT_MODEL_ERC ROT_MAKE_MODEL(ROT_ROTOREZ, 4)
/*! \def ROT_MODEL_SARTEK1 /*! \def ROT_MODEL_SARTEK1
* \brief A macro that returns the model number of the SARtek-1 backend. * \brief A macro that returns the model number of the SARtek-1 backend.

Wyświetl plik

@ -6,7 +6,7 @@
* This shared library provides an API for communicating * This shared library provides an API for communicating
* via serial interface to a Hy-Gain or Yaesu rotor using * via serial interface to a Hy-Gain or Yaesu rotor using
* the Idiom Press Rotor-EZ or RotorCard interface. It also * the Idiom Press Rotor-EZ or RotorCard interface. It also
* supports the Hy-Gain DCU-1. * supports the Hy-Gain DCU-1, and DF9GR ERC.
* *
* Rotor-EZ is a trademark of Idiom Press * Rotor-EZ is a trademark of Idiom Press
* Hy-Gain is a trademark of MFJ Enterprises * Hy-Gain is a trademark of MFJ Enterprises
@ -14,9 +14,6 @@
* Tested on a HAM-IV with the Rotor-EZ V1.4S interface installed. * Tested on a HAM-IV with the Rotor-EZ V1.4S interface installed.
* *
* *
* $Id: rotorez.c,v 1.14 2009-01-25 16:14:39 fillods Exp $
*
*
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
@ -38,10 +35,10 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* Standard library definitions */ #include <stdlib.h> /* Standard library definitions */
#include <string.h> /* String function definitions */ #include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */ #include <unistd.h> /* UNIX standard function definitions */
#include <ctype.h> /* for isdigit function */ #include <ctype.h> /* for isdigit function */
#include "hamlib/rotator.h" #include "hamlib/rotator.h"
#include "serial.h" #include "serial.h"
@ -56,7 +53,7 @@
* Private data structure * Private data structure
*/ */
struct rotorez_rot_priv_data { struct rotorez_rot_priv_data {
azimuth_t az; azimuth_t az;
}; };
/* /*
@ -99,40 +96,40 @@ static const struct confparams rotorez_cfg_params[] = {
*/ */
const struct rot_caps rotorez_rot_caps = { const struct rot_caps rotorez_rot_caps = {
.rot_model = ROT_MODEL_ROTOREZ, .rot_model = ROT_MODEL_ROTOREZ,
.model_name = "Rotor-EZ", .model_name = "Rotor-EZ",
.mfg_name = "Idiom Press", .mfg_name = "Idiom Press",
.version = "0.5", .version = "0.5",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_BETA, .status = RIG_STATUS_BETA,
.rot_type = ROT_TYPE_OTHER, .rot_type = ROT_TYPE_OTHER,
.port_type = RIG_PORT_SERIAL, .port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800, .serial_rate_min = 4800,
.serial_rate_max = 4800, .serial_rate_max = 4800,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, .write_delay = 0,
.post_write_delay = 500, .post_write_delay = 500,
.timeout = 1500, .timeout = 1500,
.retry = 2, .retry = 2,
.min_az = 0, .min_az = 0,
.max_az = 360, .max_az = 360,
.min_el = 0, .min_el = 0,
.max_el = 0, .max_el = 0,
.priv = NULL, /* priv */ .priv = NULL, /* priv */
.cfgparams = rotorez_cfg_params, .cfgparams = rotorez_cfg_params,
.rot_init = rotorez_rot_init, .rot_init = rotorez_rot_init,
.rot_cleanup = rotorez_rot_cleanup, .rot_cleanup = rotorez_rot_cleanup,
.set_position = rotorez_rot_set_position, .set_position = rotorez_rot_set_position,
.get_position = rotorez_rot_get_position, .get_position = rotorez_rot_get_position,
.stop = rotorez_rot_stop, .stop = rotorez_rot_stop,
.set_conf = rotorez_rot_set_conf, .set_conf = rotorez_rot_set_conf,
.get_info = rotorez_rot_get_info, .get_info = rotorez_rot_get_info,
}; };
@ -143,41 +140,40 @@ const struct rot_caps rotorez_rot_caps = {
*/ */
const struct rot_caps rotorcard_rot_caps = { const struct rot_caps rotorcard_rot_caps = {
.rot_model = ROT_MODEL_ROTORCARD, .rot_model = ROT_MODEL_ROTORCARD,
.model_name = "RotorCard", .model_name = "RotorCard",
.mfg_name = "Idiom Press", .mfg_name = "Idiom Press",
.version = "0.5", .version = "0.5",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_UNTESTED, .status = RIG_STATUS_UNTESTED,
.rot_type = ROT_TYPE_OTHER, .rot_type = ROT_TYPE_OTHER,
.port_type = RIG_PORT_SERIAL, .port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800, .serial_rate_min = 4800,
.serial_rate_max = 4800, .serial_rate_max = 4800,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, .write_delay = 0,
.post_write_delay = 500, .post_write_delay = 500,
.timeout = 1500, .timeout = 1500,
.retry = 2, .retry = 2,
.min_az = 0, .min_az = 0,
.max_az = 360, .max_az = 360,
.min_el = 0, .min_el = 0,
.max_el = 0, .max_el = 0,
.priv = NULL, /* priv */ .priv = NULL, /* priv */
.cfgparams = rotorez_cfg_params, .cfgparams = rotorez_cfg_params,
.rot_init = rotorez_rot_init,
.rot_cleanup = rotorez_rot_cleanup,
.set_position = rotorez_rot_set_position,
.get_position = rotorez_rot_get_position,
.stop = rotorez_rot_stop,
.set_conf = rotorez_rot_set_conf,
.get_info = rotorez_rot_get_info,
.rot_init = rotorez_rot_init,
.rot_cleanup = rotorez_rot_cleanup,
.set_position = rotorez_rot_set_position,
.get_position = rotorez_rot_get_position,
.stop = rotorez_rot_stop,
.set_conf = rotorez_rot_set_conf,
.get_info = rotorez_rot_get_info,
}; };
@ -187,39 +183,89 @@ const struct rot_caps rotorcard_rot_caps = {
*/ */
const struct rot_caps dcu_rot_caps = { const struct rot_caps dcu_rot_caps = {
.rot_model = ROT_MODEL_DCU, .rot_model = ROT_MODEL_DCU,
.model_name = "DCU-1/DCU-1X", .model_name = "DCU-1/DCU-1X",
.mfg_name = "Hy-Gain", .mfg_name = "Hy-Gain",
.version = "0.5", .version = "0.5",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_UNTESTED, .status = RIG_STATUS_UNTESTED,
.rot_type = ROT_TYPE_OTHER, .rot_type = ROT_TYPE_OTHER,
.port_type = RIG_PORT_SERIAL, .port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800, .serial_rate_min = 4800,
.serial_rate_max = 4800, .serial_rate_max = 4800,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, .write_delay = 0,
.post_write_delay = 500, .post_write_delay = 500,
.timeout = 1500, .timeout = 1500,
.retry = 2, .retry = 2,
.min_az = 0, .min_az = 0,
.max_az = 360, .max_az = 360,
.min_el = 0, .min_el = 0,
.max_el = 0, .max_el = 0,
.priv = NULL, /* priv */ .priv = NULL, /* priv */
.rot_init = rotorez_rot_init, .rot_init = rotorez_rot_init,
.rot_cleanup = rotorez_rot_cleanup, .rot_cleanup = rotorez_rot_cleanup,
.set_position = rotorez_rot_set_position, .set_position = rotorez_rot_set_position,
.get_info = rotorez_rot_get_info, .stop = dcu1_rot_stop,
.reset = rotorez_rot_stop, /* Not a typo! */
.get_info = rotorez_rot_get_info,
}; };
/*
* Rotor capabilities for DF9GR ERC
*
* TODO: Learn of additional capabilities of the ERC
*/
const struct rot_caps erc_rot_caps = {
.rot_model = ROT_MODEL_ERC,
.model_name = "ERC",
.mfg_name = "DF9GR",
.version = "0.1",
.copyright = "LGPL",
.status = RIG_STATUS_UNTESTED,
.rot_type = ROT_TYPE_OTHER,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 4800,
.serial_data_bits = 8,
.serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 500,
.timeout = 1500,
.retry = 2,
.min_az = 0,
.max_az = 360,
.min_el = 0,
.max_el = 0,
.priv = NULL, /* priv */
// .cfgparams = rotorez_cfg_params,
.rot_init = rotorez_rot_init,
.rot_cleanup = rotorez_rot_cleanup,
.set_position = rotorez_rot_set_position,
.get_position = erc_rot_get_position,
.stop = dcu1_rot_stop,
.reset = rotorez_rot_stop, /* Not a typo! */
// .stop = rotorez_rot_stop,
// .set_conf = rotorez_rot_set_conf,
.get_info = rotorez_rot_get_info,
};
/* ************************************ /* ************************************
* *
* API functions * API functions
@ -233,25 +279,25 @@ const struct rot_caps dcu_rot_caps = {
*/ */
static int rotorez_rot_init(ROT *rot) { static int rotorez_rot_init(ROT *rot) {
struct rotorez_rot_priv_data *priv; struct rotorez_rot_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
priv = (struct rotorez_rot_priv_data *) priv = (struct rotorez_rot_priv_data *)
malloc(sizeof(struct rotorez_rot_priv_data)); malloc(sizeof(struct rotorez_rot_priv_data));
if (!priv) if (!priv)
return -RIG_ENOMEM; return -RIG_ENOMEM;
rot->state.priv = (void *)priv; rot->state.priv = (void *)priv;
rot->state.rotport.type.rig = RIG_PORT_SERIAL; rot->state.rotport.type.rig = RIG_PORT_SERIAL;
priv->az = 0; priv->az = 0;
return RIG_OK; return RIG_OK;
} }
/* /*
@ -260,16 +306,16 @@ static int rotorez_rot_init(ROT *rot) {
static int rotorez_rot_cleanup(ROT *rot) { static int rotorez_rot_cleanup(ROT *rot) {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
if (rot->state.priv) if (rot->state.priv)
free(rot->state.priv); free(rot->state.priv);
rot->state.priv = NULL; rot->state.priv = NULL;
return RIG_OK; return RIG_OK;
} }
@ -280,31 +326,31 @@ static int rotorez_rot_cleanup(ROT *rot) {
*/ */
static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation) { static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation) {
char cmdstr[8]; char cmdstr[8];
char execstr[5] = "AM1;"; char execstr[5] = "AM1;";
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
if (azimuth < 0 || azimuth > 360) if (azimuth < 0 || azimuth > 360)
return -RIG_EINVAL; return -RIG_EINVAL;
if (azimuth > 359.4999) /* DCU-1 compatibility */ if (azimuth > 359.4999) /* DCU-1 compatibility */
azimuth = 0; azimuth = 0;
sprintf(cmdstr, "AP1%03.0f;", azimuth); /* Target bearing */ sprintf(cmdstr, "AP1%03.0f;", azimuth); /* Target bearing */
err = rotorez_send_priv_cmd(rot, cmdstr); err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
err = rotorez_send_priv_cmd(rot, execstr); /* Execute command */ err = rotorez_send_priv_cmd(rot, execstr); /* Execute command */
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
return RIG_OK; return RIG_OK;
} }
@ -316,94 +362,188 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t ele
*/ */
static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) { static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) {
struct rot_state *rs; struct rot_state *rs;
char cmdstr[5] = "AI1;"; char cmdstr[5] = "AI1;";
char az[5]; /* read azimuth string */ char az[5]; /* read azimuth string */
char *p; char *p;
azimuth_t tmp = 0; azimuth_t tmp = 0;
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
do { do {
err = rotorez_send_priv_cmd(rot, cmdstr); err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
rs = &rot->state; rs = &rot->state;
err = read_block(&rs->rotport, az, AZ_READ_LEN); err = read_block(&rs->rotport, az, AZ_READ_LEN);
if (err != AZ_READ_LEN) if (err != AZ_READ_LEN)
return -RIG_ETRUNC; return -RIG_ETRUNC;
/* The azimuth string should be ';xxx' beginning at offset 0. If the /* The azimuth string should be ';xxx' beginning at offset 0. If the
* ';' is not there, it's likely the RotorEZ has received an invalid * ';' is not there, it's likely the RotorEZ has received an invalid
* command and the buffer needs to be flushed. See rotorez_flush_buffer() * command and the buffer needs to be flushed. See
* definition below for a complete description. * rotorez_flush_buffer() definition below for a complete description.
*/ */
if (az[0] != ';') { if (az[0] != ';') {
err = rotorez_flush_buffer(rot); err = rotorez_flush_buffer(rot);
if (err == -RIG_EIO) if (err == -RIG_EIO)
return err; return err;
else else
err = -RIG_EINVAL; err = -RIG_EINVAL;
} else if (err == AZ_READ_LEN && az[0] == ';') { } else if (err == AZ_READ_LEN && az[0] == ';') {
/* Check if remaining chars are digits if az[0] == ';' */ /* Check if remaining chars are digits if az[0] == ';' */
for (p = az + 1;p < az + 4; p++) for (p = az + 1;p < az + 4; p++)
if (isdigit(*p)) if (isdigit(*p))
continue; continue;
else else
err = -RIG_EINVAL; err = -RIG_EINVAL;
} }
} while (err == -RIG_EINVAL); } while (err == -RIG_EINVAL);
/* /*
* Rotor-EZ returns a four octet string consisting of a ';' followed * Rotor-EZ returns a four octet string consisting of a ';' followed
* by three octets containing the rotor's position in degrees. The * by three octets containing the rotor's position in degrees. The
* semi-colon is ignored when passing the string to atof(). * semi-colon is ignored when passing the string to atof().
*/ */
az[4] = 0x00; /* NULL terminated string */ az[4] = 0x00; /* NULL terminated string */
p = az + 1; /* advance past leading ';' */ p = az + 1; /* advance past leading ';' */
tmp = (azimuth_t)atof(p); tmp = (azimuth_t)atof(p);
rig_debug(RIG_DEBUG_TRACE, "%s: \"%s\" after conversion = %.1f\n", rig_debug(RIG_DEBUG_TRACE, "%s: \"%s\" after conversion = %.1f\n",
__func__, p, tmp); __func__, p, tmp);
if (tmp == 360) if (tmp == 360)
tmp = 0; tmp = 0;
else if (tmp < 0 || tmp > 359) else if (tmp < 0 || tmp > 359)
return -RIG_EINVAL; return -RIG_EINVAL;
*azimuth = tmp; *azimuth = tmp;
*elevation = 0; /* RotorEZ does not support elevation */ *elevation = 0; /* RotorEZ does not support elevation */
rig_debug(RIG_DEBUG_TRACE, rig_debug(RIG_DEBUG_TRACE,
"%s: azimuth = %.1f deg; elevation = %.1f deg\n", "%s: azimuth = %.1f deg; elevation = %.1f deg\n",
__func__, *azimuth, *elevation); __func__, *azimuth, *elevation);
return RIG_OK; return RIG_OK;
} }
/* /*
* Stop rotation * Get position for ERC
* Returns current azimuth position in whole degrees.
* Range returned from ERC is an integer, 0 to 359 degrees
* Elevation is set to 0
*/
static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation) {
struct rot_state *rs;
char cmdstr[5] = "AI1;";
char az[5]; /* read azimuth string */
char *p;
azimuth_t tmp = 0;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot)
return -RIG_EINVAL;
do {
err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK)
return err;
rs = &rot->state;
err = read_block(&rs->rotport, az, AZ_READ_LEN);
if (err != AZ_READ_LEN)
return -RIG_ETRUNC;
/* The azimuth string returned by the ERC should be 'xxx;'
* beginning at offset 0.
*/
/* Check if remaining chars are digits if az[3] == ';' */
if (az[3] == ';') {
for (p = az; p < az + 3; p++)
if (isdigit(*p))
continue;
else
err = -RIG_EINVAL;
}
} while (err == -RIG_EINVAL);
/*
* ERC returns a four octet string consisting of three octets followed
* by ';' containing the rotor's position in degrees. The
* semi-colon is ignored when passing the string to atof().
*/
az[4] = 0x00; /* NULL terminated string */
p = az; /* advance past leading ';' */
tmp = (azimuth_t)atof(p);
rig_debug(RIG_DEBUG_TRACE, "%s: \"%s\" after conversion = %.1f\n",
__func__, p, tmp);
if (tmp == 360)
tmp = 0;
else if (tmp < 0 || tmp > 359)
return -RIG_EINVAL;
*azimuth = tmp;
*elevation = 0; /* ERC does not support elevation */
rig_debug(RIG_DEBUG_TRACE,
"%s: azimuth = %.1f deg; elevation = %.1f deg\n",
__func__, *azimuth, *elevation);
return RIG_OK;
}
/*
* Stop rotation on RotorEZ, reset on DCU-1
*
* Sending the ";" string will stop rotation on the RotorEZ and reset the DCU-1
*/ */
static int rotorez_rot_stop(ROT *rot) { static int rotorez_rot_stop(ROT *rot) {
char cmdstr[2] = ";"; char cmdstr[2] = ";";
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
err = rotorez_send_priv_cmd(rot, cmdstr); err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
return RIG_OK; return RIG_OK;
}
/*
* Stop rotation on DCU-1
*/
static int dcu1_rot_stop(ROT *rot) {
char cmdstr[5] = "AS1;";
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot)
return -RIG_EINVAL;
err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK)
return err;
return RIG_OK;
} }
@ -416,59 +556,58 @@ static int rotorez_rot_stop(ROT *rot) {
*/ */
static int rotorez_rot_set_conf(ROT *rot, token_t token, const char *val) { static int rotorez_rot_set_conf(ROT *rot, token_t token, const char *val) {
char cmdstr[2]; char cmdstr[2];
char c; char c;
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s: token = %d, *val = %c\n", rig_debug(RIG_DEBUG_TRACE, "%s: token = %d, *val = %c\n", __func__, token, *val);
__func__, token, *val);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
if (*val < '0' || *val > '1') if (*val < '0' || *val > '1')
return -RIG_EINVAL; return -RIG_EINVAL;
switch(token) { switch(token) {
case TOK_ENDPT: /* Endpoint option */ case TOK_ENDPT: /* Endpoint option */
if (*val == '1') if (*val == '1')
c = 'E'; c = 'E';
else else
c = 'e'; c = 'e';
break; break;
case TOK_JAM: /* Jam protection */ case TOK_JAM: /* Jam protection */
if (*val == '1') if (*val == '1')
c = 'J'; c = 'J';
else else
c = 'j'; c = 'j';
break; break;
case TOK_OVRSHT: /* Overshoot option */ case TOK_OVRSHT: /* Overshoot option */
if (*val == '1') if (*val == '1')
c = 'O'; c = 'O';
else else
c = 'o'; c = 'o';
break; break;
case TOK_UNSTICK: /* Unstick option */ case TOK_UNSTICK: /* Unstick option */
if (*val == '1') if (*val == '1')
c = 'S'; c = 'S';
else else
c = 's'; c = 's';
break; break;
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
} }
rig_debug(RIG_DEBUG_TRACE, "%s: c = %c, *val = %c\n", __func__, c, *val); rig_debug(RIG_DEBUG_TRACE, "%s: c = %c, *val = %c\n", __func__, c, *val);
snprintf(cmdstr, sizeof(cmdstr), "%c", c); snprintf(cmdstr, sizeof(cmdstr), "%c", c);
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n", rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n",
__func__, cmdstr, *val); __func__, cmdstr, *val);
err = rotorez_send_priv_cmd(rot, cmdstr); err = rotorez_send_priv_cmd(rot, cmdstr);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
return RIG_OK; return RIG_OK;
} }
@ -478,16 +617,16 @@ static int rotorez_rot_set_conf(ROT *rot, token_t token, const char *val) {
*/ */
static const char *rotorez_rot_get_info(ROT *rot) static const char *rotorez_rot_get_info(ROT *rot)
{ {
const struct rot_caps *rc; const struct rot_caps *rc;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return (const char *)-RIG_EINVAL; return (const char *)-RIG_EINVAL;
rc = rot->caps; rc = rot->caps;
return rc->model_name; return rc->model_name;
} }
@ -496,20 +635,20 @@ static const char *rotorez_rot_get_info(ROT *rot)
*/ */
static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr) { static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr) {
struct rot_state *rs; struct rot_state *rs;
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
rs = &rot->state; rs = &rot->state;
err = write_block(&rs->rotport, cmdstr, strlen(cmdstr)); err = write_block(&rs->rotport, cmdstr, strlen(cmdstr));
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
return RIG_OK; return RIG_OK;
} }
@ -525,27 +664,27 @@ static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr) {
*/ */
static int rotorez_flush_buffer(ROT *rot) { static int rotorez_flush_buffer(ROT *rot) {
struct rot_state *rs; struct rot_state *rs;
char garbage[32]; /* read buffer */ char garbage[32]; /* read buffer */
int err = 0; int err = 0;
size_t MAX = 31; size_t MAX = 31;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rot) if (!rot)
return -RIG_EINVAL; return -RIG_EINVAL;
rs = &rot->state; rs = &rot->state;
do { do {
err = read_block(&rs->rotport, garbage, MAX); err = read_block(&rs->rotport, garbage, MAX);
/* Oops! An IO error was encountered. Bail out! */ /* Oops! An IO error was encountered. Bail out! */
if (err == -RIG_EIO) if (err == -RIG_EIO)
return -RIG_EIO; return -RIG_EIO;
} }
while (err != -RIG_ETIMEOUT); while (err != -RIG_ETIMEOUT);
return RIG_OK; return RIG_OK;
} }
@ -555,12 +694,13 @@ static int rotorez_flush_buffer(ROT *rot) {
DECLARE_INITROT_BACKEND(rotorez) DECLARE_INITROT_BACKEND(rotorez)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rot_register(&rotorez_rot_caps); rot_register(&rotorez_rot_caps);
rot_register(&rotorcard_rot_caps); rot_register(&rotorcard_rot_caps);
rot_register(&dcu_rot_caps); rot_register(&dcu_rot_caps);
rot_register(&erc_rot_caps);
return RIG_OK; return RIG_OK;
} }

Wyświetl plik

@ -38,6 +38,7 @@
extern const struct rot_caps rotorez_rot_caps; extern const struct rot_caps rotorez_rot_caps;
extern const struct rot_caps rotorcard_rot_caps; extern const struct rot_caps rotorcard_rot_caps;
extern const struct rot_caps dcu_rot_caps; extern const struct rot_caps dcu_rot_caps;
extern const struct rot_caps erc_rot_caps;
/* /*
* Tokens used by rotorez_rot_set_conf and the 'C' command in rotctl * Tokens used by rotorez_rot_set_conf and the 'C' command in rotctl
@ -59,8 +60,10 @@ static int rotorez_rot_cleanup(ROT *rot);
static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation); static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation);
static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation);
static int rotorez_rot_stop(ROT *rot); static int rotorez_rot_stop(ROT *rot);
static int dcu1_rot_stop(ROT *rot);
static int rotorez_rot_set_conf(ROT *rot, token_t token, const char *val); static int rotorez_rot_set_conf(ROT *rot, token_t token, const char *val);