kopia lustrzana https://github.com/Hamlib/Hamlib
* Initial release
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@306 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.1
rodzic
0ed363957b
commit
205d2fbac6
|
@ -0,0 +1,6 @@
|
|||
lib_LTLIBRARIES = libhamlib-kenwood.la
|
||||
libhamlib_kenwood_la_SOURCES = ts870s.c kenwood.c
|
||||
libhamlib_kenwood_la_LDFLAGS = -avoid-version # -module
|
||||
lib_LIBRARIES = libhamlib-kenwood.a
|
||||
libhamlib_kenwood_a_SOURCES = ts870s.c kenwood.c
|
||||
noinst_HEADERS = kenwood.h
|
|
@ -0,0 +1,37 @@
|
|||
hamlib - Copyright (C) 2000 Frank Singleton
|
||||
|
||||
libkenwood.so - Copyright (C) 2000 Stephane Fillod
|
||||
This shared library provides an API for communicating
|
||||
via serial interface to a Kenwood rig.
|
||||
|
||||
|
||||
Reference Documentation
|
||||
-----------------------
|
||||
|
||||
Kenwood CAT protocol (manual).
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
This is a WIP.
|
||||
Handles 5% of all opcodes.
|
||||
All primitives are written from spec. In other words,
|
||||
they are totally untested because I don't own a Kenwood radio myself.
|
||||
Patchs and contributions are welcome! I'm also looking for
|
||||
a real maintainer :) --SF
|
||||
|
||||
|
||||
This lib should/will support other Kenwood models.
|
||||
|
||||
Warnings
|
||||
--------
|
||||
|
||||
1. NOTHING IS WORKING, this is a WIP.
|
||||
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* kenwood.c - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to a Kenwood radio.
|
||||
*
|
||||
*
|
||||
* $Id: kenwood.c,v 1.1 2000-12-23 08:40:14 f4cfe Exp $
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <sys/ioctl.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <hamlib/riglist.h>
|
||||
#include <serial.h>
|
||||
#include <misc.h>
|
||||
#include "kenwood.h"
|
||||
|
||||
|
||||
/*
|
||||
* modes in use by the "MD" command
|
||||
*/
|
||||
#define MD_LSB '1'
|
||||
#define MD_USB '2'
|
||||
#define MD_CW '3'
|
||||
#define MD_FM '4'
|
||||
|
||||
/*
|
||||
* kenwood_transaction
|
||||
* We assume that rig!=NULL, rig->state!= NULL, data!=NULL, data_len!=NULL
|
||||
* Otherwise, you'll get a nice seg fault. You've been warned!
|
||||
* TODO: error case handling
|
||||
*/
|
||||
int kenwood_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len)
|
||||
{
|
||||
int i;
|
||||
struct rig_state *rig_s;
|
||||
|
||||
rig_s = &rig->state;
|
||||
|
||||
write_block(rig_s->fd, cmd, cmd_len, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
/*
|
||||
* buffered read are quite helpful here!
|
||||
* However, an automate with a state model would be more efficient..
|
||||
*/
|
||||
i = 0;
|
||||
do {
|
||||
fread_block(rig_s->stream, data+i, 1, rig_s->timeout);
|
||||
} while (data[i++] != ';');
|
||||
|
||||
*data_len = i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_set_freq
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
unsigned char freqbuf[16], ackbuf[16];
|
||||
int freq_len,ack_len;
|
||||
char vfo_letter;
|
||||
|
||||
/*
|
||||
* FIXME: vfo==RIG_VFO_CURR
|
||||
*/
|
||||
vfo_letter = vfo==RIG_VFO_A? 'A':'B';
|
||||
freq_len = sprintf(freqbuf,"F%c%011Ld;", vfo_letter, freq);
|
||||
|
||||
kenwood_transaction (rig, freqbuf, freq_len, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 1) {
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_set_freq: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_get_freq
|
||||
* Assumes rig!=NULL, freq!=NULL
|
||||
*/
|
||||
int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
unsigned char freqbuf[16];
|
||||
unsigned char cmdbuf[4];
|
||||
int freq_len;
|
||||
|
||||
/*
|
||||
* FIXME: vfo==RIG_VFO_CURR
|
||||
*/
|
||||
cmdbuf[0] = 'F';
|
||||
cmdbuf[1] = vfo==RIG_VFO_A? 'A':'B';
|
||||
cmdbuf[2] = ';';
|
||||
|
||||
kenwood_transaction (rig, cmdbuf, 3, freqbuf, &freq_len);
|
||||
|
||||
sscanf(freqbuf,"%Ld", freq);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_set_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
unsigned char mdbuf[16],ackbuf[16];
|
||||
int mdbuf_len,ack_len,kmode;
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_CW: kmode = MD_CW; break;
|
||||
case RIG_MODE_USB: kmode = MD_USB; break;
|
||||
case RIG_MODE_LSB: kmode = MD_LSB; break;
|
||||
case RIG_MODE_FM: kmode = MD_FM; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_set_mode: unsupported mode %d\n",
|
||||
mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mdbuf_len = sprintf(mdbuf, "MD%c;", kmode);
|
||||
kenwood_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 1) {
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_set_mode: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_get_mode
|
||||
* Assumes rig!=NULL, mode!=NULL
|
||||
*/
|
||||
int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||
{
|
||||
unsigned char ackbuf[16];
|
||||
int ack_len;
|
||||
|
||||
|
||||
kenwood_transaction (rig, "MD;", 2, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 2) {
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_get_mode: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
switch (ackbuf[0]) {
|
||||
case MD_CW: *mode = RIG_MODE_CW; break;
|
||||
case MD_USB: *mode = RIG_MODE_USB; break;
|
||||
case MD_LSB: *mode = RIG_MODE_LSB; break;
|
||||
case MD_FM: *mode = RIG_MODE_FM; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_get_mode: unsupported mode %d\n",
|
||||
ackbuf[0]);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* init_kenwood is called by rig_backend_load
|
||||
*/
|
||||
int init_kenwood(void *be_handle)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "kenwood: _init called\n");
|
||||
|
||||
rig_register(&ts870s_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* kenwood.h - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to a Kenwood radio.
|
||||
*
|
||||
*
|
||||
* $Id: kenwood.h,v 1.1 2000-12-23 08:40:14 f4cfe Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _KENWOOD_H
|
||||
#define _KENWOOD_H 1
|
||||
|
||||
|
||||
int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||
int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||
|
||||
extern const struct rig_caps ts870s_caps;
|
||||
|
||||
extern int init_kenwood(void *be_handle);
|
||||
|
||||
|
||||
#endif /* _KENWOOD_H */
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ts870s.c - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to a Kenwood radio
|
||||
* using the serial interface.
|
||||
*
|
||||
*
|
||||
* $Id: ts870s.c,v 1.1 2000-12-23 08:40:14 f4cfe Exp $
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <hamlib/riglist.h>
|
||||
#include "kenwood.h"
|
||||
|
||||
|
||||
#define TS870S_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_FM)
|
||||
|
||||
#define TS870S_FUNC_ALL (RIG_FUNC_TSQL)
|
||||
|
||||
#define TS870S_LEVEL_ALL (RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_SQL|RIG_LEVEL_SQLSTAT|RIG_LEVEL_STRENGTH)
|
||||
|
||||
/*
|
||||
* ts870s rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
* Also this struct is READONLY!
|
||||
*/
|
||||
const struct rig_caps ts870s_caps = {
|
||||
RIG_MODEL_TS870S, "TS-870S", "Kenwood", "0.1", RIG_STATUS_UNTESTED,
|
||||
RIG_TYPE_TRANSCEIVER, RIG_PTT_RIG, 1200, 57600, 8, 1, RIG_PARITY_NONE,
|
||||
RIG_HANDSHAKE_NONE, 0, 0, 2000, 3, TS870S_FUNC_ALL, TS870S_LEVEL_ALL,
|
||||
TS870S_LEVEL_ALL, 1000, RIG_TRN_ON,
|
||||
{
|
||||
{KHz(100),MHz(2040),TS870S_ALL_MODES,-1,-1},
|
||||
{0,0,0,0,0},
|
||||
}, /* rx range */
|
||||
{ {0,0,0,0,0} }, /* no tx range, this is a scanner! */
|
||||
{
|
||||
{TS870S_ALL_MODES,50},
|
||||
{TS870S_ALL_MODES,100},
|
||||
{TS870S_ALL_MODES,KHz(1)},
|
||||
{TS870S_ALL_MODES,KHz(5)},
|
||||
{TS870S_ALL_MODES,KHz(9)},
|
||||
{TS870S_ALL_MODES,KHz(10)},
|
||||
{TS870S_ALL_MODES,12500},
|
||||
{TS870S_ALL_MODES,KHz(20)},
|
||||
{TS870S_ALL_MODES,KHz(25)},
|
||||
{TS870S_ALL_MODES,KHz(100)},
|
||||
{TS870S_ALL_MODES,MHz(1)},
|
||||
{TS870S_ALL_MODES,0}, /* any tuning step */
|
||||
{0,0}
|
||||
},
|
||||
NULL, NULL, NULL, NULL, NULL /* probe not supported yet */,
|
||||
kenwood_set_freq, kenwood_get_freq, kenwood_set_mode, kenwood_get_mode, NULL,
|
||||
};
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
|
Ładowanie…
Reference in New Issue