kopia lustrzana https://github.com/Hamlib/Hamlib
initial basic support for R8B (untested)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1211 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.4
rodzic
01658d123d
commit
af8bf1df18
171
drake/drake.c
171
drake/drake.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Drake backend - main file
|
* Hamlib Drake backend - main file
|
||||||
* Copyright (c) 2001,2002 by Stephane Fillod
|
* Copyright (c) 2001,2002 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: drake.c,v 1.1 2002-07-08 22:10:43 fillods Exp $
|
* $Id: drake.c,v 1.2 2002-10-20 20:46:32 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -41,12 +41,23 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a skeleton backend. Please fill in the gaps.
|
* Protocol information available at http://www.rldrake.com/swl/R8B.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define BUFSZ 64
|
#define BUFSZ 64
|
||||||
|
|
||||||
|
#define CRLF "\x0d\x0a"
|
||||||
|
#define EOM CRLF
|
||||||
|
|
||||||
|
#define MD_USB '1'
|
||||||
|
#define MD_LSB '2'
|
||||||
|
#define MD_RTTY '3'
|
||||||
|
#define MD_CW '4'
|
||||||
|
#define MD_FM '5'
|
||||||
|
#define MD_AM '6'
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* drake_transaction
|
* drake_transaction
|
||||||
* We assume that rig!=NULL, rig->state!= NULL, data!=NULL, data_len!=NULL
|
* We assume that rig!=NULL, rig->state!= NULL, data!=NULL, data_len!=NULL
|
||||||
|
@ -71,7 +82,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *d
|
||||||
if (!data || !data_len)
|
if (!data || !data_len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*data_len = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1);
|
*data_len = read_string(&rs->rigport, data, BUFSZ, CRLF, 1);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
@ -82,10 +93,118 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *d
|
||||||
*/
|
*/
|
||||||
int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
return -RIG_ENIMPL;
|
unsigned char freqbuf[16], ackbuf[16];
|
||||||
|
int freq_len, ack_len, retval;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 10Hz resolution
|
||||||
|
* TODO: round nearest?
|
||||||
|
*/
|
||||||
|
freq_len = sprintf(freqbuf,"F%07Ld" EOM, freq/10);
|
||||||
|
retval = drake_transaction(rig, freqbuf, freq_len, ackbuf, &ack_len);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* drake_set_vfo
|
||||||
|
* Assumes rig!=NULL
|
||||||
|
*/
|
||||||
|
int drake_set_vfo(RIG *rig, vfo_t vfo)
|
||||||
|
{
|
||||||
|
unsigned char cmdbuf[16], ackbuf[16];
|
||||||
|
int cmd_len, ack_len, retval;
|
||||||
|
char vfo_function;
|
||||||
|
|
||||||
|
switch (vfo) {
|
||||||
|
case RIG_VFO_VFO:
|
||||||
|
case RIG_VFO_A: vfo_function = 'A'; break;
|
||||||
|
case RIG_VFO_B: vfo_function = 'B'; break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR,"drake_set_vfo: unsupported VFO %d\n",
|
||||||
|
vfo);
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_len = sprintf(cmdbuf, "V%c" EOM, vfo_function);
|
||||||
|
|
||||||
|
retval = drake_transaction (rig, cmdbuf, cmd_len, ackbuf, &ack_len);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* drake_set_mode
|
||||||
|
* Assumes rig!=NULL
|
||||||
|
*/
|
||||||
|
int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
|
{
|
||||||
|
unsigned char mdbuf[16], ackbuf[16];
|
||||||
|
unsigned char mode_sel, width_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_RTTY; break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR,"drake_set_mode: "
|
||||||
|
"unsupported mode %d\n", mode);
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mdbuf_len = sprintf(mdbuf, "M%c" EOM, mode_sel);
|
||||||
|
retval = drake_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||||
|
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
if (mode != RIG_MODE_FM) {
|
||||||
|
|
||||||
|
if (width == RIG_PASSBAND_NORMAL)
|
||||||
|
width = rig_passband_normal(rig, mode);
|
||||||
|
|
||||||
|
switch (width) {
|
||||||
|
case 500: width_sel = '0'; break;
|
||||||
|
case 1800: width_sel = '1'; break;
|
||||||
|
case 2300: width_sel = '2'; break;
|
||||||
|
case 4000: width_sel = '4'; break;
|
||||||
|
case 6000: width_sel = '6'; break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR,"drake_set_mode: "
|
||||||
|
"unsupported width %d\n", width);
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
mdbuf_len = sprintf(mdbuf, "W%c" EOM, width_sel);
|
||||||
|
retval = drake_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* drake_set_freq
|
||||||
|
* Assumes rig!=NULL
|
||||||
|
*/
|
||||||
|
const char *drake_get_info(RIG *rig)
|
||||||
|
{
|
||||||
|
static unsigned char idbuf[BUFSZ];
|
||||||
|
int retval, id_len;
|
||||||
|
|
||||||
|
retval = drake_transaction(rig, "ID" EOM, 4, idbuf, &id_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
idbuf[id_len] = '\0';
|
||||||
|
|
||||||
|
return idbuf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initrigs_drake is called by rig_backend_load
|
* initrigs_drake is called by rig_backend_load
|
||||||
|
@ -99,3 +218,47 @@ int initrigs_drake(void *be_handle)
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* probe_drake
|
||||||
|
*/
|
||||||
|
rig_model_t probe_drake(port_t *port)
|
||||||
|
{
|
||||||
|
static unsigned char idbuf[BUFSZ];
|
||||||
|
int retval, id_len;
|
||||||
|
|
||||||
|
if (!port)
|
||||||
|
return RIG_MODEL_NONE;
|
||||||
|
|
||||||
|
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, "ID" EOM, 4);
|
||||||
|
id_len = read_string(port, idbuf, BUFSZ, CRLF, 2);
|
||||||
|
|
||||||
|
close(port->fd);
|
||||||
|
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return RIG_MODEL_NONE;
|
||||||
|
|
||||||
|
idbuf[id_len] = '\0';
|
||||||
|
|
||||||
|
|
||||||
|
if (!strcmp(idbuf, "R8B"))
|
||||||
|
return RIG_MODEL_DKR8B;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* not found...
|
||||||
|
*/
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE,"probe_drake: found unknown device "
|
||||||
|
"with ID '%s', please report to Hamlib "
|
||||||
|
"developers.\n", idbuf);
|
||||||
|
|
||||||
|
return RIG_MODEL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Drake backend - main header
|
* Hamlib Drake backend - main header
|
||||||
* Copyright (c) 2001,2002 by Stephane Fillod
|
* Copyright (c) 2001,2002 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: drake.h,v 1.1 2002-07-08 22:10:43 fillods Exp $
|
* $Id: drake.h,v 1.2 2002-10-20 20:46:32 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -27,10 +27,14 @@
|
||||||
|
|
||||||
|
|
||||||
int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||||
|
int drake_set_vfo(RIG *rig, vfo_t vfo);
|
||||||
|
int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||||
|
const char *drake_get_info(RIG *rig);
|
||||||
|
|
||||||
extern const struct rig_caps r8b_caps;
|
extern const struct rig_caps r8b_caps;
|
||||||
|
|
||||||
extern BACKEND_EXPORT(int) initrigs_drake(void *be_handle);
|
extern BACKEND_EXPORT(int) initrigs_drake(void *be_handle);
|
||||||
|
extern BACKEND_EXPORT(rig_model_t) probe_drake(port_t *port);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _DRAKE_H */
|
#endif /* _DRAKE_H */
|
||||||
|
|
54
drake/r8b.c
54
drake/r8b.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Drake backend - R-8B description
|
* Hamlib Drake backend - R-8B description
|
||||||
* Copyright (c) 2001-2002 by Stephane Fillod
|
* Copyright (c) 2001-2002 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: r8b.c,v 1.2 2002-08-16 17:43:01 fillods Exp $
|
* $Id: r8b.c,v 1.3 2002-10-20 20:46:32 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -28,8 +28,7 @@
|
||||||
#include "drake.h"
|
#include "drake.h"
|
||||||
|
|
||||||
|
|
||||||
/* FIXME! */
|
#define R8B_MODES (RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM|RIG_MODE_FM)
|
||||||
#define R8B_MODES (RIG_MODE_NONE)
|
|
||||||
|
|
||||||
#define R8B_FUNC (RIG_FUNC_NONE)
|
#define R8B_FUNC (RIG_FUNC_NONE)
|
||||||
|
|
||||||
|
@ -37,20 +36,25 @@
|
||||||
|
|
||||||
#define R8B_PARM_ALL (RIG_PARM_NONE)
|
#define R8B_PARM_ALL (RIG_PARM_NONE)
|
||||||
|
|
||||||
#define R8B_VFO RIG_VFO_A
|
#define R8B_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||||
|
|
||||||
|
#define R8B_VFO_OPS (RIG_OP_UP|RIG_OP_DOWN|RIG_OP_CPY)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* R-8B rig capabilities.
|
* R-8B rig capabilities.
|
||||||
*
|
*
|
||||||
* TODO: check this with manual or web site.
|
* manual: http://www.rldrake.com/swl/R8B.pdf
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const struct rig_caps r8b_caps = {
|
const struct rig_caps r8b_caps = {
|
||||||
.rig_model = RIG_MODEL_DKR8B,
|
.rig_model = RIG_MODEL_DKR8B,
|
||||||
.model_name = "R-8B",
|
.model_name = "R-8B",
|
||||||
.mfg_name = "Drake",
|
.mfg_name = "Drake",
|
||||||
.version = "0.1",
|
.version = "0.1",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_UNTESTED, /* and only basic support */
|
||||||
.rig_type = RIG_TYPE_RECEIVER,
|
.rig_type = RIG_TYPE_RECEIVER,
|
||||||
.ptt_type = RIG_PTT_NONE,
|
.ptt_type = RIG_PTT_NONE,
|
||||||
.dcd_type = RIG_DCD_NONE,
|
.dcd_type = RIG_DCD_NONE,
|
||||||
|
@ -60,7 +64,7 @@ const struct rig_caps r8b_caps = {
|
||||||
.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_HARDWARE,
|
||||||
.write_delay = 0,
|
.write_delay = 0,
|
||||||
.post_write_delay = 1,
|
.post_write_delay = 1,
|
||||||
.timeout = 200,
|
.timeout = 200,
|
||||||
|
@ -76,40 +80,56 @@ const struct rig_caps r8b_caps = {
|
||||||
.parm_gran = {},
|
.parm_gran = {},
|
||||||
.ctcss_list = NULL,
|
.ctcss_list = NULL,
|
||||||
.dcs_list = NULL,
|
.dcs_list = NULL,
|
||||||
.preamp = { RIG_DBLST_END },
|
.preamp = { 10, RIG_DBLST_END },
|
||||||
.attenuator = { RIG_DBLST_END },
|
.attenuator = { 10, RIG_DBLST_END },
|
||||||
.max_rit = Hz(0),
|
.max_rit = Hz(0),
|
||||||
.max_xit = Hz(0),
|
.max_xit = Hz(0),
|
||||||
.max_ifshift = Hz(0),
|
.max_ifshift = Hz(0),
|
||||||
.targetable_vfo = 0,
|
.targetable_vfo = 0,
|
||||||
.transceive = RIG_TRN_OFF,
|
.transceive = RIG_TRN_OFF, /* TODO: acutally has RIG_TRN_RIG */
|
||||||
.bank_qty = 0,
|
.bank_qty = 0,
|
||||||
.chan_desc_sz = 0,
|
.chan_desc_sz = 7,
|
||||||
|
.vfo_ops = R8B_VFO_OPS,
|
||||||
|
|
||||||
.chan_list = {
|
.chan_list = {
|
||||||
RIG_CHAN_END,
|
RIG_CHAN_END, /* FIXME */
|
||||||
},
|
},
|
||||||
|
|
||||||
.rx_range_list1 = { RIG_FRNG_END, }, /* FIXME: enter region 1 setting */
|
.rx_range_list1 = {
|
||||||
|
{kHz(10),MHz(30),R8B_MODES,-1,-1,R8B_VFO},
|
||||||
|
RIG_FRNG_END,
|
||||||
|
},
|
||||||
.tx_range_list1 = { RIG_FRNG_END, },
|
.tx_range_list1 = { RIG_FRNG_END, },
|
||||||
.rx_range_list2 = {
|
.rx_range_list2 = {
|
||||||
{MHz(29),MHz(956),R8B_MODES,-1,-1,R8B_VFO}, // FIXME
|
{kHz(10),MHz(30),R8B_MODES,-1,-1,R8B_VFO},
|
||||||
RIG_FRNG_END,
|
RIG_FRNG_END,
|
||||||
},
|
},
|
||||||
.tx_range_list2 = { RIG_FRNG_END, },
|
.tx_range_list2 = { RIG_FRNG_END, },
|
||||||
|
|
||||||
.tuning_steps = {
|
.tuning_steps = {
|
||||||
{R8B_MODES,10}, /* FIXME: add other ts */
|
{R8B_MODES,10},
|
||||||
|
{R8B_MODES,100},
|
||||||
|
{R8B_MODES,kHz(1)},
|
||||||
|
{R8B_MODES,kHz(10)},
|
||||||
RIG_TS_END,
|
RIG_TS_END,
|
||||||
},
|
},
|
||||||
/* mode/filter list, remember: order matters! */
|
/* mode/filter list, remember: order matters! */
|
||||||
.filters = {
|
.filters = {
|
||||||
{RIG_MODE_AM|RIG_MODE_FM, kHz(8)},
|
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, kHz(2.3)}, /* normal */
|
||||||
{RIG_MODE_WFM, kHz(230)},
|
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, kHz(6)}, /* wide */
|
||||||
|
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, kHz(4)},
|
||||||
|
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, kHz(1.8)}, /* narrow */
|
||||||
|
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY|RIG_MODE_AM, Hz(500)},
|
||||||
|
{RIG_MODE_FM, kHz(12)},
|
||||||
RIG_FLT_END,
|
RIG_FLT_END,
|
||||||
},
|
},
|
||||||
.priv = NULL,
|
.priv = NULL,
|
||||||
|
|
||||||
.set_freq = drake_set_freq,
|
.set_freq = drake_set_freq,
|
||||||
|
.set_vfo = drake_set_vfo,
|
||||||
|
.set_mode = drake_set_mode,
|
||||||
|
|
||||||
|
.get_info = drake_get_info,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue