kopia lustrzana https://github.com/Hamlib/Hamlib
Initial release
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1479 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.0
rodzic
962a3f018f
commit
b082e43e2d
|
@ -0,0 +1,7 @@
|
|||
|
||||
lib_LTLIBRARIES = hamlib-flexradio.la
|
||||
hamlib_flexradio_la_SOURCES = sdr1k.c
|
||||
hamlib_flexradio_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
hamlib_flexradio_la_LIBADD = $(top_builddir)/src/libhamlib.la
|
||||
|
||||
noinst_HEADERS = sdr1k.h
|
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
* Hamlib Rotator backend - SDR-1000
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
* $Id: sdr1k.c,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "serial.h"
|
||||
#include "misc.h"
|
||||
#include "bandplan.h"
|
||||
#include "register.h"
|
||||
|
||||
#include "sdr1k.h"
|
||||
|
||||
static int sdr1k_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
static int sdr1k_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
static int sdr1k_reset(RIG *rig, reset_t reset);
|
||||
static int sdr1k_init(RIG *rig);
|
||||
static int sdr1k_open(RIG *rig);
|
||||
static int sdr1k_close(RIG *rig);
|
||||
static int sdr1k_cleanup(RIG *rig);
|
||||
static int sdr1k_set_ptt (RIG *rig, vfo_t vfo, ptt_t ptt);
|
||||
|
||||
typedef enum { L_EXT = 0, L_BAND = 1, L_DDS0 = 2, L_DDS1 = 3 } latch_t;
|
||||
|
||||
static void write_latch (RIG *rig, latch_t which, int value, int mask);
|
||||
static void write_reg (RIG *rig, int addr, int data);
|
||||
static void set_bit (RIG *rig, latch_t reg, int bit, int state);
|
||||
|
||||
|
||||
|
||||
struct sdr1k_priv_data {
|
||||
int shadow[4]; /* shadow latches */
|
||||
};
|
||||
|
||||
|
||||
#define SDR1K_FUNC RIG_FUNC_NONE
|
||||
#define SDR1K_LEVEL RIG_LEVEL_NONE
|
||||
#define SDR1K_PARM RIG_PARM_NONE
|
||||
|
||||
#define SDR1K_MODES (RIG_MODE_NONE)
|
||||
|
||||
#define SDR1K_VFO RIG_VFO_A
|
||||
|
||||
#define SDR1K_ANTS 0
|
||||
|
||||
|
||||
/* ************************************************************************* */
|
||||
/*
|
||||
* http://www.flex-radio.com
|
||||
* SDR-1000 rig capabilities.
|
||||
*
|
||||
*
|
||||
* TODO: set_gain? RIG_FUNC_MUTE, set_external_pin?
|
||||
*
|
||||
* def set_gain (self, high):
|
||||
* self.set_bit(0, 7, high)
|
||||
*
|
||||
* def set_mute (self, mute = 1):
|
||||
* self.set_bit(1, 7, mute)
|
||||
*
|
||||
* def set_unmute (self):
|
||||
* self.set_bit(1, 7, 0)
|
||||
*
|
||||
* def set_external_pin (self, pin, on = 1):
|
||||
* assert (pin < 8 and pin > 0), "Out of range 1..7"
|
||||
* self.set_bit(0, pin-1, on)
|
||||
*/
|
||||
|
||||
const struct rig_caps sdr1k_rig_caps = {
|
||||
.rig_model = RIG_MODEL_SDR1000,
|
||||
.model_name = "SDR-1000",
|
||||
.mfg_name = "Flex-radio",
|
||||
.version = "0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_NEW,
|
||||
.rig_type = RIG_TYPE_TUNER,
|
||||
.targetable_vfo = 0,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_PARALLEL,
|
||||
|
||||
.has_get_func = SDR1K_FUNC,
|
||||
.has_set_func = SDR1K_FUNC,
|
||||
.has_get_level = SDR1K_LEVEL,
|
||||
.has_set_level = RIG_LEVEL_SET(SDR1K_LEVEL),
|
||||
.has_get_parm = SDR1K_PARM,
|
||||
.has_set_parm = RIG_PARM_SET(SDR1K_PARM),
|
||||
.chan_list = {
|
||||
RIG_CHAN_END,
|
||||
},
|
||||
.scan_ops = RIG_SCAN_NONE,
|
||||
.vfo_ops = RIG_OP_NONE,
|
||||
.transceive = RIG_TRN_OFF,
|
||||
.attenuator = { RIG_DBLST_END, },
|
||||
.preamp = { RIG_DBLST_END, },
|
||||
|
||||
.rx_range_list1 = { {.start=Hz(1),.end=MHz(65),.modes=SDR1K_MODES,
|
||||
.low_power=-1,.high_power=-1,SDR1K_VFO},
|
||||
RIG_FRNG_END, },
|
||||
.tx_range_list1 = {
|
||||
/* restricted to ham band */
|
||||
FRQ_RNG_HF(1,SDR1K_MODES, W(1),W(1),SDR1K_VFO,SDR1K_ANTS),
|
||||
FRQ_RNG_6m(1,SDR1K_MODES, W(1),W(1),SDR1K_VFO,SDR1K_ANTS),
|
||||
RIG_FRNG_END, },
|
||||
|
||||
.rx_range_list2 = { {.start=Hz(1),.end=MHz(65),.modes=SDR1K_MODES,
|
||||
.low_power=-1,.high_power=-1,SDR1K_VFO},
|
||||
RIG_FRNG_END, },
|
||||
.tx_range_list2 = {
|
||||
/* restricted to ham band */
|
||||
FRQ_RNG_HF(2,SDR1K_MODES, W(1),W(1),SDR1K_VFO,SDR1K_ANTS),
|
||||
FRQ_RNG_6m(2,SDR1K_MODES, W(1),W(1),SDR1K_VFO,SDR1K_ANTS),
|
||||
RIG_FRNG_END, },
|
||||
|
||||
.tuning_steps = { {SDR1K_MODES,1},
|
||||
RIG_TS_END,
|
||||
},
|
||||
.priv = NULL, /* priv */
|
||||
|
||||
.rig_init = sdr1k_init,
|
||||
.rig_open = sdr1k_open,
|
||||
.rig_close = sdr1k_close,
|
||||
.rig_cleanup = sdr1k_cleanup,
|
||||
|
||||
.set_freq = sdr1k_set_freq,
|
||||
.get_freq = sdr1k_get_freq,
|
||||
.set_ptt = sdr1k_set_ptt,
|
||||
.reset = sdr1k_reset,
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
DECLARE_INITRIG_BACKEND(flexradio)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||
|
||||
rig_register(&sdr1k_rig_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
int sdr1k_init(RIG *rig)
|
||||
{
|
||||
struct sdr1k_priv_data *priv;
|
||||
|
||||
priv = (struct sdr1k_priv_data*)malloc(sizeof(struct sdr1k_priv_data));
|
||||
if (!priv) {
|
||||
/* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
rig->state.current_freq = RIG_FREQ_NONE;
|
||||
|
||||
rig->state.priv = (void*)priv;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_open(RIG *rig)
|
||||
{
|
||||
struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv;
|
||||
|
||||
priv->shadow[0] = 0;
|
||||
priv->shadow[1] = 0;
|
||||
priv->shadow[2] = 0;
|
||||
priv->shadow[3] = 0;
|
||||
|
||||
sdr1k_reset(rig, 1);
|
||||
|
||||
write_latch (rig, L_DDS1, 0x00, 0xC0); /* Reset low, WRS/ low */
|
||||
write_reg (rig, 0x20, 0x40);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_close(RIG *rig)
|
||||
{
|
||||
/* place holder.. */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_cleanup(RIG *rig)
|
||||
{
|
||||
struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv;
|
||||
|
||||
if (priv) {
|
||||
free(priv);
|
||||
}
|
||||
rig->state.priv = NULL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
int i, band;
|
||||
double ftw;
|
||||
|
||||
/* set_band */
|
||||
if (freq <= MHz(2.25))
|
||||
band = 0;
|
||||
else if ( freq <= MHz(5.5))
|
||||
band = 1;
|
||||
else if (freq <= MHz(11))
|
||||
band = 3; /* due to wiring mistake on board */
|
||||
else if (freq <= MHz(22))
|
||||
band = 2; /* due to wiring mistake on board */
|
||||
else if (freq <= MHz(37.5))
|
||||
band = 4;
|
||||
else
|
||||
band = 5;
|
||||
|
||||
write_latch (rig, L_BAND, 1 << band, 0x3f);
|
||||
|
||||
ftw = freq / MHz(200);
|
||||
|
||||
for (i = 0; i<5; i++) {
|
||||
int word;
|
||||
|
||||
word = (int)(ftw * 256);
|
||||
ftw = ftw*256 - word;
|
||||
// print (('%d [%02x]') % (i, word))
|
||||
write_reg (rig, 4+i, word);
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
*freq = rig->state.current_freq;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int sdr1k_reset (RIG *rig, reset_t reset)
|
||||
{
|
||||
port_t *pport = &rig->state.rigport;
|
||||
|
||||
par_write_control (pport, 0x0F);
|
||||
write_latch (rig, L_EXT, 0x00, 0xff);
|
||||
write_latch (rig, L_BAND, 0x00, 0xff);
|
||||
write_latch (rig, L_DDS0, 0x80, 0xff); /* hold DDS in reset */
|
||||
write_latch (rig, L_DDS1, 0x00, 0xff);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int sdr1k_set_ptt (RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||
{
|
||||
set_bit(rig, 1, 6, ptt == RIG_PTT_ON);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
write_latch (RIG *rig, latch_t which, int value, int mask)
|
||||
{
|
||||
struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv;
|
||||
port_t *pport = &rig->state.rigport;
|
||||
|
||||
if (!(0 <= which && which <= 3))
|
||||
return;
|
||||
|
||||
priv->shadow[which] = (priv->shadow[which] & ~mask) | (value & mask);
|
||||
par_write_data (pport, priv->shadow[which]);
|
||||
par_write_control (pport, 0x0F ^ (1 << which));
|
||||
par_write_control (pport, 0x0F);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
write_reg (RIG *rig, int addr, int data)
|
||||
{
|
||||
write_latch (rig, L_DDS1, addr & 0x3f, 0x3f);
|
||||
write_latch (rig, L_DDS0, data, 0xff);
|
||||
write_latch (rig, L_DDS1, 0x40, 0x40);
|
||||
write_latch (rig, L_DDS1, 0x00, 0x40);
|
||||
}
|
||||
|
||||
void
|
||||
set_bit (RIG *rig, latch_t reg, int bit, int state)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = state ? 1<<bit : 0;
|
||||
|
||||
write_latch (rig, reg, val, 1<<bit);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Hamlib Rotator backend - SDR-1000 interface protocol
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
* $Id: sdr1k.h,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ROT_SDR1K_H
|
||||
#define _ROT_SDR1K_H 1
|
||||
|
||||
extern const struct rig_caps sdr1k_rig_caps;
|
||||
|
||||
#endif /* _ROT_SDR1K_H */
|
|
@ -0,0 +1,8 @@
|
|||
LOWESRC = hf235.c
|
||||
|
||||
lib_LTLIBRARIES = hamlib-lowe.la
|
||||
hamlib_lowe_la_SOURCES = $(LOWESRC) lowe.c
|
||||
hamlib_lowe_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
hamlib_lowe_la_LIBADD = $(top_builddir)/src/libhamlib.la
|
||||
|
||||
noinst_HEADERS = lowe.h
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Hamlib Lowe backend - HF-235 description
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
* $Id: hf235.c,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "lowe.h"
|
||||
|
||||
|
||||
#define HF235_MODES (RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM|RIG_MODE_FM)
|
||||
|
||||
#define HF235_FUNC (RIG_FUNC_LOCK|RIG_FUNC_MUTE)
|
||||
|
||||
#define HF235_LEVEL_ALL (RIG_LEVEL_STRENGTH)
|
||||
|
||||
#define HF235_PARM_ALL (RIG_PARM_NONE)
|
||||
|
||||
#define HF235_VFO (RIG_VFO_A)
|
||||
|
||||
#define HF235_VFO_OPS (RIG_OP_NONE)
|
||||
|
||||
|
||||
/*
|
||||
* HF-235 rig capabilities.
|
||||
*
|
||||
*/
|
||||
|
||||
const struct rig_caps hf235_caps = {
|
||||
.rig_model = RIG_MODEL_HF235,
|
||||
.model_name = "HF-235",
|
||||
.mfg_name = "Lowe",
|
||||
.version = "0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_ALPHA, /* and only basic support */
|
||||
.rig_type = RIG_TYPE_RECEIVER,
|
||||
.ptt_type = RIG_PTT_NONE,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
.serial_rate_min = 300,
|
||||
.serial_rate_max = 1200,
|
||||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
|
||||
.write_delay = 0,
|
||||
.post_write_delay = 1,
|
||||
.timeout = 200,
|
||||
.retry = 3,
|
||||
|
||||
.has_get_func = HF235_FUNC,
|
||||
.has_set_func = HF235_FUNC,
|
||||
.has_get_level = HF235_LEVEL_ALL,
|
||||
.has_set_level = RIG_LEVEL_SET(HF235_LEVEL_ALL),
|
||||
.has_get_parm = HF235_PARM_ALL,
|
||||
.has_set_parm = RIG_PARM_SET(HF235_PARM_ALL),
|
||||
.level_gran = {},
|
||||
.parm_gran = {},
|
||||
.ctcss_list = NULL,
|
||||
.dcs_list = NULL,
|
||||
.preamp = { RIG_DBLST_END },
|
||||
.attenuator = { RIG_DBLST_END },
|
||||
.max_rit = Hz(0),
|
||||
.max_xit = Hz(0),
|
||||
.max_ifshift = Hz(0),
|
||||
.targetable_vfo = 0,
|
||||
.transceive = RIG_TRN_OFF,
|
||||
.bank_qty = 0,
|
||||
.chan_desc_sz = 7,
|
||||
.vfo_ops = HF235_VFO_OPS,
|
||||
|
||||
.chan_list = {
|
||||
RIG_CHAN_END, /* FIXME */
|
||||
},
|
||||
|
||||
.rx_range_list1 = {
|
||||
{kHz(30),MHz(30),HF235_MODES,-1,-1,HF235_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list1 = { RIG_FRNG_END, },
|
||||
.rx_range_list2 = {
|
||||
{kHz(30),MHz(30),HF235_MODES,-1,-1,HF235_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = { RIG_FRNG_END, },
|
||||
|
||||
.tuning_steps = {
|
||||
{HF235_MODES,10},
|
||||
RIG_TS_END,
|
||||
},
|
||||
/* mode/filter list, remember: order matters! */
|
||||
.filters = {
|
||||
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, kHz(2.2)},
|
||||
{RIG_MODE_FM, kHz(12)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
.priv = NULL,
|
||||
|
||||
.set_freq = lowe_set_freq,
|
||||
.get_freq = lowe_get_freq,
|
||||
.set_mode = lowe_set_mode,
|
||||
.get_mode = lowe_get_mode,
|
||||
|
||||
//.set_func = lowe_set_func,
|
||||
.get_level = lowe_get_level,
|
||||
.reset = lowe_reset,
|
||||
.get_info = lowe_get_info,
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
/*
|
||||
* Hamlib Lowe backend - main file
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
* $Id: lowe.c,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <math.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "serial.h"
|
||||
#include "misc.h"
|
||||
#include "register.h"
|
||||
|
||||
#include "lowe.h"
|
||||
|
||||
|
||||
#define BUFSZ 64
|
||||
|
||||
#define CR "\x0d"
|
||||
#define EOM CR
|
||||
|
||||
#define MD_USB "USB"
|
||||
#define MD_LSB "LSB"
|
||||
#define MD_FAX "FAX"
|
||||
#define MD_CW "CW"
|
||||
#define MD_FM "FM"
|
||||
#define MD_AM "AM"
|
||||
#define MD_AMS "AMS"
|
||||
|
||||
|
||||
/*
|
||||
* lowe_transaction
|
||||
* We assume that rig!=NULL, rig->state!= NULL, data!=NULL, data_len!=NULL
|
||||
*/
|
||||
int lowe_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len)
|
||||
{
|
||||
int retval;
|
||||
struct rig_state *rs;
|
||||
|
||||
rs = &rig->state;
|
||||
|
||||
serial_flush(&rs->rigport);
|
||||
|
||||
retval = write_block(&rs->rigport, cmd, cmd_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
||||
/* no data expected, TODO: flush input? */
|
||||
if (!data || !data_len)
|
||||
return 0;
|
||||
|
||||
*data_len = read_string(&rs->rigport, data, BUFSZ, CR, 1);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* lowe_set_freq
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
unsigned char freqbuf[16], ackbuf[16];
|
||||
int freq_len, ack_len, retval;
|
||||
|
||||
/*
|
||||
*/
|
||||
freq_len = sprintf(freqbuf,"FRQ%f" EOM, (float)freq/1000);
|
||||
retval = lowe_transaction(rig, freqbuf, freq_len, ackbuf, &ack_len);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* lowe_get_freq
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
unsigned char freqbuf[16];
|
||||
int freq_len, retval;
|
||||
float f_freq;
|
||||
|
||||
retval = lowe_transaction(rig, "FRQ?" EOM, 5, freqbuf, &freq_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
freqbuf[freq_len < 16 ? freq_len : 15] = '\0';
|
||||
|
||||
sscanf(freqbuf+1, "%f", &f_freq);
|
||||
*freq = f_freq*1000;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lowe_set_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
unsigned char mdbuf[16], ackbuf[16];
|
||||
unsigned char *mode_sel;
|
||||
int mdbuf_len, ack_len, retval;
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_CW: mode_sel = MD_CW; break;
|
||||
case RIG_MODE_USB: mode_sel = MD_USB; break;
|
||||
case RIG_MODE_LSB: mode_sel = MD_LSB; break;
|
||||
case RIG_MODE_FM: mode_sel = MD_FM; break;
|
||||
case RIG_MODE_AM: mode_sel = MD_AM; break;
|
||||
case RIG_MODE_RTTY: mode_sel = MD_FAX; break; /* TBC */
|
||||
case RIG_MODE_AMS: mode_sel = MD_AMS; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"lowe_set_mode: "
|
||||
"unsupported mode %d\n", mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mdbuf_len = sprintf(mdbuf, "MOD%s" EOM, mode_sel);
|
||||
retval = lowe_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lowe_get_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||
{
|
||||
unsigned char mdbuf[16];
|
||||
int mdbuf_len, retval;
|
||||
|
||||
retval = lowe_transaction (rig, "MOD?" EOM, 5, mdbuf, &mdbuf_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (!strcmp(mdbuf+1, MD_CW))
|
||||
*mode = RIG_MODE_CW;
|
||||
else if (!strcmp(mdbuf+1, MD_USB))
|
||||
*mode = RIG_MODE_USB;
|
||||
else if (!strcmp(mdbuf+1, MD_LSB))
|
||||
*mode = RIG_MODE_LSB;
|
||||
else if (!strcmp(mdbuf+1, MD_FM))
|
||||
*mode = RIG_MODE_FM;
|
||||
else if (!strcmp(mdbuf+1, MD_FAX)) /* TBC */
|
||||
*mode = RIG_MODE_RTTY;
|
||||
else if (!strcmp(mdbuf+1, MD_AMS))
|
||||
*mode = RIG_MODE_AMS;
|
||||
else if (!strcmp(mdbuf+1, MD_AM))
|
||||
*mode = RIG_MODE_AM;
|
||||
else {
|
||||
rig_debug(RIG_DEBUG_WARN,"%s: unknown mode '%s'\n",
|
||||
__FUNCTION__, mdbuf);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* lowe_get_level
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
unsigned char lvlbuf[16];
|
||||
int lvl_len, retval;
|
||||
|
||||
if (level != RIG_LEVEL_STRENGTH)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
retval = lowe_transaction(rig, "RSS?" EOM, 5, lvlbuf, &lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
lvlbuf[lvl_len < 16 ? lvl_len : 15] = '\0';
|
||||
|
||||
sscanf(lvlbuf+1, "%d", &val->i);
|
||||
|
||||
val->i += 60; /* dBm */
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lowe_reset
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int lowe_reset(RIG *rig, reset_t reset)
|
||||
{
|
||||
static unsigned char ackbuf[BUFSZ];
|
||||
int retval, ack_len;
|
||||
|
||||
retval = lowe_transaction(rig, "RES" EOM, 4, ackbuf, &ack_len);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lowe_get_info
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
const char *lowe_get_info(RIG *rig)
|
||||
{
|
||||
static unsigned char idbuf[BUFSZ];
|
||||
int retval, id_len;
|
||||
|
||||
/* hack: no idea what INF is for */
|
||||
retval = lowe_transaction(rig, "INF?" EOM, 5, idbuf, &id_len);
|
||||
|
||||
/* this is the real one */
|
||||
retval = lowe_transaction(rig, "TYP?" EOM, 5, idbuf, &id_len);
|
||||
if (retval != RIG_OK)
|
||||
return NULL;
|
||||
|
||||
idbuf[id_len] = '\0';
|
||||
|
||||
return idbuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* probe_lowe(port_t *port, rig_probe_func_t cfunc, rig_ptr_t data)
|
||||
*/
|
||||
DECLARE_PROBERIG_BACKEND(lowe)
|
||||
{
|
||||
static unsigned char idbuf[BUFSZ];
|
||||
int retval, id_len;
|
||||
|
||||
if (!port)
|
||||
return RIG_MODEL_NONE;
|
||||
|
||||
if (port->type.rig != RIG_PORT_SERIAL)
|
||||
return RIG_MODEL_NONE;
|
||||
|
||||
port->parm.serial.rate = hf235_caps.serial_rate_max;
|
||||
port->write_delay = port->post_write_delay = 0;
|
||||
port->timeout = 50;
|
||||
port->retry = 1;
|
||||
|
||||
retval = serial_open(port);
|
||||
if (retval != RIG_OK)
|
||||
return RIG_MODEL_NONE;
|
||||
|
||||
retval = write_block(port, "TYP?" EOM, 4);
|
||||
id_len = read_string(port, idbuf, BUFSZ, CR, 2);
|
||||
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK || id_len <= 0 || id_len >= BUFSZ)
|
||||
return RIG_MODEL_NONE;
|
||||
|
||||
idbuf[id_len] = '\0';
|
||||
|
||||
if (!strcmp(idbuf, "HF-235")) {
|
||||
if (cfunc)
|
||||
(*cfunc)(port, RIG_MODEL_HF235, data);
|
||||
return RIG_MODEL_HF235;
|
||||
}
|
||||
|
||||
/*
|
||||
* not found...
|
||||
*/
|
||||
if (memcmp(idbuf, "ID" EOM, 3)) /* catch loopback serial */
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"probe_lowe: found unknown device "
|
||||
"with ID '%s', please report to Hamlib "
|
||||
"developers.\n", idbuf);
|
||||
|
||||
return RIG_MODEL_NONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* initrigs_lowe is called by rig_backend_load
|
||||
*/
|
||||
DECLARE_INITRIG_BACKEND(lowe)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "lowe: _init called\n");
|
||||
|
||||
rig_register(&hf235_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hamlib Lowe backend - main header
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
* $Id: lowe.h,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOWE_H
|
||||
#define _LOWE_H 1
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
|
||||
int lowe_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int lowe_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
int lowe_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||
int lowe_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||
int lowe_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
||||
int lowe_reset(RIG *rig, reset_t reset);
|
||||
const char *lowe_get_info(RIG *rig);
|
||||
|
||||
extern const struct rig_caps hf235_caps;
|
||||
|
||||
#endif /* _LOWE_H */
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
lib_LTLIBRARIES = hamlib-sartek.la
|
||||
hamlib_sartek_la_SOURCES = sartek.c
|
||||
hamlib_sartek_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
hamlib_sartek_la_LIBADD = $(top_builddir)/src/libhamlib.la
|
||||
|
||||
noinst_HEADERS = sartek.h
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Hamlib backend library for the SARtek rotor command set.
|
||||
*
|
||||
* sartek.c - (C) Stephane Fillod 2003
|
||||
*
|
||||
* $Id: sartek.c,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* Standard library definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
|
||||
#include "hamlib/rotator.h"
|
||||
#include "serial.h"
|
||||
#include "register.h"
|
||||
|
||||
#include "sartek.h"
|
||||
|
||||
|
||||
/* *************************************
|
||||
*
|
||||
* Seperate model capabilities
|
||||
*
|
||||
* *************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* SARtek rotor capabilities
|
||||
*
|
||||
* Documentation from:
|
||||
* http://www.hosenose.com/sartek/ifcspecs.htm
|
||||
*/
|
||||
|
||||
const struct rot_caps sartek_rot_caps = {
|
||||
.rot_model = ROT_MODEL_SARTEK1,
|
||||
.model_name = "SARtek-1",
|
||||
.mfg_name = "SARtek",
|
||||
.version = "0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.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,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
*
|
||||
* API functions
|
||||
*
|
||||
* ************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set position
|
||||
* SARtek protocol supports azimuth only--elevation is ignored
|
||||
* Range is converted to an integer string, 0 to 360 degrees
|
||||
*/
|
||||
|
||||
static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation)
|
||||
{
|
||||
unsigned char cmdstr[8];
|
||||
int len, err;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
||||
|
||||
if (!rot)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (azimuth < 0 || azimuth > 360)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (azimuth < 2) {
|
||||
azimuth = 2;
|
||||
}
|
||||
else if (azimuth > 358) {
|
||||
azimuth = 358;
|
||||
}
|
||||
|
||||
len = sprintf(cmdstr, "P%c", (int) ((azimuth * 255) / 360));
|
||||
|
||||
err = write_block(&rot->state.rotport, cmdstr, len);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Stop rotation
|
||||
*/
|
||||
|
||||
static int sartek_rot_stop(ROT *rot)
|
||||
{
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
||||
|
||||
err = write_block(&rot->state.rotport, "P\0", 2);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialize backend
|
||||
*/
|
||||
|
||||
DECLARE_INITROT_BACKEND(sartek)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||
|
||||
rot_register(&sartek_rot_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Hamlib backend library for the SARtek rotor command set.
|
||||
*
|
||||
* sartek.h - (C) Stephane Fillod 2003
|
||||
*
|
||||
* $Id: sartek.h,v 1.1 2003-06-22 19:36:37 fillods Exp $
|
||||
*
|
||||
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ROT_SARTEK_H
|
||||
#define _ROT_SARTEK_H 1
|
||||
|
||||
#define AZ_READ_LEN 4
|
||||
|
||||
extern const struct rot_caps sartek_rot_caps;
|
||||
|
||||
/*
|
||||
* API local implementation
|
||||
*
|
||||
*/
|
||||
|
||||
static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation);
|
||||
|
||||
static int sartek_rot_stop(ROT *rot);
|
||||
|
||||
|
||||
#endif /* _ROT_SARTEK_H */
|
Ładowanie…
Reference in New Issue