2001-06-04 21:07:17 +00:00
|
|
|
/*
|
|
|
|
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
|
|
|
*
|
2010-03-05 19:18:10 +00:00
|
|
|
* yaesu.c - (C) Stephane Fillod 2001-2010
|
2001-06-04 21:07:17 +00:00
|
|
|
*
|
|
|
|
* This shared library provides an API for communicating
|
|
|
|
* via serial interface to a Yaesu rig
|
|
|
|
*
|
|
|
|
*
|
2009-01-04 10:40:34 +00:00
|
|
|
* $Id: yaesu.c,v 1.31 2009-01-04 10:40:34 fillods Exp $
|
2002-12-01 03:08:05 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2001-06-04 21:07:17 +00:00
|
|
|
*/
|
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-06-04 21:07:17 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#include "hamlib/rig.h"
|
2001-12-16 11:14:47 +00:00
|
|
|
#include "serial.h"
|
|
|
|
#include "misc.h"
|
2003-04-16 22:30:43 +00:00
|
|
|
#include "register.h"
|
2001-06-15 07:08:37 +00:00
|
|
|
|
2001-06-04 21:07:17 +00:00
|
|
|
#include "yaesu.h"
|
|
|
|
|
2005-02-26 23:44:41 +00:00
|
|
|
struct yaesu_id {
|
|
|
|
rig_model_t model;
|
|
|
|
int id1, id2;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define UNKNOWN_ID -1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Identification number as returned by 0xFA opcode.
|
|
|
|
* Note: On the FT736R, the 0xFA opcode sets CTCSS tone code
|
|
|
|
*
|
|
|
|
* Please, if the model number of your rig is listed as UNKNOWN_ID,
|
|
|
|
* send the value to <fillods@users.sourceforge.net> for inclusion. Thanks --SF
|
|
|
|
*/
|
|
|
|
static const struct yaesu_id yaesu_id_list[] = {
|
|
|
|
{ RIG_MODEL_FT1000, 0x10, 0x21 }, /* or 0x10, 0x00 ? */
|
|
|
|
{ RIG_MODEL_FT990, 0x09, 0x90 },
|
|
|
|
{ RIG_MODEL_FT890, 0x08, 0x41 },
|
|
|
|
{ RIG_MODEL_FRG100, 0x03, 0x92 }, /* TBC, inconsistency in manual */
|
|
|
|
{ RIG_MODEL_FT1000MP, 0x03, 0x93 },
|
|
|
|
{ RIG_MODEL_FT1000MPMKV, 0x03, 0x93 }, /* or 0x10, 0x00 ? */
|
|
|
|
{ RIG_MODEL_FT1000MPMKVFLD, 0x03, 0x93 },
|
|
|
|
{ RIG_MODEL_NONE, UNKNOWN_ID, UNKNOWN_ID }, /* end marker */
|
|
|
|
};
|
|
|
|
|
2001-06-04 21:07:17 +00:00
|
|
|
|
|
|
|
/*
|
2001-12-28 20:28:04 +00:00
|
|
|
* initrigs_yaesu is called by rig_backend_load
|
2001-06-04 21:07:17 +00:00
|
|
|
*/
|
|
|
|
|
2003-04-16 22:30:43 +00:00
|
|
|
DECLARE_INITRIG_BACKEND(yaesu)
|
2001-06-04 21:07:17 +00:00
|
|
|
{
|
2003-03-09 04:43:38 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "yaesu: %s called\n", __func__);
|
2001-06-04 21:07:17 +00:00
|
|
|
|
2003-03-09 04:43:38 +00:00
|
|
|
rig_register(&ft100_caps);
|
2007-11-23 03:31:26 +00:00
|
|
|
rig_register(&ft450_caps);
|
2004-08-10 21:10:36 +00:00
|
|
|
rig_register(&ft736_caps);
|
2003-03-09 04:43:38 +00:00
|
|
|
rig_register(&ft747_caps);
|
2004-04-24 13:01:00 +00:00
|
|
|
rig_register(&ft757gx_caps);
|
2004-08-08 19:15:31 +00:00
|
|
|
rig_register(&ft757gx2_caps);
|
2007-10-05 04:19:18 +00:00
|
|
|
rig_register(&ft767gx_caps);
|
2001-12-15 03:23:14 +00:00
|
|
|
rig_register(&ft817_caps);
|
2003-03-09 04:43:38 +00:00
|
|
|
rig_register(&ft847_caps);
|
2003-08-11 21:20:35 +00:00
|
|
|
rig_register(&ft857_caps);
|
2004-02-08 17:08:46 +00:00
|
|
|
rig_register(&ft897_caps);
|
2009-01-04 10:40:34 +00:00
|
|
|
rig_register(&ft840_caps);
|
2003-03-09 04:43:38 +00:00
|
|
|
rig_register(&ft890_caps);
|
2003-04-14 03:05:32 +00:00
|
|
|
rig_register(&ft900_caps);
|
2002-10-28 04:53:05 +00:00
|
|
|
rig_register(&ft920_caps);
|
2008-09-22 21:32:38 +00:00
|
|
|
rig_register(&ft950_caps);
|
2003-10-12 18:04:02 +00:00
|
|
|
rig_register(&ft990_caps);
|
2004-08-17 20:07:20 +00:00
|
|
|
rig_register(&ft1000d_caps);
|
2002-11-21 23:09:28 +00:00
|
|
|
rig_register(&ft1000mp_caps);
|
2005-02-26 23:13:48 +00:00
|
|
|
rig_register(&ft1000mpmkv_caps);
|
|
|
|
rig_register(&ft1000mpmkvfld_caps);
|
2008-12-14 20:02:03 +00:00
|
|
|
rig_register(&ft2000_caps);
|
|
|
|
rig_register(&ft9000_caps);
|
2004-08-10 21:10:36 +00:00
|
|
|
rig_register(&frg100_caps);
|
2004-05-16 07:32:57 +00:00
|
|
|
rig_register(&frg8800_caps);
|
2004-08-10 21:10:36 +00:00
|
|
|
rig_register(&frg9600_caps);
|
2005-02-26 23:13:48 +00:00
|
|
|
rig_register(&vr5000_caps);
|
2001-06-04 21:07:17 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-26 23:44:41 +00:00
|
|
|
/*
|
|
|
|
* proberigs_yaesu
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* There's only one rig possible per port.
|
|
|
|
*
|
|
|
|
* rig_model_t probeallrigs_yaesu(port_t *port, rig_probe_func_t cfunc, rig_ptr_t data)
|
|
|
|
*/
|
|
|
|
DECLARE_PROBERIG_BACKEND(yaesu)
|
|
|
|
{
|
2008-11-01 16:38:46 +00:00
|
|
|
unsigned char idbuf[YAESU_CMD_LENGTH+1];
|
2005-02-26 23:44:41 +00:00
|
|
|
static const unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xfa};
|
|
|
|
int id_len=-1, i, id1, id2;
|
|
|
|
int retval=-1;
|
|
|
|
int rates[] = { 4800, 57600, 9600, 38400, 0 }; /* possible baud rates */
|
|
|
|
int rates_idx;
|
|
|
|
|
|
|
|
if (!port)
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
|
|
|
|
if (port->type.rig != RIG_PORT_SERIAL)
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
|
|
|
|
port->write_delay = port->post_write_delay = 20;
|
|
|
|
port->parm.serial.stop_bits = 2;
|
|
|
|
port->retry = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* try for all different baud rates
|
|
|
|
*/
|
|
|
|
for (rates_idx = 0; rates[rates_idx]; rates_idx++) {
|
|
|
|
port->parm.serial.rate = rates[rates_idx];
|
|
|
|
port->timeout = 2*1000/rates[rates_idx] + 50;
|
|
|
|
|
|
|
|
retval = serial_open(port);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
|
|
|
|
/* send READ STATUS cmd to rig */
|
2006-10-07 15:51:38 +00:00
|
|
|
retval = write_block(port, (char *) cmd, YAESU_CMD_LENGTH);
|
|
|
|
id_len = read_block(port, (char *) idbuf, YAESU_CMD_LENGTH);
|
2005-02-26 23:44:41 +00:00
|
|
|
|
|
|
|
close(port->fd);
|
|
|
|
|
|
|
|
if (retval != RIG_OK || id_len < 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retval != RIG_OK || id_len < 0)
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reply should be [Flag1,Flag2,Flag3,ID1,ID2]
|
|
|
|
*/
|
|
|
|
if (id_len != 5 || id_len != 6) {
|
2008-11-01 16:38:46 +00:00
|
|
|
idbuf[YAESU_CMD_LENGTH] = '\0';
|
2005-02-26 23:44:41 +00:00
|
|
|
rig_debug(RIG_DEBUG_WARN,"probe_yaesu: protocol error,"
|
|
|
|
" expected %d, received %d: %s\n", 6, id_len, idbuf);
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
}
|
|
|
|
id1 = idbuf[3];
|
2010-03-05 19:18:10 +00:00
|
|
|
id2 = idbuf[4];
|
2005-02-26 23:44:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
for (i=0; yaesu_id_list[i].model != RIG_MODEL_NONE; i++) {
|
|
|
|
if (id1 == yaesu_id_list[i].id1 && id2 == yaesu_id_list[i].id2) {
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"probe_yaesu: "
|
|
|
|
"found ID %02xH %02xH\n", id1, id2);
|
|
|
|
if (cfunc)
|
|
|
|
(*cfunc)(port, yaesu_id_list[i].model, data);
|
|
|
|
return yaesu_id_list[i].model;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* not found in known table....
|
|
|
|
* update yaesu_id_list[]!
|
|
|
|
*/
|
|
|
|
rig_debug(RIG_DEBUG_WARN,"probe_yaesu: found unknown device "
|
|
|
|
"with ID %02xH %02xH, please report to Hamlib "
|
|
|
|
"developers.\n", id1, id2);
|
|
|
|
|
|
|
|
return RIG_MODEL_NONE;
|
|
|
|
}
|
|
|
|
|