kopia lustrzana https://github.com/Hamlib/Hamlib
Initial release
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@262 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.0
rodzic
399b91c5c0
commit
1c3685eacb
|
@ -0,0 +1,6 @@
|
|||
lib_LTLIBRARIES = libhamlib-aor.la
|
||||
libhamlib_aor_la_SOURCES = ar8200.c aor.c
|
||||
libhamlib_aor_la_LDFLAGS = -avoid-version # -module
|
||||
lib_LIBRARIES = libhamlib-aor.a
|
||||
libhamlib_aor_a_SOURCES = ar8200.c aor.c
|
||||
noinst_HEADERS = aor.h
|
|
@ -0,0 +1,40 @@
|
|||
hamlib - Copyright (C) 2000 Frank Singleton
|
||||
|
||||
libaor.so - Copyright (C) 2000 Stephane Fillod
|
||||
This shared library provides an API for communicating
|
||||
via serial interface to an AOR scanner.
|
||||
|
||||
|
||||
Reference Documentation
|
||||
-----------------------
|
||||
|
||||
AOR RS232 protocol listing for the AR8200 (accompanies the CC8200)
|
||||
Document release V1.3
|
||||
AOR Ltd.
|
||||
|
||||
|
||||
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 an AOR scanner myself.
|
||||
Patchs and contributions are welcome! I'm also looking for
|
||||
a real maintainer :) --SF
|
||||
|
||||
|
||||
This lib should/will support other AOR models.
|
||||
|
||||
Warnings
|
||||
--------
|
||||
|
||||
1. NOTHING IS WORKING, this is a WIP.
|
||||
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* aor.c - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an AOR scanner.
|
||||
*
|
||||
*
|
||||
* $Id: aor.c,v 1.1 2000-11-01 23:23:56 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 "aor.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* acknowledge is CR
|
||||
* Is \r portable enough?
|
||||
*/
|
||||
#define CR '\r'
|
||||
|
||||
/*
|
||||
* modes in use by the "MD" command
|
||||
*/
|
||||
#define MD_WFM '0'
|
||||
#define MD_NFM '1'
|
||||
#define MD_AM '2'
|
||||
#define MD_USB '3'
|
||||
#define MD_LSB '4'
|
||||
#define MD_CW '5'
|
||||
#define MD_SFM '6'
|
||||
#define MD_WAM '7'
|
||||
#define MD_NAM '8'
|
||||
|
||||
|
||||
/*
|
||||
* aor_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 aor_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);
|
||||
write_block(rig_s->fd, "\n", 1, 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++] != CR);
|
||||
|
||||
*data_len = i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_close
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int aor_close(RIG *rig)
|
||||
{
|
||||
unsigned char ackbuf[16];
|
||||
int ack_len;
|
||||
|
||||
/* terminate remote operation via the RS-232 */
|
||||
|
||||
aor_transaction (rig, "EX", 2, ackbuf, &ack_len);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* aor_set_freq
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int aor_set_freq(RIG *rig, freq_t freq)
|
||||
{
|
||||
unsigned char freqbuf[16], ackbuf[16];
|
||||
int freq_len,ack_len;
|
||||
|
||||
/*
|
||||
* actually, frequency must be like nnnnnnnnm0,
|
||||
* where m must be 0 or 5 (for 50Hz).
|
||||
*/
|
||||
freq_len = sprintf(freqbuf,"RF%010Ld", freq);
|
||||
|
||||
aor_transaction (rig, freqbuf, freq_len, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 1 || ackbuf[0] != CR) {
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_set_freq: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_get_freq
|
||||
* Assumes rig!=NULL, freq!=NULL
|
||||
*/
|
||||
int aor_get_freq(RIG *rig, freq_t *freq)
|
||||
{
|
||||
unsigned char freqbuf[16];
|
||||
char *rfp;
|
||||
int freq_len;
|
||||
|
||||
aor_transaction (rig, "RX", 2, freqbuf, &freq_len);
|
||||
|
||||
rfp = strstr(freqbuf, "RF");
|
||||
sscanf(rfp+2,"%Ld", freq);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_set_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int aor_set_mode(RIG *rig, rmode_t mode)
|
||||
{
|
||||
unsigned char mdbuf[16],ackbuf[16];
|
||||
int mdbuf_len,ack_len,aormode;
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_AM: aormode = MD_AM; break;
|
||||
case RIG_MODE_CW: aormode = MD_CW; break;
|
||||
case RIG_MODE_USB: aormode = MD_USB; break;
|
||||
case RIG_MODE_LSB: aormode = MD_LSB; break;
|
||||
case RIG_MODE_FM: aormode = MD_NFM; break;
|
||||
case RIG_MODE_RTTY:
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_set_mode: unsupported mode %d\n",
|
||||
mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mdbuf_len = sprintf(mdbuf, "MD%c", aormode);
|
||||
aor_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 1 || ackbuf[0] != CR) {
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_set_mode: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_get_mode
|
||||
* Assumes rig!=NULL, mode!=NULL
|
||||
*/
|
||||
int aor_get_mode(RIG *rig, rmode_t *mode)
|
||||
{
|
||||
unsigned char ackbuf[16];
|
||||
int ack_len;
|
||||
|
||||
|
||||
aor_transaction (rig, "MD", 2, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 2 || ackbuf[1] != CR) {
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_get_mode: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
switch (ackbuf[0]) {
|
||||
case MD_AM: *mode = RIG_MODE_AM; break;
|
||||
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_NFM: *mode = RIG_MODE_FM; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_get_mode: unsupported mode %d\n",
|
||||
ackbuf[0]);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_set_ts
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int aor_set_ts(RIG *rig, unsigned long ts)
|
||||
{
|
||||
unsigned char tsbuf[16],ackbuf[16];
|
||||
int ts_len, ack_len;
|
||||
|
||||
/*
|
||||
* actually, tuning step must be like nnnnm0,
|
||||
* where m must be 0 or 5 (for 50Hz).
|
||||
*/
|
||||
ts_len = sprintf(tsbuf,"ST%06ld", ts);
|
||||
|
||||
aor_transaction (rig, tsbuf, ts_len, ackbuf, &ack_len);
|
||||
|
||||
if (ack_len != 1 || ackbuf[0] != CR) {
|
||||
rig_debug(RIG_DEBUG_ERR,"aor_set_ts: ack NG, len=%d\n",
|
||||
ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* aor_set_poweroff
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
*/
|
||||
int aor_set_poweroff(RIG *rig)
|
||||
{
|
||||
unsigned char ackbuf[16];
|
||||
int ack_len;
|
||||
|
||||
/* turn off power */
|
||||
|
||||
aor_transaction (rig, "QP", 2, ackbuf, &ack_len);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* init_aor is called by rig_backend_load
|
||||
*/
|
||||
int init_aor(void *be_handle)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "aor: _init called\n");
|
||||
|
||||
rig_register(&ar8200_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* aor.h - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an AOR scanner.
|
||||
*
|
||||
*
|
||||
* $Id: aor.h,v 1.1 2000-11-01 23:23:56 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 _AOR_H
|
||||
#define _AOR_H 1
|
||||
|
||||
|
||||
int aor_close(RIG *rig);
|
||||
|
||||
int aor_set_freq(RIG *rig, freq_t freq);
|
||||
int aor_get_freq(RIG *rig, freq_t *freq);
|
||||
int aor_set_mode(RIG *rig, rmode_t mode);
|
||||
int aor_get_mode(RIG *rig, rmode_t *mode);
|
||||
|
||||
int aor_set_ts(RIG *rig, unsigned long ts);
|
||||
int aor_set_poweroff(RIG *rig);
|
||||
|
||||
extern const struct rig_caps ar8200_caps;
|
||||
|
||||
extern int init_aor(void *be_handle);
|
||||
|
||||
|
||||
#endif /* _AOR_H */
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ar8200.c - Copyright (C) 2000 Stephane Fillod
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to a AOR-AR8200 handheld scanner radio
|
||||
* using the serial interface.
|
||||
*
|
||||
*
|
||||
* $Id: ar8200.c,v 1.1 2000-11-01 23:23:56 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 "aor.h"
|
||||
|
||||
|
||||
#define AR8200_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_FM)
|
||||
|
||||
#define AR8200_FUNC_ALL (RIG_FUNC_TSQL)
|
||||
|
||||
#define AR8200_LEVEL_ALL (RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_SQL|RIG_LEVEL_SQLSTAT|RIG_LEVEL_STRENGTH)
|
||||
|
||||
/*
|
||||
* ar8200 rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
* Also this struct is READONLY!
|
||||
*/
|
||||
const struct rig_caps ar8200_caps = {
|
||||
RIG_MODEL_AR8200, "AR8200", "AOR", "0.1", RIG_STATUS_UNTESTED,
|
||||
RIG_TYPE_SCANNER, RIG_PTT_NONE, 9600, 19200, 8, 2, RIG_PARITY_NONE,
|
||||
RIG_HANDSHAKE_XONXOFF, 0, 0, 2000, 3, AR8200_FUNC_ALL, AR8200_LEVEL_ALL,
|
||||
AR8200_LEVEL_ALL, 1000, RIG_TRN_ON,
|
||||
{
|
||||
{KHz(100),MHz(2040),AR8200_ALL_MODES,-1,-1},
|
||||
{0,0,0,0,0},
|
||||
}, /* rx range */
|
||||
{ {0,0,0,0,0} }, /* no tx range, this is a scanner! */
|
||||
{
|
||||
{AR8200_ALL_MODES,50},
|
||||
{AR8200_ALL_MODES,100},
|
||||
{AR8200_ALL_MODES,KHz(1)},
|
||||
{AR8200_ALL_MODES,KHz(5)},
|
||||
{AR8200_ALL_MODES,KHz(9)},
|
||||
{AR8200_ALL_MODES,KHz(10)},
|
||||
{AR8200_ALL_MODES,12500},
|
||||
{AR8200_ALL_MODES,KHz(20)},
|
||||
{AR8200_ALL_MODES,KHz(25)},
|
||||
{AR8200_ALL_MODES,KHz(100)},
|
||||
{AR8200_ALL_MODES,MHz(1)},
|
||||
{AR8200_ALL_MODES,0}, /* any tuning step */
|
||||
{0,0}
|
||||
},
|
||||
NULL, NULL, NULL, aor_close, NULL /* probe not supported yet */,
|
||||
aor_set_freq, aor_get_freq, aor_set_mode, aor_get_mode, NULL,
|
||||
set_ts: aor_set_ts,
|
||||
set_poweroff: aor_set_poweroff,
|
||||
};
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,418 @@
|
|||
/*
|
||||
* rigmatric.c - Copyright (C) 2000 Stephane Fillod
|
||||
* This program generates the supported rig matrix in HTML format.
|
||||
*
|
||||
*
|
||||
* $Id: rigmatrix.c,v 1.1 2000-11-01 23:25:54 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <gd.h>
|
||||
#include <gdfontg.h>
|
||||
#include <gdfonts.h>
|
||||
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
|
||||
int create_png_range(const freq_range_t rx_range_list[], const freq_range_t tx_range_list[], int num);
|
||||
|
||||
int print_caps_sum(const struct rig_caps *caps, void *data)
|
||||
{
|
||||
|
||||
printf("<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD><TD>",
|
||||
caps->model_name,caps->mfg_name,caps->version
|
||||
);
|
||||
|
||||
switch (caps->status) {
|
||||
case RIG_STATUS_ALPHA:
|
||||
printf("Alpha");
|
||||
break;
|
||||
case RIG_STATUS_UNTESTED:
|
||||
printf("Untested");
|
||||
break;
|
||||
case RIG_STATUS_BETA:
|
||||
printf("Beta");
|
||||
break;
|
||||
case RIG_STATUS_STABLE:
|
||||
printf("Stable");
|
||||
break;
|
||||
case RIG_STATUS_BUGGY:
|
||||
printf("Buggy");
|
||||
break;
|
||||
case RIG_STATUS_NEW:
|
||||
printf("New");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown");
|
||||
}
|
||||
printf("</TD><TD>");
|
||||
|
||||
switch (caps->rig_type) {
|
||||
case RIG_TYPE_TRANSCEIVER:
|
||||
printf("Transceiver");
|
||||
break;
|
||||
case RIG_TYPE_HANDHELD:
|
||||
printf("Handheld");
|
||||
break;
|
||||
case RIG_TYPE_MOBILE:
|
||||
printf("Mobile");
|
||||
break;
|
||||
case RIG_TYPE_RECEIVER:
|
||||
printf("Receiver");
|
||||
break;
|
||||
case RIG_TYPE_SCANNER:
|
||||
printf("Scanner");
|
||||
break;
|
||||
case RIG_TYPE_COMPUTER:
|
||||
printf("Computer");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown");
|
||||
}
|
||||
printf("</TD><TD><A HREF=\"#rng%d\">range</A></TD>"
|
||||
"<TD><A HREF=\"#parms%d\">parms</A></TD>"
|
||||
"<TD><A HREF=\"#caps%d\">caps</A></TD></TR>\n",
|
||||
caps->rig_model, caps->rig_model, caps->rig_model);
|
||||
|
||||
return 1; /* !=0, we want them all ! */
|
||||
}
|
||||
|
||||
int print_caps_parms(const struct rig_caps *caps, void *data)
|
||||
{
|
||||
printf("<A NAME=\"parms%d\"><TR><TD>%s</TD><TD>",
|
||||
caps->rig_model,
|
||||
caps->model_name);
|
||||
|
||||
switch (caps->ptt_type) {
|
||||
case RIG_PTT_RIG:
|
||||
printf("rig");
|
||||
break;
|
||||
case RIG_PTT_PARALLEL:
|
||||
printf("parallel");
|
||||
break;
|
||||
case RIG_PTT_SERIAL:
|
||||
printf("serial");
|
||||
break;
|
||||
case RIG_PTT_NONE:
|
||||
printf("None");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown");
|
||||
}
|
||||
|
||||
printf("</TD><TD>%d</TD><TD>%d</TD><TD>%d%c%d</TD><TD>%s</TD>",
|
||||
caps->serial_rate_min, caps->serial_rate_max,
|
||||
caps->serial_data_bits,
|
||||
caps->serial_parity==RIG_PARITY_NONE?'N':
|
||||
(caps->serial_parity==RIG_PARITY_ODD?'O':'E'),
|
||||
caps->serial_stop_bits,
|
||||
caps->serial_handshake==RIG_HANDSHAKE_NONE?"none":
|
||||
(caps->serial_handshake==RIG_HANDSHAKE_XONXOFF?"XONXOFF":"CTS/RTS")
|
||||
);
|
||||
|
||||
printf("<TD>%dms</TD><TD>%dms</TD><TD>%dms</TD><TD>%d</TD></TR></A>\n",
|
||||
caps->write_delay, caps->post_write_delay,
|
||||
caps->timeout, caps->retry);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int print_caps_caps(const struct rig_caps *caps, void *data)
|
||||
{
|
||||
printf("<A NAME=\"caps%d\"><TR><TD>%s</TD>",
|
||||
caps->rig_model,
|
||||
caps->model_name);
|
||||
|
||||
#define print_yn(fn) printf("<TD>%c</TD>", (fn) ? 'Y':'N')
|
||||
|
||||
print_yn(caps->set_freq);
|
||||
print_yn(caps->get_freq);
|
||||
print_yn(caps->set_mode);
|
||||
print_yn(caps->get_mode);
|
||||
print_yn(caps->set_vfo);
|
||||
print_yn(caps->get_vfo);
|
||||
print_yn(caps->set_ptt);
|
||||
print_yn(caps->get_ptt);
|
||||
print_yn(caps->set_rptr_shift);
|
||||
print_yn(caps->get_rptr_shift);
|
||||
print_yn(caps->set_rptr_offs);
|
||||
print_yn(caps->get_rptr_offs);
|
||||
print_yn(caps->set_split_freq);
|
||||
print_yn(caps->get_split_freq);
|
||||
print_yn(caps->set_split);
|
||||
print_yn(caps->get_split);
|
||||
print_yn(caps->set_ts);
|
||||
print_yn(caps->get_ts);
|
||||
print_yn(caps->set_ctcss);
|
||||
print_yn(caps->get_ctcss);
|
||||
print_yn(caps->set_dcs);
|
||||
print_yn(caps->get_dcs);
|
||||
print_yn(caps->set_poweron);
|
||||
print_yn(caps->set_poweroff);
|
||||
print_yn(caps->set_trn);
|
||||
print_yn(caps->set_trn);
|
||||
print_yn(caps->decode_event);
|
||||
|
||||
printf("</TR></A>\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int print_caps_range(const struct rig_caps *caps, void *data)
|
||||
{
|
||||
create_png_range(caps->rx_range_list, caps->tx_range_list, caps->rig_model);
|
||||
|
||||
printf("<A NAME=\"rng%d\"><TR><TD>%s</TD>"
|
||||
"<TD><IMG SRC=\"range%d.png\"></TD></TR></A>",
|
||||
caps->rig_model,
|
||||
caps->model_name,
|
||||
caps->rig_model);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define RANGE_WIDTH 600
|
||||
#define RANGE_HEIGHT 16
|
||||
#define RANGE_MIDHEIGHT (RANGE_HEIGHT/2)
|
||||
|
||||
#define RX_R 0
|
||||
#define RX_G 255
|
||||
#define RX_B 255
|
||||
#define TX_R 0
|
||||
#define TX_G 0
|
||||
#define TX_B 255
|
||||
|
||||
#define HF_H 10
|
||||
#define VHF_H 30
|
||||
#define UHF_H 50
|
||||
#define IM_LGD 21
|
||||
|
||||
static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h1, int h2, int rgb)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<FRQRANGESIZ; i++) {
|
||||
float start_pix, end_pix;
|
||||
|
||||
if (range_list[i].start == 0 && range_list[i].end == 0)
|
||||
break;
|
||||
|
||||
start_pix = range_list[i].start;
|
||||
end_pix = range_list[i].end;
|
||||
|
||||
/*
|
||||
* HF
|
||||
*/
|
||||
if (range_list[i].start < MHz(30)) {
|
||||
start_pix = start_pix / MHz(30) * RANGE_WIDTH;
|
||||
end_pix = end_pix / MHz(30) * RANGE_WIDTH;
|
||||
if (end_pix >= RANGE_WIDTH)
|
||||
end_pix = RANGE_WIDTH-1;
|
||||
|
||||
start_pix += IM_LGD;
|
||||
end_pix += IM_LGD;
|
||||
gdImageFilledRectangle(im_rng, start_pix, HF_H+h1, end_pix, HF_H+h2, rgb);
|
||||
}
|
||||
|
||||
/*
|
||||
* VHF
|
||||
*/
|
||||
start_pix = range_list[i].start;
|
||||
end_pix = range_list[i].end;
|
||||
if ((range_list[i].start > MHz(30) && range_list[i].start < MHz(300))
|
||||
|| (range_list[i].start < MHz(30) && range_list[i].end > MHz(30))) {
|
||||
start_pix = (start_pix-MHz(30)) / MHz(300) * RANGE_WIDTH;
|
||||
end_pix = (end_pix-MHz(30)) / MHz(300) * RANGE_WIDTH;
|
||||
if (start_pix < 0)
|
||||
start_pix = 0;
|
||||
if (end_pix >= RANGE_WIDTH)
|
||||
end_pix = RANGE_WIDTH-1;
|
||||
|
||||
start_pix += IM_LGD;
|
||||
end_pix += IM_LGD;
|
||||
gdImageFilledRectangle(im_rng, start_pix, VHF_H+h1, end_pix, VHF_H+h2, rgb);
|
||||
}
|
||||
|
||||
/*
|
||||
* UHF
|
||||
*/
|
||||
start_pix = range_list[i].start;
|
||||
end_pix = range_list[i].end;
|
||||
if ((range_list[i].start > MHz(300) && range_list[i].start < GHz(3))
|
||||
|| (range_list[i].start < MHz(300) && range_list[i].end > MHz(300))) {
|
||||
start_pix = (start_pix-MHz(300)) / GHz(3) * RANGE_WIDTH;
|
||||
end_pix = (end_pix-MHz(300)) / GHz(3) * RANGE_WIDTH;
|
||||
if (start_pix < 0)
|
||||
start_pix = 0;
|
||||
if (end_pix >= RANGE_WIDTH)
|
||||
end_pix = RANGE_WIDTH-1;
|
||||
|
||||
start_pix += IM_LGD;
|
||||
end_pix += IM_LGD;
|
||||
gdImageFilledRectangle(im_rng, start_pix, UHF_H+h1, end_pix, UHF_H+h2, rgb);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int create_png_range(const freq_range_t rx_range_list[],
|
||||
const freq_range_t tx_range_list[], int num)
|
||||
{
|
||||
FILE *out;
|
||||
|
||||
/* Input and output images */
|
||||
gdImagePtr im_rng;
|
||||
char rng_fname[128];
|
||||
|
||||
/* Color indexes */
|
||||
int white, black;
|
||||
int rx_rgb,tx_rgb;
|
||||
|
||||
/* Create output image, x by y pixels. */
|
||||
im_rng = gdImageCreate(RANGE_WIDTH+IM_LGD, UHF_H+RANGE_HEIGHT);
|
||||
|
||||
/* First color allocated is background. */
|
||||
white = gdImageColorAllocate(im_rng, 255, 255, 255);
|
||||
black = gdImageColorAllocate(im_rng, 0, 0, 0);
|
||||
|
||||
#if 0
|
||||
/* Set transparent color. */
|
||||
gdImageColorTransparent(im_rng, white);
|
||||
#endif
|
||||
|
||||
/* Try to load demoin.png and paste part of it into the
|
||||
output image. */
|
||||
|
||||
tx_rgb = gdImageColorAllocate(im_rng, TX_R, TX_G, TX_B);
|
||||
rx_rgb = gdImageColorAllocate(im_rng, RX_R, RX_G, RX_B);
|
||||
|
||||
draw_range(rx_range_list, im_rng, 0, RANGE_MIDHEIGHT-1, rx_rgb);
|
||||
draw_range(tx_range_list, im_rng, RANGE_MIDHEIGHT, RANGE_HEIGHT-1, tx_rgb);
|
||||
|
||||
gdImageRectangle(im_rng, IM_LGD, HF_H, IM_LGD+RANGE_WIDTH-1, HF_H+RANGE_HEIGHT-1, black);
|
||||
gdImageRectangle(im_rng, IM_LGD, VHF_H, IM_LGD+RANGE_WIDTH-1, VHF_H+RANGE_HEIGHT-1, black);
|
||||
gdImageRectangle(im_rng, IM_LGD, UHF_H, IM_LGD+RANGE_WIDTH-1, UHF_H+RANGE_HEIGHT-1, black);
|
||||
|
||||
/* gdImageStringUp */
|
||||
gdImageString(im_rng, gdFontSmall, 1, HF_H+1,
|
||||
(unsigned char *) "HF", black);
|
||||
gdImageString(im_rng, gdFontSmall, 1, VHF_H+1,
|
||||
(unsigned char *) "VHF", black);
|
||||
gdImageString(im_rng, gdFontSmall, 1, UHF_H+1,
|
||||
(unsigned char *) "UHF", black);
|
||||
|
||||
/* Make output image interlaced (allows "fade in" in some viewers,
|
||||
and in the latest web browsers) */
|
||||
gdImageInterlace(im_rng, 1);
|
||||
|
||||
sprintf(rng_fname, "range%d.png", num);
|
||||
out = fopen(rng_fname, "wb");
|
||||
/* Write PNG */
|
||||
gdImagePng(im_rng, out);
|
||||
fclose(out);
|
||||
gdImageDestroy(im_rng);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int status;
|
||||
time_t gentime;
|
||||
|
||||
status = rig_load_backend("icom");
|
||||
if (status != RIG_OK ) {
|
||||
printf("rig_load_backend: error = %s \n", rigerror(status));
|
||||
exit(3);
|
||||
}
|
||||
status = rig_load_backend("ft747");
|
||||
if (status != RIG_OK ) {
|
||||
printf("rig_load_backend: ft747 error = %s \n", rigerror(status));
|
||||
exit(3);
|
||||
}
|
||||
status = rig_load_backend("ft847");
|
||||
if (status != RIG_OK ) {
|
||||
printf("rig_load_backend: ft847 error = %s \n", rigerror(status));
|
||||
exit(3);
|
||||
}
|
||||
status = rig_load_backend("aor");
|
||||
if (status != RIG_OK ) {
|
||||
printf("rig_load_backend: aor error = %s \n", rigerror(status));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
printf("<TABLE BORDER=1>");
|
||||
printf("<TR><TD>Model</TD><TD>Mfg</TD><TD>Vers.</TD><TD>Status</TD>"
|
||||
"<TD>Type</TD><TD>Freq. range</TD><TD>Parameters</TD>"
|
||||
"<TD>Capabilities</TD></TR>\n");
|
||||
status = rig_list_foreach(print_caps_sum,NULL);
|
||||
printf("</TABLE>\n");
|
||||
|
||||
printf("<P>");
|
||||
|
||||
printf("<TABLE BORDER=1>\n");
|
||||
printf("<TR><TD>Model</TD><TD>PTT</TD><TD>Speed min</TD><TD>Speed max</TD>"
|
||||
"<TD>Parm.</TD><TD>Handshake</TD><TD>Write delay</TD>"
|
||||
"<TD>Post delay</TD><TD>Timeout</TD><TD>Retry</TD></TR>\n");
|
||||
status = rig_list_foreach(print_caps_parms,NULL);
|
||||
printf("</TABLE>\n");
|
||||
|
||||
printf("<P>");
|
||||
|
||||
printf("<TABLE BORDER=1>\n");
|
||||
printf("<TR><TD>Model</TD><TD>Freq. range</TD></TR>\n");
|
||||
status = rig_list_foreach(print_caps_range,NULL);
|
||||
printf("</TABLE>\n");
|
||||
|
||||
printf("<P>");
|
||||
|
||||
printf("<TABLE BORDER=1>\n");
|
||||
printf("<TR><TD>Model</TD><TD>Set freq</TD><TD>Get freq</TD>"
|
||||
"<TD>Set mode</TD><TD>Get mode</TD>"
|
||||
"<TD>Set VFO</TD><TD>Get VFO</TD>"
|
||||
"<TD>Set PTT</TD><TD>Get PTT</TD>"
|
||||
"<TD>Set rptr shift</TD><TD>Get rptr shift</TD>"
|
||||
"<TD>Set rptr offs</TD><TD>Get rptr offs</TD>"
|
||||
"<TD>Set split f.</TD><TD>Get split f.</TD>"
|
||||
"<TD>Set split</TD><TD>Get split</TD>"
|
||||
"<TD>Set ts</TD><TD>Get ts</TD>"
|
||||
"<TD>Set CTCSS</TD><TD>Get CTCSS</TD>"
|
||||
"<TD>Set DCS</TD><TD>Get DCS</TD>"
|
||||
"<TD>Set PowerON</TD><TD>Set PowerOFF</TD>"
|
||||
"<TD>Set trn</TD><TD>Get trn</TD>"
|
||||
"<TD>Decode</TD>"
|
||||
"</TR>\n");
|
||||
status = rig_list_foreach(print_caps_caps,NULL);
|
||||
printf("</TABLE>\n");
|
||||
|
||||
|
||||
printf("<P>");
|
||||
|
||||
time(&gentime);
|
||||
printf("Rigmatrix generated %s by %s\n",ctime(&gentime), getenv("USER"));
|
||||
|
||||
printf("</body></html>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Ładowanie…
Reference in New Issue