kopia lustrzana https://github.com/Hamlib/Hamlib
20050118:
Update: src/locator.c -- Applied patch from Dave Hines M1CXW yaesu/ft920.* -- Format cleanup git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1899 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.4
rodzic
95daa7ac08
commit
e02795f58c
|
@ -14,7 +14,7 @@
|
|||
* Copyright (c) 2003 by Nate Bargmann
|
||||
* Copyright (c) 2003 by Dave Hines
|
||||
*
|
||||
* $Id: locator.c,v 1.16 2004-10-02 10:32:08 fillods Exp $
|
||||
* $Id: locator.c,v 1.17 2005-01-18 23:06:34 n0nb Exp $
|
||||
*
|
||||
* Code to determine bearing and range was taken from the Great Circle,
|
||||
* by S. R. Sampson, N5OWK.
|
||||
|
@ -72,7 +72,7 @@
|
|||
/* arc length for 1 degree, 60 Nautical Miles */
|
||||
#define ARC_IN_KM 111.2
|
||||
|
||||
/* The following is contributed by Dave Hines
|
||||
/* The following is contributed by Dave Hines M1CXW
|
||||
*
|
||||
* begin dph
|
||||
*/
|
||||
|
@ -80,25 +80,34 @@
|
|||
* These are the constants used when converting between Maidenhead grid
|
||||
* locators and longitude/latitude values. MAX_LOCATOR_PAIRS is the maximum
|
||||
* number of locator character pairs to convert. This number MUST NOT exceed
|
||||
* the number of pairs of values in range[] & weight[].
|
||||
* the number of pairs of values in loc_char_range[].
|
||||
* Setting MAX_LOCATOR_PAIRS to 3 will convert the currently defined 6
|
||||
* character locators. A value of 4 will convert the extended 8 character
|
||||
* locators described in section 3L of "The IARU region 1 VHF managers
|
||||
* handbook". Values of 5 and 6 will extent the format even more, to the
|
||||
* longest definition I have seen for locators. Beware that there seems to be
|
||||
* no universally accepted standard for 10 & 12 character locators.
|
||||
* Note that the loc_char_weight values are in minutes of arc, to avoid
|
||||
* constants which can't be represented precisely in either binary or decimal.
|
||||
* longest definition I have seen for locators, see
|
||||
* http://www.btinternet.com/~g8yoa/geog/non-ra.html
|
||||
* Beware that there seems to be no universally accepted standard for 10 & 12
|
||||
* character locators.
|
||||
*
|
||||
* The ranges of characters which will be accepted by locator2longlat, and
|
||||
* generated by longlat2locator, are specified by the loc_char_range[] array.
|
||||
* This array may be changed without requiring any other code changes.
|
||||
*
|
||||
* For the fifth pair to range from aa to xx use:
|
||||
* const static int loc_char_range[] = { 18, 10, 24, 10, 24, 10 };
|
||||
*
|
||||
* For the fifth pair to range from aa to yy use:
|
||||
* const static int loc_char_range[] = { 18, 10, 24, 10, 25, 10 };
|
||||
*
|
||||
* MAX_LOCATOR_PAIRS now sets the limit locator2longlat() will convert and
|
||||
* sets the maximum length longlat2locator() will generate. Each function
|
||||
* properly handles any value from 1 to 6 so MAX_LOCATOR_PAIRS should be
|
||||
* left at 6. MIN_LOCATOR_PAIRS sets a floor on the shortest locator that
|
||||
* should be handled. -N0NB
|
||||
*
|
||||
*/
|
||||
const static double loc_char_weight[] = { 600.0, 60.0, 2.5, 0.25, 0.01, 0.001 };
|
||||
const static int loc_char_range[] = { 18, 10, 24, 10, 25, 10 };
|
||||
const static int loc_char_range[] = { 18, 10, 24, 10, 24, 10 };
|
||||
|
||||
#define MAX_LOCATOR_PAIRS 6
|
||||
#define MIN_LOCATOR_PAIRS 1
|
||||
|
||||
|
@ -319,12 +328,12 @@ int HAMLIB_API dec2dmmm(double dec, int *degrees, double *minutes, int *sw) {
|
|||
* EM19 will return coordinates equivalent to the southwest corner
|
||||
* of EM19mm.
|
||||
*
|
||||
* \retval -RIG_EINVAL if locator exceeds RR99xx99yy99 or exceeds length
|
||||
* \retval -RIG_EINVAL if locator exceeds RR99xx99xx99 or exceeds length
|
||||
* limit--currently 1 to 6 lon/lat pairs.
|
||||
* \retval RIG_OK if conversion went OK.
|
||||
*
|
||||
* \bug The fifth pair ranges from aa to yy, there is another convention
|
||||
* that ranges from aa to xx. At some point both conventions should be
|
||||
* \bug The fifth pair ranges from aa to xx, there is another convention
|
||||
* that ranges from aa to yy. At some point both conventions should be
|
||||
* supported.
|
||||
*
|
||||
* \sa longlat2locator()
|
||||
|
@ -335,7 +344,8 @@ int HAMLIB_API dec2dmmm(double dec, int *degrees, double *minutes, int *sw) {
|
|||
int HAMLIB_API locator2longlat(double *longitude, double *latitude, const char *locator) {
|
||||
int x_or_y, paircount;
|
||||
int locvalue, pair;
|
||||
double xy[2], minutes;
|
||||
int divisions;
|
||||
double xy[2], ordinate;
|
||||
|
||||
/* bail if NULL pointers passed */
|
||||
if (!longitude || !latitude)
|
||||
|
@ -349,9 +359,10 @@ int HAMLIB_API locator2longlat(double *longitude, double *latitude, const char *
|
|||
else if (paircount < MIN_LOCATOR_PAIRS)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
/* For x(=lon) and y(=lat) */
|
||||
/* For x(=longitude) and y(=latitude) */
|
||||
for (x_or_y = 0; x_or_y < 2; ++x_or_y) {
|
||||
minutes = 0.0;
|
||||
ordinate = -90.0;
|
||||
divisions = 1;
|
||||
|
||||
for (pair = 0; pair < paircount; ++pair) {
|
||||
locvalue = locator[pair*2 + x_or_y];
|
||||
|
@ -361,18 +372,19 @@ int HAMLIB_API locator2longlat(double *longitude, double *latitude, const char *
|
|||
(isupper(locvalue)) ? 'A' : 'a';
|
||||
|
||||
/* Check range for non-letter/digit or out of range */
|
||||
if (((unsigned) locvalue) >= loc_char_range[pair])
|
||||
if ((locvalue < 0) || (locvalue >= loc_char_range[pair]))
|
||||
return -RIG_EINVAL;
|
||||
|
||||
minutes += locvalue * loc_char_weight[pair];
|
||||
divisions *= loc_char_range[pair];
|
||||
ordinate += locvalue * 180.0 / divisions;
|
||||
}
|
||||
/* Center coordinate */
|
||||
minutes += loc_char_weight[paircount - 1] / 2.0;
|
||||
/* Center ordinate in the Maidenhead "square" or "subsquare" */
|
||||
ordinate += 90.0 / divisions;
|
||||
|
||||
xy[x_or_y] = minutes / 60.0 - 90.0;
|
||||
xy[x_or_y] = ordinate;
|
||||
}
|
||||
|
||||
*longitude = xy[0] * 2;
|
||||
*longitude = xy[0] * 2.0;
|
||||
*latitude = xy[1];
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -404,8 +416,8 @@ int HAMLIB_API locator2longlat(double *longitude, double *latitude, const char *
|
|||
/* begin dph */
|
||||
|
||||
int HAMLIB_API longlat2locator(double longitude, double latitude, char *locator, int pair_count) {
|
||||
int x_or_y, pair, locvalue;
|
||||
double tmp;
|
||||
int x_or_y, pair, locvalue, divisions;
|
||||
double square_size, ordinate;
|
||||
|
||||
if (!locator)
|
||||
return -RIG_EINVAL;
|
||||
|
@ -414,15 +426,17 @@ int HAMLIB_API longlat2locator(double longitude, double latitude, char *locator,
|
|||
return -RIG_EINVAL;
|
||||
|
||||
for (x_or_y = 0; x_or_y < 2; ++x_or_y) {
|
||||
tmp = ((x_or_y == 0) ? longitude / 2. : latitude);
|
||||
ordinate = (x_or_y == 0) ? longitude / 2.0 : latitude;
|
||||
divisions = 1;
|
||||
|
||||
/* The 1e-6 here guards against floating point rounding errors */
|
||||
tmp = fmod(tmp + 270., 180.) * 60. + 1e-6;
|
||||
ordinate = fmod(ordinate + 270.000001, 180.0);
|
||||
for (pair = 0; pair < pair_count; ++pair) {
|
||||
locvalue = (int) (tmp / loc_char_weight[pair]);
|
||||
divisions *= loc_char_range[pair];
|
||||
square_size = 180.0 / divisions;
|
||||
|
||||
/* assert(locvalue < loc_char_range[pair]); */
|
||||
tmp -= loc_char_weight[pair] * locvalue;
|
||||
locvalue = (int) (ordinate / square_size);
|
||||
ordinate -= square_size * locvalue;
|
||||
locvalue += (loc_char_range[pair] == 10) ? '0':'A';
|
||||
locator[pair * 2 + x_or_y] = locvalue;
|
||||
}
|
||||
|
|
149
yaesu/ft920.c
149
yaesu/ft920.c
|
@ -2,7 +2,7 @@
|
|||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
*
|
||||
* ft920.c - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
* (C) Nate Bargmann 2002, 2003 (n0nb at arrl.net)
|
||||
* (C) Nate Bargmann 2002-2005 (n0nb at arrl.net)
|
||||
* (C) Stephane Fillod 2002 (fillods at users.sourceforge.net)
|
||||
*
|
||||
* This shared library provides an API for communicating
|
||||
|
@ -12,7 +12,7 @@
|
|||
* pages 86 to 90
|
||||
*
|
||||
*
|
||||
* $Id: ft920.c,v 1.16 2003-04-07 22:42:07 fillods Exp $
|
||||
* $Id: ft920.c,v 1.17 2005-01-18 23:06:48 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
@ -70,19 +70,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/* Private helper function prototypes */
|
||||
|
||||
static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl);
|
||||
|
||||
static int ft920_send_static_cmd(RIG *rig, unsigned char ci);
|
||||
|
||||
static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
||||
unsigned char p1, unsigned char p2,
|
||||
unsigned char p3, unsigned char p4);
|
||||
|
||||
static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4);
|
||||
static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq);
|
||||
|
||||
static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit);
|
||||
|
||||
|
||||
/*
|
||||
* Native ft920 cmd set prototypes. These are READ ONLY as each
|
||||
* rig instance will copy from these and modify if required.
|
||||
|
@ -326,7 +323,6 @@ static int ft920_init(RIG *rig) {
|
|||
*/
|
||||
|
||||
static int ft920_cleanup(RIG *rig) {
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
|
@ -360,7 +356,7 @@ static int ft920_open(RIG *rig) {
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay = %i msec\n",
|
||||
__func__, rig_s->rigport.post_write_delay);
|
||||
|
||||
/* TODO */
|
||||
/* TODO: more initialization as necessary */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -372,7 +368,6 @@ static int ft920_open(RIG *rig) {
|
|||
*/
|
||||
|
||||
static int ft920_close(RIG *rig) {
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
|
@ -405,8 +400,7 @@ static int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
|
|||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n",
|
||||
__func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
|
@ -426,8 +420,7 @@ static int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
|
|||
default:
|
||||
return -RIG_EINVAL; /* sorry, unsupported VFO */
|
||||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set cmd_index = 0x%02x\n",
|
||||
__func__, cmd_index);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set cmd_index = 0x%02x\n", __func__, cmd_index);
|
||||
|
||||
err = ft920_send_dial_freq(rig, cmd_index, freq);
|
||||
if (err != RIG_OK)
|
||||
|
@ -459,8 +452,7 @@ static int ft920_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
|
|||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
|
@ -490,8 +482,7 @@ static int ft920_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
|
|||
/* big endian integer */
|
||||
f = (((((p[0]<<8) + p[1])<<8) + p[2])<<8) + p[3];
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: freq = %lli Hz for vfo 0x%02x\n", __func__, f, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: freq = %lli Hz for vfo 0x%02x\n", __func__, f, vfo);
|
||||
|
||||
*freq = f; /* return displayed frequency */
|
||||
|
||||
|
@ -506,8 +497,7 @@ static int ft920_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
|
|||
*
|
||||
*/
|
||||
|
||||
static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
||||
pbwidth_t width ) {
|
||||
static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) {
|
||||
struct ft920_priv_data *priv;
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
unsigned char mode_parm; /* mode parameter */
|
||||
|
@ -520,8 +510,7 @@ static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %i\n", __func__, mode);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed width = %li Hz\n",
|
||||
__func__, width);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed width = %li Hz\n", __func__, width);
|
||||
|
||||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
|
@ -601,8 +590,7 @@ static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|||
* Yeah, it's ugly... -N0NB
|
||||
*
|
||||
*/
|
||||
if (width == RIG_PASSBAND_NORMAL ||
|
||||
width == rig_passband_normal(rig, mode)) {
|
||||
if (width == RIG_PASSBAND_NORMAL || width == rig_passband_normal(rig, mode)) {
|
||||
switch(vfo) {
|
||||
case RIG_VFO_A:
|
||||
case RIG_VFO_VFO:
|
||||
|
@ -636,22 +624,19 @@ static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* Invalid mode, how can caller know? */
|
||||
return -RIG_EINVAL; /* Invalid mode; how can caller know? */
|
||||
}
|
||||
} else {
|
||||
if (width != RIG_PASSBAND_NORMAL &&
|
||||
width != rig_passband_normal(rig, mode)) {
|
||||
return -RIG_EINVAL; /* Invalid width, how can caller know? */
|
||||
if (width != RIG_PASSBAND_NORMAL && width != rig_passband_normal(rig, mode)) {
|
||||
return -RIG_EINVAL; /* Invalid width; how can caller know? */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set mode_parm = 0x%02x\n", __func__, mode_parm);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set cmd_index = %i\n",
|
||||
__func__, cmd_index);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set cmd_index = %i\n", __func__, cmd_index);
|
||||
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_MODE_SET,
|
||||
mode_parm, 0, 0, 0);
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_MODE_SET, mode_parm, 0, 0, 0);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -659,7 +644,7 @@ static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
return RIG_OK; /* good */
|
||||
return RIG_OK; /* Whew! */
|
||||
}
|
||||
|
||||
|
||||
|
@ -684,8 +669,7 @@ static int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
|
@ -814,8 +798,7 @@ static int ft920_set_vfo(RIG *rig, vfo_t vfo) {
|
|||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
|
@ -831,6 +814,7 @@ static int ft920_set_vfo(RIG *rig, vfo_t vfo) {
|
|||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong VFO */
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set cmd_index = %i\n", __func__, cmd_index);
|
||||
|
||||
err = ft920_send_static_cmd(rig, cmd_index);
|
||||
|
@ -862,8 +846,7 @@ static int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
|
|||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
/* Get flags for VFO status */
|
||||
err = ft920_get_update_data(rig, FT920_NATIVE_STATUS_FLAGS,
|
||||
FT920_STATUS_FLAGS_LENGTH);
|
||||
err = ft920_get_update_data(rig, FT920_NATIVE_STATUS_FLAGS, FT920_STATUS_FLAGS_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -873,10 +856,8 @@ static int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
|
|||
status_1 = priv->update_data[FT920_SUMO_DISPLAYED_STATUS_1];
|
||||
status_1 &= SF_VFO_MASK; /* get VFO/MEM (main display) active bits */
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: vfo status_0 = 0x%02x\n", __func__, status_0);
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: vfo status_1 = 0x%02x\n", __func__, status_1);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: vfo status_0 = 0x%02x\n", __func__, status_0);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: vfo status_1 = 0x%02x\n", __func__, status_1);
|
||||
|
||||
/*
|
||||
* translate vfo status from ft920 to generic.
|
||||
|
@ -922,6 +903,7 @@ static int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
|
|||
default: /* Oops! */
|
||||
return -RIG_EINVAL; /* sorry, wrong current VFO */
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set vfo = 0x%02x\n", __func__, *vfo);
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -991,16 +973,14 @@ static int ft920_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vf
|
|||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
/* Get flags for VFO split status */
|
||||
err = ft920_get_update_data(rig, FT920_NATIVE_STATUS_FLAGS,
|
||||
FT920_STATUS_FLAGS_LENGTH);
|
||||
err = ft920_get_update_data(rig, FT920_NATIVE_STATUS_FLAGS, FT920_STATUS_FLAGS_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
status_0 = priv->update_data[FT920_SUMO_DISPLAYED_STATUS_0];
|
||||
status_0 &= SF_VFOB; /* get VFO B (sub display) active bits */
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: split status_0 = 0x%02x\n", __func__, status_0);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: split status_0 = 0x%02x\n", __func__, status_0);
|
||||
|
||||
switch (status_0) {
|
||||
case SF_SPLITA:
|
||||
|
@ -1075,8 +1055,7 @@ static int ft920_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) {
|
|||
* the split direction and set accordingly?
|
||||
*/
|
||||
|
||||
static int ft920_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
||||
pbwidth_t tx_width) {
|
||||
static int ft920_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) {
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
@ -1100,8 +1079,7 @@ static int ft920_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
|||
* the split direction and set accordingly?
|
||||
*/
|
||||
|
||||
static int ft920_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
||||
pbwidth_t *tx_width) {
|
||||
static int ft920_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width) {
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
@ -1152,8 +1130,7 @@ static int ft920_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) {
|
|||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set offset = 0x%02x\n", __func__, offset);
|
||||
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_CLARIFIER_OPS,
|
||||
offset, 0, 0, 0);
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_CLARIFIER_OPS, offset, 0, 0, 0);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1194,8 +1171,7 @@ static int ft920_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) {
|
|||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
|
@ -1270,8 +1246,7 @@ static int ft920_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit) {
|
|||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set offset = 0x%02x\n", __func__, offset);
|
||||
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_CLARIFIER_OPS,
|
||||
offset, 0, 0, 0);
|
||||
err = ft920_send_dynamic_cmd(rig, FT920_NATIVE_CLARIFIER_OPS, offset, 0, 0, 0);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1316,7 +1291,7 @@ static int ft920_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit) {
|
|||
|
||||
|
||||
/*
|
||||
* Private helper function. Retrieves update data from rig.
|
||||
* Private helper function to retrieve update data from rig.
|
||||
* using pacing value and buffer indicated in *priv struct.
|
||||
* Extended to be command agnostic as 920 has several ways to
|
||||
* get data and several ways to return it.
|
||||
|
@ -1351,11 +1326,9 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) {
|
|||
/* get pacing value, and store in private cmd */
|
||||
priv->p_cmd[P1] = priv->pacing;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: read pacing = %i\n", __func__, priv->pacing);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing);
|
||||
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1398,14 +1371,16 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) {
|
|||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
/*
|
||||
* If we've been passed a command index (ci) that is marked
|
||||
* as dynamic (0), then bail out.
|
||||
*/
|
||||
if (!priv->pcs[ci].ncomp) {
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: Attempt to send incomplete sequence\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) priv->pcs[ci].nseq,
|
||||
YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) priv->pcs[ci].nseq, YAESU_CMD_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1445,9 +1420,13 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
__func__, p1, p2, p3, p4);
|
||||
|
||||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
/*
|
||||
* If we've been passed a command index (ci) that is marked
|
||||
* as static (1), then bail out.
|
||||
*/
|
||||
if (priv->pcs[ci].ncomp) {
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: Attempt to modify complete sequence\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1459,8 +1438,7 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[P3] = p3;
|
||||
priv->p_cmd[P4] = p4;
|
||||
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1496,9 +1474,13 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) {
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %lli Hz\n", __func__, freq);
|
||||
|
||||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
/*
|
||||
* If we've been passed a command index (ci) that is marked
|
||||
* as static (1), then bail out.
|
||||
*/
|
||||
if (priv->pcs[ci].ncomp) {
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: Attempt to modify complete sequence\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1514,8 +1496,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) {
|
|||
"%s: requested freq after conversion = %lli Hz\n",
|
||||
__func__, from_bcd(priv->p_cmd, FT920_BCD_DIAL)* 10);
|
||||
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
@ -1525,7 +1506,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) {
|
|||
|
||||
/*
|
||||
* Private helper function to build and send a complete command to
|
||||
* change the Main or Sub display frequency.
|
||||
* change the RIT/XIT frequency.
|
||||
*
|
||||
* TODO: place variant of this in yaesu.c
|
||||
*
|
||||
|
@ -1557,9 +1538,13 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) {
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: passed rit = %li Hz\n", __func__, rit);
|
||||
|
||||
priv = (struct ft920_priv_data *)rig->state.priv;
|
||||
|
||||
/*
|
||||
* If we've been passed a command index (ci) that is marked
|
||||
* as static (1), then bail out.
|
||||
*/
|
||||
if (priv->pcs[ci].ncomp) {
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: Attempt to modify complete sequence\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1580,15 +1565,13 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) {
|
|||
/* store bcd format in in p_cmd */
|
||||
to_bcd(priv->p_cmd, rit/10, FT920_BCD_RIT);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: requested rit after conversion = %li Hz\n",
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: requested rit after conversion = %li Hz\n",
|
||||
__func__, from_bcd(priv->p_cmd, FT920_BCD_RIT)* 10);
|
||||
|
||||
priv->p_cmd[P1] = p1; /* ick */
|
||||
priv->p_cmd[P2] = p2;
|
||||
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig_s->rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
*
|
||||
* ft920.h - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
* (C) Nate Bargmann 2002, 2003 (n0nb at arrl.net)
|
||||
* (C) Nate Bargmann 2002-2005 (n0nb at arrl.net)
|
||||
* (C) Stephane Fillod 2002 (fillods at users.sourceforge.net)
|
||||
*
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-920 using the "CAT" interface
|
||||
*
|
||||
*
|
||||
* $Id: ft920.h,v 1.12 2003-04-06 18:40:36 fillods Exp $
|
||||
* $Id: ft920.h,v 1.13 2005-01-18 23:06:51 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
Ładowanie…
Reference in New Issue