kopia lustrzana https://github.com/Hamlib/Hamlib
Bumped out to beta, solved a few bugs. Tested with PCR100/1000/1500.
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2779 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.11
rodzic
7cb82e376a
commit
46de76084e
40
pcr/pcr.c
40
pcr/pcr.c
|
@ -20,6 +20,14 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Tested on
|
||||
*
|
||||
* (402) PCR100 fw 1.2, proto 1.0 (usb-to-serial) by IZ1PRB
|
||||
* (401) PCR1000 fw 1.0, proto 1.0 (serial) by KM3T
|
||||
* (403) PCR1500 fw 2.0, proto 2.0 (usb) by KM3T
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -133,12 +141,13 @@ pcr_read_block(RIG *rig, char *rxbuffer, size_t count)
|
|||
int read = 0, tries = 4;
|
||||
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct pcr_priv_data *priv = (struct pcr_priv_data *) rs->priv;
|
||||
struct pcr_priv_caps *caps = pcr_caps(rig);
|
||||
struct pcr_priv_data *priv = (struct pcr_priv_data *) rs->priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
|
||||
|
||||
/* already in sync? */
|
||||
if (priv->sync)
|
||||
if (priv->sync && !caps->always_sync)
|
||||
return read_block(&rs->rigport, rxbuffer, count);
|
||||
|
||||
/* read first char */
|
||||
|
@ -154,7 +163,7 @@ pcr_read_block(RIG *rig, char *rxbuffer, size_t count)
|
|||
return -RIG_EPROTO;
|
||||
|
||||
/* validate */
|
||||
if (!is_valid_answer(*p))
|
||||
if (*p != 0x0a && !is_valid_answer(*p))
|
||||
continue;
|
||||
|
||||
/* sync ok, read remaining chars */
|
||||
|
@ -263,10 +272,9 @@ pcr_send(RIG * rig, const char *cmd)
|
|||
/* XXX check max len */
|
||||
memcpy(priv->cmd_buf, cmd, len);
|
||||
|
||||
/* append cr lf */
|
||||
/* XXX not required in auto update mode? */
|
||||
/* append cr */
|
||||
/* XXX not required in auto update mode? (should not harm) */
|
||||
priv->cmd_buf[len+0] = 0x0a;
|
||||
priv->cmd_buf[len+1] = 0x0a;
|
||||
|
||||
rs->hold_decode = 1;
|
||||
|
||||
|
@ -277,14 +285,13 @@ pcr_send(RIG * rig, const char *cmd)
|
|||
return err;
|
||||
}
|
||||
|
||||
#define PCR_REPLY_SIZE 6
|
||||
|
||||
static int
|
||||
pcr_transaction(RIG * rig, const char *cmd)
|
||||
{
|
||||
int err;
|
||||
char buf[PCR_REPLY_SIZE];
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct pcr_priv_caps *caps = pcr_caps(rig);
|
||||
struct pcr_priv_data *priv = (struct pcr_priv_data *) rs->priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmd = %s\n",
|
||||
|
@ -299,22 +306,19 @@ pcr_transaction(RIG * rig, const char *cmd)
|
|||
if (priv->auto_update)
|
||||
return RIG_OK;
|
||||
|
||||
err = pcr_read_block(rig, buf, PCR_REPLY_SIZE);
|
||||
err = pcr_read_block(rig, priv->reply_buf, caps->reply_size);
|
||||
if (err < 0) {
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: read error, %s\n", __func__, strerror(errno));
|
||||
return err;
|
||||
}
|
||||
|
||||
if (err != PCR_REPLY_SIZE) {
|
||||
if (err != caps->reply_size) {
|
||||
priv->sync = 0;
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: got %c%c%c%c\n", __func__, buf[0], buf[1], buf[2], buf[3]);
|
||||
|
||||
return pcr_parse_answer(rig, buf, err);
|
||||
return pcr_parse_answer(rig, &priv->reply_buf[caps->reply_offset], err);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -466,7 +470,13 @@ pcr_open(RIG * rig)
|
|||
pcr_send(rig, "H101");
|
||||
usleep(100*250);
|
||||
|
||||
err = pcr_transaction(rig, "H101");
|
||||
pcr_send(rig, "H101");
|
||||
usleep(100*250);
|
||||
|
||||
serial_flush(&rs->rigport);
|
||||
|
||||
/* return RIG_ERJCTED if power is off */
|
||||
err = pcr_transaction(rig, "H1?");
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
|
|
15
pcr/pcr.h
15
pcr/pcr.h
|
@ -29,12 +29,11 @@
|
|||
/* ext_level's tokens */
|
||||
#define TOK_EL_ANL TOKEN_BACKEND(1)
|
||||
|
||||
|
||||
#define BACKEND_VER "0.7"
|
||||
|
||||
#define PCR_MAX_CMD_LEN 32
|
||||
|
||||
struct pcr_priv_data {
|
||||
struct pcr_priv_data
|
||||
{
|
||||
freq_t last_freq;
|
||||
rmode_t last_mode;
|
||||
|
||||
|
@ -52,6 +51,7 @@ struct pcr_priv_data {
|
|||
|
||||
char info[100];
|
||||
char cmd_buf[PCR_MAX_CMD_LEN];
|
||||
char reply_buf[PCR_MAX_CMD_LEN];
|
||||
|
||||
int protocol;
|
||||
int firmware;
|
||||
|
@ -63,6 +63,15 @@ struct pcr_priv_data {
|
|||
powerstat_t power;
|
||||
};
|
||||
|
||||
struct pcr_priv_caps
|
||||
{
|
||||
unsigned int reply_size;
|
||||
unsigned int reply_offset;
|
||||
unsigned int always_sync;
|
||||
};
|
||||
|
||||
#define pcr_caps(rig) ((struct pcr_priv_caps *)(rig)->caps->priv)
|
||||
|
||||
extern const tone_t pcr_ctcss_list[];
|
||||
|
||||
int pcr_init(RIG *rig);
|
||||
|
|
10
pcr/pcr100.c
10
pcr/pcr100.c
|
@ -46,6 +46,12 @@ static const struct confparams pcr_ext_levels[] = {
|
|||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
static const struct pcr_priv_caps pcr100_priv = {
|
||||
.reply_size = 6,
|
||||
.reply_offset = 0,
|
||||
.always_sync = 0,
|
||||
};
|
||||
|
||||
/*
|
||||
* IC PCR100 rigs capabilities.
|
||||
*/
|
||||
|
@ -67,7 +73,7 @@ const struct rig_caps pcr100_caps = {
|
|||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
|
||||
|
||||
.write_delay = 12,
|
||||
.post_write_delay = 2,
|
||||
|
@ -137,7 +143,7 @@ const struct rig_caps pcr100_caps = {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL,
|
||||
.priv = (void *) &pcr100_priv,
|
||||
|
||||
/* XXX verify */
|
||||
.str_cal = { 7, {
|
||||
|
|
|
@ -41,6 +41,12 @@
|
|||
RIG_LEVEL_AGC | RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | \
|
||||
RIG_LEVEL_NR )
|
||||
|
||||
static const struct pcr_priv_caps pcr1000_priv = {
|
||||
.reply_size = 6,
|
||||
.reply_offset = 1,
|
||||
.always_sync = 0,
|
||||
};
|
||||
|
||||
/*
|
||||
* IC PCR1000 rigs capabilities.
|
||||
*/
|
||||
|
@ -50,7 +56,7 @@ const struct rig_caps pcr1000_caps = {
|
|||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER,
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_ALPHA,
|
||||
.status = RIG_STATUS_BETA,
|
||||
|
||||
.rig_type = RIG_TYPE_PCRECEIVER,
|
||||
.ptt_type = RIG_PTT_NONE,
|
||||
|
@ -62,7 +68,7 @@ const struct rig_caps pcr1000_caps = {
|
|||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
|
||||
|
||||
.write_delay = 12,
|
||||
.post_write_delay = 2,
|
||||
|
@ -126,7 +132,7 @@ const struct rig_caps pcr1000_caps = {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL,
|
||||
.priv = (void *) &pcr1000_priv,
|
||||
|
||||
/* XXX fake */
|
||||
.str_cal = { 3, { { 0, -60 }, { 127, 0 }, { 255, 60 } } },
|
||||
|
@ -155,6 +161,6 @@ const struct rig_caps pcr1000_caps = {
|
|||
.set_trn = pcr_set_trn,
|
||||
.decode_event = pcr_decode_event,
|
||||
|
||||
.set_powerstat = pcr_set_powerstat,
|
||||
.get_powerstat = pcr_get_powerstat,
|
||||
.set_powerstat = pcr_set_powerstat,
|
||||
.get_powerstat = pcr_get_powerstat,
|
||||
};
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
RIG_LEVEL_AGC | RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | \
|
||||
RIG_LEVEL_NR )
|
||||
|
||||
|
||||
static const struct pcr_priv_caps pcr1500_priv = {
|
||||
.reply_size = 6,
|
||||
.reply_offset = 0,
|
||||
.always_sync = 0,
|
||||
};
|
||||
|
||||
/*
|
||||
* IC PCR1500 rigs capabilities.
|
||||
*/
|
||||
|
@ -52,23 +59,23 @@ const struct rig_caps pcr1500_caps = {
|
|||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER,
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_ALPHA,
|
||||
.status = RIG_STATUS_BETA,
|
||||
|
||||
.rig_type = RIG_TYPE_PCRECEIVER,
|
||||
.ptt_type = RIG_PTT_NONE,
|
||||
.dcd_type = RIG_DCD_RIG,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
|
||||
.serial_rate_min = 300,
|
||||
.serial_rate_min = 9600, /* lower speeds gave troubles */
|
||||
.serial_rate_max = 38400,
|
||||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
|
||||
|
||||
.write_delay = 12,
|
||||
.post_write_delay = 0,
|
||||
.timeout = 300,
|
||||
.post_write_delay = 2,
|
||||
.timeout = 400,
|
||||
.retry = 3,
|
||||
|
||||
.has_get_func = PCR1500_FUNC,
|
||||
|
@ -132,7 +139,7 @@ const struct rig_caps pcr1500_caps = {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL,
|
||||
.priv = (void *) &pcr1500_priv,
|
||||
|
||||
/* XXX fake */
|
||||
.str_cal = { 3, { { 0, -60 }, { 127, 0 }, { 255, 60 } } },
|
||||
|
@ -161,7 +168,6 @@ const struct rig_caps pcr1500_caps = {
|
|||
.set_trn = pcr_set_trn,
|
||||
.decode_event = pcr_decode_event,
|
||||
|
||||
.set_powerstat = pcr_set_powerstat,
|
||||
.get_powerstat = pcr_get_powerstat,
|
||||
|
||||
.set_powerstat = pcr_set_powerstat,
|
||||
.get_powerstat = pcr_get_powerstat,
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue