2019-06-12 20:52:35 +00:00
|
|
|
/*
|
|
|
|
* Hamlib backend library for the Elecraft KPA1500 command set.
|
|
|
|
*
|
|
|
|
* kpa1500.c - (C) Michael Black W9MDB 2019
|
|
|
|
*
|
|
|
|
* This shared library provides an API for communicating
|
|
|
|
* to an Elecraft KPA1500 amplifier.
|
|
|
|
*
|
|
|
|
* 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h> /* Standard library definitions */
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
|
|
|
|
#include "register.h"
|
|
|
|
|
|
|
|
#include "kpa.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct kpa_priv_data *kpa1500_priv;
|
|
|
|
/*
|
|
|
|
* API local implementation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private helper function prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
//static int kpa1500_send_priv_cmd(AMP *amp, const char *cmd);
|
|
|
|
//static int kpa1500_flush_buffer(AMP *amp);
|
|
|
|
|
|
|
|
/* *************************************
|
|
|
|
*
|
|
|
|
* Separate model capabilities
|
|
|
|
*
|
|
|
|
* *************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Elecraft KPA1500
|
|
|
|
*/
|
|
|
|
|
|
|
|
const struct amp_caps kpa1500_amp_caps =
|
|
|
|
{
|
2020-03-06 05:48:14 +00:00
|
|
|
AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500),
|
2019-11-30 16:19:08 +00:00
|
|
|
.model_name = "KPA1500",
|
|
|
|
.mfg_name = "Elecraft",
|
2021-09-01 14:11:00 +00:00
|
|
|
.version = "20210901.0",
|
2019-11-30 16:19:08 +00:00
|
|
|
.copyright = "LGPL",
|
|
|
|
.status = RIG_STATUS_ALPHA,
|
|
|
|
.amp_type = AMP_TYPE_OTHER,
|
|
|
|
.port_type = RIG_PORT_SERIAL,
|
|
|
|
.serial_rate_min = 4800,
|
|
|
|
.serial_rate_max = 230400,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 1,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
|
|
|
.write_delay = 0,
|
|
|
|
.post_write_delay = 0,
|
|
|
|
.timeout = 2000,
|
|
|
|
.retry = 2,
|
|
|
|
|
|
|
|
.amp_open = amp_open,
|
2019-12-06 21:19:58 +00:00
|
|
|
.amp_init = kpa_init,
|
2020-01-12 13:56:10 +00:00
|
|
|
.amp_close = kpa_close,
|
2019-11-30 16:19:08 +00:00
|
|
|
.reset = kpa_reset,
|
|
|
|
.get_info = kpa_get_info,
|
|
|
|
.get_powerstat = kpa_get_powerstat,
|
|
|
|
.set_powerstat = kpa_set_powerstat,
|
|
|
|
.set_freq = kpa_set_freq,
|
|
|
|
.get_freq = kpa_get_freq,
|
|
|
|
.get_level = kpa_get_level,
|
2019-06-12 20:52:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************
|
|
|
|
*
|
|
|
|
* API functions
|
|
|
|
*
|
|
|
|
* ************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-06-26 11:39:42 +00:00
|
|
|
#if 0 // not implemented yet
|
2019-06-12 20:52:35 +00:00
|
|
|
/*
|
|
|
|
* Send command string to amplifier
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int kpa1500_send_priv_cmd(AMP *amp, const char *cmdstr)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct amp_state *rs;
|
|
|
|
int err;
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (!amp)
|
|
|
|
{
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rs = &->state;
|
|
|
|
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (err != RIG_OK)
|
|
|
|
{
|
|
|
|
return err;
|
|
|
|
}
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2019-06-12 20:52:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize backend
|
|
|
|
*/
|
|
|
|
|
|
|
|
DECLARE_INITAMP_BACKEND(kpa1500)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
amp_register(&kpa1500_amp_caps);
|
2019-06-12 20:52:35 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2019-06-12 20:52:35 +00:00
|
|
|
}
|