kopia lustrzana https://github.com/Hamlib/Hamlib
rodzic
80a4097aba
commit
d489b8bcb5
527
tests/dumpcaps.c
527
tests/dumpcaps.c
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -38,10 +38,11 @@ int range_sanity_check(const struct freq_range_list range_list[], int rx);
|
||||||
int ts_sanity_check(const struct tuning_step_list tuning_step[]);
|
int ts_sanity_check(const struct tuning_step_list tuning_step[]);
|
||||||
static void dump_chan_caps(const channel_cap_t *chan, FILE *fout);
|
static void dump_chan_caps(const channel_cap_t *chan, FILE *fout);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the rig may be in rig_init state, but not openned
|
* the rig may be in rig_init state, but not openned
|
||||||
*/
|
*/
|
||||||
int dumpcaps (RIG* rig, FILE *fout)
|
int dumpcaps(RIG *rig, FILE *fout)
|
||||||
{
|
{
|
||||||
const struct rig_caps *caps;
|
const struct rig_caps *caps;
|
||||||
int status, i;
|
int status, i;
|
||||||
|
@ -50,8 +51,9 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
int backend_warnings = 0;
|
int backend_warnings = 0;
|
||||||
static char prntbuf[1024]; /* a malloc would be better.. */
|
static char prntbuf[1024]; /* a malloc would be better.. */
|
||||||
|
|
||||||
if (!rig || !rig->caps)
|
if (!rig || !rig->caps) {
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
caps = rig->caps;
|
caps = rig->caps;
|
||||||
|
|
||||||
|
@ -62,99 +64,128 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Backend copyright:\t%s\n", caps->copyright);
|
fprintf(fout, "Backend copyright:\t%s\n", caps->copyright);
|
||||||
fprintf(fout, "Backend status:\t%s\n", rig_strstatus(caps->status));
|
fprintf(fout, "Backend status:\t%s\n", rig_strstatus(caps->status));
|
||||||
fprintf(fout, "Rig type:\t");
|
fprintf(fout, "Rig type:\t");
|
||||||
|
|
||||||
switch (caps->rig_type & RIG_TYPE_MASK) {
|
switch (caps->rig_type & RIG_TYPE_MASK) {
|
||||||
case RIG_TYPE_TRANSCEIVER:
|
case RIG_TYPE_TRANSCEIVER:
|
||||||
fprintf(fout, "Transceiver\n");
|
fprintf(fout, "Transceiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_HANDHELD:
|
case RIG_TYPE_HANDHELD:
|
||||||
fprintf(fout, "Handheld\n");
|
fprintf(fout, "Handheld\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_MOBILE:
|
case RIG_TYPE_MOBILE:
|
||||||
fprintf(fout, "Mobile\n");
|
fprintf(fout, "Mobile\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_RECEIVER:
|
case RIG_TYPE_RECEIVER:
|
||||||
fprintf(fout, "Receiver\n");
|
fprintf(fout, "Receiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_PCRECEIVER:
|
case RIG_TYPE_PCRECEIVER:
|
||||||
fprintf(fout, "PC Receiver\n");
|
fprintf(fout, "PC Receiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_SCANNER:
|
case RIG_TYPE_SCANNER:
|
||||||
fprintf(fout, "Scanner\n");
|
fprintf(fout, "Scanner\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_TRUNKSCANNER:
|
case RIG_TYPE_TRUNKSCANNER:
|
||||||
fprintf(fout, "Trunking scanner\n");
|
fprintf(fout, "Trunking scanner\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_COMPUTER:
|
case RIG_TYPE_COMPUTER:
|
||||||
fprintf(fout, "Computer\n");
|
fprintf(fout, "Computer\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_TUNER:
|
case RIG_TYPE_TUNER:
|
||||||
fprintf(fout, "Tuner\n");
|
fprintf(fout, "Tuner\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_OTHER:
|
case RIG_TYPE_OTHER:
|
||||||
fprintf(fout, "Other\n");
|
fprintf(fout, "Other\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "PTT type:\t");
|
fprintf(fout, "PTT type:\t");
|
||||||
|
|
||||||
switch (caps->ptt_type) {
|
switch (caps->ptt_type) {
|
||||||
case RIG_PTT_RIG:
|
case RIG_PTT_RIG:
|
||||||
fprintf(fout, "Rig capable\n");
|
fprintf(fout, "Rig capable\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_RIG_MICDATA:
|
case RIG_PTT_RIG_MICDATA:
|
||||||
fprintf(fout, "Rig capable (Mic/Data)\n");
|
fprintf(fout, "Rig capable (Mic/Data)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_PARALLEL:
|
case RIG_PTT_PARALLEL:
|
||||||
fprintf(fout, "Parallel port (DATA0)\n");
|
fprintf(fout, "Parallel port (DATA0)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_RTS:
|
case RIG_PTT_SERIAL_RTS:
|
||||||
fprintf(fout, "Serial port (CTS/RTS)\n");
|
fprintf(fout, "Serial port (CTS/RTS)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_DTR:
|
case RIG_PTT_SERIAL_DTR:
|
||||||
fprintf(fout, "Serial port (DTR/DSR)\n");
|
fprintf(fout, "Serial port (DTR/DSR)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_NONE:
|
case RIG_PTT_NONE:
|
||||||
fprintf(fout, "None\n");
|
fprintf(fout, "None\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "DCD type:\t");
|
fprintf(fout, "DCD type:\t");
|
||||||
|
|
||||||
switch (caps->dcd_type) {
|
switch (caps->dcd_type) {
|
||||||
case RIG_DCD_RIG:
|
case RIG_DCD_RIG:
|
||||||
fprintf(fout, "Rig capable\n");
|
fprintf(fout, "Rig capable\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_PARALLEL:
|
case RIG_DCD_PARALLEL:
|
||||||
fprintf(fout, "Parallel port (/STROBE)\n");
|
fprintf(fout, "Parallel port (/STROBE)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_SERIAL_CTS:
|
case RIG_DCD_SERIAL_CTS:
|
||||||
fprintf(fout, "Serial port (CTS/RTS)\n");
|
fprintf(fout, "Serial port (CTS/RTS)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_SERIAL_DSR:
|
case RIG_DCD_SERIAL_DSR:
|
||||||
fprintf(fout, "Serial port (DTR/DSR)\n");
|
fprintf(fout, "Serial port (DTR/DSR)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_SERIAL_CAR:
|
case RIG_DCD_SERIAL_CAR:
|
||||||
fprintf(fout, "Serial port (CD)\n");
|
fprintf(fout, "Serial port (CD)\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_NONE:
|
case RIG_DCD_NONE:
|
||||||
fprintf(fout, "None\n");
|
fprintf(fout, "None\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Port type:\t");
|
fprintf(fout, "Port type:\t");
|
||||||
|
|
||||||
switch (caps->port_type) {
|
switch (caps->port_type) {
|
||||||
case RIG_PORT_SERIAL:
|
case RIG_PORT_SERIAL:
|
||||||
fprintf(fout, "RS-232\n");
|
fprintf(fout, "RS-232\n");
|
||||||
fprintf(fout, "Serial speed: %d..%d bauds, %d%c%d %s\n", caps->serial_rate_min,
|
fprintf(fout,
|
||||||
caps->serial_rate_max, caps->serial_data_bits,
|
"Serial speed: %d..%d bauds, %d%c%d %s\n",
|
||||||
caps->serial_parity == RIG_PARITY_NONE ? 'N':
|
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' :
|
caps->serial_parity == RIG_PARITY_ODD ? 'O' :
|
||||||
caps->serial_parity == RIG_PARITY_EVEN ? 'E' :
|
caps->serial_parity == RIG_PARITY_EVEN ? 'E' :
|
||||||
caps->serial_parity == RIG_PARITY_MARK ? 'M' : 'S',
|
caps->serial_parity == RIG_PARITY_MARK ? 'M' : 'S',
|
||||||
|
@ -163,84 +194,118 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
(caps->serial_handshake == RIG_HANDSHAKE_XONXOFF ? "XONXOFF" : "CTS/RTS")
|
(caps->serial_handshake == RIG_HANDSHAKE_XONXOFF ? "XONXOFF" : "CTS/RTS")
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_PARALLEL:
|
case RIG_PORT_PARALLEL:
|
||||||
fprintf(fout, "Parallel\n");
|
fprintf(fout, "Parallel\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_DEVICE:
|
case RIG_PORT_DEVICE:
|
||||||
fprintf(fout, "Device driver\n");
|
fprintf(fout, "Device driver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_USB:
|
case RIG_PORT_USB:
|
||||||
fprintf(fout, "USB\n");
|
fprintf(fout, "USB\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NETWORK:
|
case RIG_PORT_NETWORK:
|
||||||
fprintf(fout, "Network link\n");
|
fprintf(fout, "Network link\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_UDP_NETWORK:
|
case RIG_PORT_UDP_NETWORK:
|
||||||
fprintf(fout, "UDP Network link\n");
|
fprintf(fout, "UDP Network link\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NONE:
|
case RIG_PORT_NONE:
|
||||||
fprintf(fout, "None\n");
|
fprintf(fout, "None\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Write delay: %dms, timeout %dms, %d retry\n",
|
fprintf(fout,
|
||||||
|
"Write delay: %dmS, timeout %dmS, %d retry\n",
|
||||||
caps->write_delay, caps->timeout, caps->retry);
|
caps->write_delay, caps->timeout, caps->retry);
|
||||||
fprintf(fout, "Post Write delay: %dms\n",
|
fprintf(fout,
|
||||||
|
"Post Write delay: %dmS\n",
|
||||||
caps->post_write_delay);
|
caps->post_write_delay);
|
||||||
|
|
||||||
fprintf(fout, "Has targetable VFO: %s\n",
|
fprintf(fout,
|
||||||
|
"Has targetable VFO: %s\n",
|
||||||
caps->targetable_vfo ? "Y" : "N");
|
caps->targetable_vfo ? "Y" : "N");
|
||||||
|
|
||||||
fprintf(fout, "Has transceive: %s\n",
|
fprintf(fout,
|
||||||
|
"Has transceive: %s\n",
|
||||||
caps->transceive ? "Y" : "N");
|
caps->transceive ? "Y" : "N");
|
||||||
|
|
||||||
fprintf(fout, "Announce: 0x%x\n", caps->announces);
|
fprintf(fout, "Announce: 0x%x\n", caps->announces);
|
||||||
fprintf(fout, "Max RIT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
fprintf(fout,
|
||||||
|
"Max RIT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
||||||
caps->max_rit / 1000, caps->max_rit % 1000,
|
caps->max_rit / 1000, caps->max_rit % 1000,
|
||||||
caps->max_rit / 1000, caps->max_rit % 1000);
|
caps->max_rit / 1000, caps->max_rit % 1000);
|
||||||
|
|
||||||
fprintf(fout, "Max XIT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
fprintf(fout,
|
||||||
|
"Max XIT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
||||||
caps->max_xit / 1000, caps->max_xit % 1000,
|
caps->max_xit / 1000, caps->max_xit % 1000,
|
||||||
caps->max_xit / 1000, caps->max_xit % 1000);
|
caps->max_xit / 1000, caps->max_xit % 1000);
|
||||||
|
|
||||||
fprintf(fout, "Max IF-SHIFT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
fprintf(fout,
|
||||||
|
"Max IF-SHIFT: -%ld.%ldkHz/+%ld.%ldkHz\n",
|
||||||
caps->max_ifshift / 1000, caps->max_ifshift % 1000,
|
caps->max_ifshift / 1000, caps->max_ifshift % 1000,
|
||||||
caps->max_ifshift / 1000, caps->max_ifshift % 1000);
|
caps->max_ifshift / 1000, caps->max_ifshift % 1000);
|
||||||
|
|
||||||
fprintf(fout, "Preamp:");
|
fprintf(fout, "Preamp:");
|
||||||
for(i = 0; i < MAXDBLSTSIZ && caps->preamp[i] != 0; i++)
|
|
||||||
|
for (i = 0; i < MAXDBLSTSIZ && caps->preamp[i] != 0; i++) {
|
||||||
fprintf(fout, " %ddB", caps->preamp[i]);
|
fprintf(fout, " %ddB", caps->preamp[i]);
|
||||||
if (i == 0)
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
fprintf(fout, " None");
|
fprintf(fout, " None");
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
fprintf(fout, "Attenuator:");
|
fprintf(fout, "Attenuator:");
|
||||||
for(i = 0; i < MAXDBLSTSIZ && caps->attenuator[i] != 0; i++)
|
|
||||||
fprintf(fout, " %ddB",caps->attenuator[i]);
|
for (i = 0; i < MAXDBLSTSIZ && caps->attenuator[i] != 0; i++) {
|
||||||
if (i == 0)
|
fprintf(fout, " %ddB", caps->attenuator[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
fprintf(fout, " None");
|
fprintf(fout, " None");
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
fprintf(fout, "CTCSS:");
|
fprintf(fout, "CTCSS:");
|
||||||
for(i = 0; caps->ctcss_list && i < 60 && caps->ctcss_list[i] != 0; i++) {
|
|
||||||
fprintf(fout, " %d.%1d", caps->ctcss_list[i] / 10, caps->ctcss_list[i] % 10);
|
for (i = 0; caps->ctcss_list && i < 60 && caps->ctcss_list[i] != 0; i++) {
|
||||||
|
fprintf(fout,
|
||||||
|
" %d.%1d",
|
||||||
|
caps->ctcss_list[i] / 10, caps->ctcss_list[i] % 10);
|
||||||
}
|
}
|
||||||
if (i == 0)
|
|
||||||
|
if (i == 0) {
|
||||||
fprintf(fout, " None");
|
fprintf(fout, " None");
|
||||||
else
|
} else {
|
||||||
fprintf(fout, " Hz, %d tones", i);
|
fprintf(fout, " Hz, %d tones", i);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
fprintf(fout, "DCS:");
|
fprintf(fout, "DCS:");
|
||||||
for(i = 0; caps->dcs_list && i < 128 && caps->dcs_list[i] != 0; i++) {
|
|
||||||
|
for (i = 0; caps->dcs_list && i < 128 && caps->dcs_list[i] != 0; i++) {
|
||||||
fprintf(fout, " %d", caps->dcs_list[i]);
|
fprintf(fout, " %d", caps->dcs_list[i]);
|
||||||
}
|
}
|
||||||
if (i == 0)
|
|
||||||
|
if (i == 0) {
|
||||||
fprintf(fout, " None");
|
fprintf(fout, " None");
|
||||||
else
|
} else {
|
||||||
fprintf(fout, ", %d codes", i);
|
fprintf(fout, ", %d codes", i);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
sprintf_func(prntbuf, caps->has_get_func);
|
sprintf_func(prntbuf, caps->has_get_func);
|
||||||
|
@ -257,10 +322,12 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((caps->has_get_level & RIG_LEVEL_RAWSTR) &&
|
if ((caps->has_get_level & RIG_LEVEL_RAWSTR)
|
||||||
caps->str_cal.size == 0 &&
|
&& caps->str_cal.size == 0
|
||||||
!(caps->has_get_level & RIG_LEVEL_STRENGTH)) {
|
&& !(caps->has_get_level & RIG_LEVEL_STRENGTH)) {
|
||||||
fprintf(fout, "Warning--backend has get RAWSTR, but not calibration data\n");
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Warning--backend has get RAWSTR, but not calibration data\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,29 +348,33 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
|
|
||||||
sprintf_parm_gran(prntbuf, caps->has_set_parm, caps->parm_gran);
|
sprintf_parm_gran(prntbuf, caps->has_set_parm, caps->parm_gran);
|
||||||
fprintf(fout, "Set parameters: %s\n", prntbuf);
|
fprintf(fout, "Set parameters: %s\n", prntbuf);
|
||||||
|
|
||||||
if (caps->has_set_parm & RIG_PARM_READONLY_LIST) {
|
if (caps->has_set_parm & RIG_PARM_READONLY_LIST) {
|
||||||
fprintf(fout, "Warning--backend can set readonly parms!\n");
|
fprintf(fout, "Warning--backend can set readonly parms!\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Extra parameters:");
|
fprintf(fout, "Extra parameters:");
|
||||||
rig_ext_parm_foreach(rig, print_ext, fout);
|
rig_ext_parm_foreach(rig, print_ext, fout);
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
|
|
||||||
if (rig->state.mode_list != 0)
|
if (rig->state.mode_list != 0) {
|
||||||
sprintf_mode(prntbuf, rig->state.mode_list);
|
sprintf_mode(prntbuf, rig->state.mode_list);
|
||||||
else {
|
} else {
|
||||||
strcpy(prntbuf,"None. This backend might be bogus!\n");
|
strcpy(prntbuf, "None. This backend might be bogus!\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Mode list: %s\n", prntbuf);
|
fprintf(fout, "Mode list: %s\n", prntbuf);
|
||||||
|
|
||||||
if (rig->state.vfo_list != 0)
|
if (rig->state.vfo_list != 0) {
|
||||||
sprintf_vfo(prntbuf, rig->state.vfo_list);
|
sprintf_vfo(prntbuf, rig->state.vfo_list);
|
||||||
else {
|
} else {
|
||||||
strcpy(prntbuf,"None. This backend might be bogus!\n");
|
strcpy(prntbuf, "None. This backend might be bogus!\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "VFO list: %s\n", prntbuf);
|
fprintf(fout, "VFO list: %s\n", prntbuf);
|
||||||
|
|
||||||
sprintf_vfop(prntbuf, caps->vfo_ops);
|
sprintf_vfop(prntbuf, caps->vfo_ops);
|
||||||
|
@ -316,72 +387,118 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Memory name desc size:\t%d\n", caps->chan_desc_sz);
|
fprintf(fout, "Memory name desc size:\t%d\n", caps->chan_desc_sz);
|
||||||
|
|
||||||
fprintf(fout, "Memories:");
|
fprintf(fout, "Memories:");
|
||||||
|
|
||||||
for (i = 0; i < CHANLSTSIZ && caps->chan_list[i].type; i++) {
|
for (i = 0; i < CHANLSTSIZ && caps->chan_list[i].type; i++) {
|
||||||
fprintf(fout, "\n\t%d..%d: \t%s", caps->chan_list[i].start,
|
fprintf(fout,
|
||||||
|
"\n\t%d..%d: \t%s",
|
||||||
|
caps->chan_list[i].start,
|
||||||
caps->chan_list[i].end,
|
caps->chan_list[i].end,
|
||||||
rig_strmtype(caps->chan_list[i].type));
|
rig_strmtype(caps->chan_list[i].type));
|
||||||
fprintf(fout, "\n\t Mem caps: ");
|
fprintf(fout, "\n\t Mem caps: ");
|
||||||
dump_chan_caps(&caps->chan_list[i].mem_caps, fout);
|
dump_chan_caps(&caps->chan_list[i].mem_caps, fout);
|
||||||
}
|
}
|
||||||
if (i == 0)
|
|
||||||
|
if (i == 0) {
|
||||||
fprintf(fout, " None");
|
fprintf(fout, " None");
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
/* TODO: print rx/tx ranges here */
|
/* TODO: print rx/tx ranges here */
|
||||||
status = range_sanity_check(caps->tx_range_list1, 0);
|
status = range_sanity_check(caps->tx_range_list1, 0);
|
||||||
fprintf(fout, "TX ranges status, region 1:\t%s (%d)\n", status ? "Bad" : "OK", status);
|
fprintf(fout,
|
||||||
if (status) backend_warnings++;
|
"TX ranges status, region 1:\t%s (%d)\n",
|
||||||
|
status ? "Bad" : "OK",
|
||||||
|
status);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
backend_warnings++;
|
||||||
|
}
|
||||||
|
|
||||||
status = range_sanity_check(caps->rx_range_list1, 1);
|
status = range_sanity_check(caps->rx_range_list1, 1);
|
||||||
fprintf(fout, "RX ranges status, region 1:\t%s (%d)\n", status ? "Bad" : "OK", status);
|
fprintf(fout,
|
||||||
if (status) backend_warnings++;
|
"RX ranges status, region 1:\t%s (%d)\n",
|
||||||
|
status ? "Bad" : "OK",
|
||||||
|
status);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
backend_warnings++;
|
||||||
|
}
|
||||||
|
|
||||||
status = range_sanity_check(caps->tx_range_list2, 0);
|
status = range_sanity_check(caps->tx_range_list2, 0);
|
||||||
fprintf(fout, "TX ranges status, region 2:\t%s (%d)\n", status ? "Bad" : "OK", status);
|
fprintf(fout,
|
||||||
if (status) backend_warnings++;
|
"TX ranges status, region 2:\t%s (%d)\n",
|
||||||
|
status ? "Bad" : "OK",
|
||||||
|
status);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
backend_warnings++;
|
||||||
|
}
|
||||||
|
|
||||||
status = range_sanity_check(caps->rx_range_list2, 1);
|
status = range_sanity_check(caps->rx_range_list2, 1);
|
||||||
fprintf(fout, "RX ranges status, region 2:\t%s (%d)\n", status ? "Bad" : "OK", status);
|
fprintf(fout,
|
||||||
if (status) backend_warnings++;
|
"RX ranges status, region 2:\t%s (%d)\n",
|
||||||
|
status ? "Bad" : "OK",
|
||||||
|
status);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
backend_warnings++;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "Tuning steps:");
|
fprintf(fout, "Tuning steps:");
|
||||||
|
|
||||||
for (i = 0; i < TSLSTSIZ && !RIG_IS_TS_END(caps->tuning_steps[i]); i++) {
|
for (i = 0; i < TSLSTSIZ && !RIG_IS_TS_END(caps->tuning_steps[i]); i++) {
|
||||||
if (caps->tuning_steps[i].ts == RIG_TS_ANY)
|
if (caps->tuning_steps[i].ts == RIG_TS_ANY) {
|
||||||
strcpy(freqbuf, "ANY"); /* strcpy! Looks safe for now */
|
strcpy(freqbuf, "ANY"); /* strcpy! Looks safe for now */
|
||||||
else
|
} else {
|
||||||
sprintf_freq(freqbuf, caps->tuning_steps[i].ts);
|
sprintf_freq(freqbuf, caps->tuning_steps[i].ts);
|
||||||
|
}
|
||||||
|
|
||||||
sprintf_mode(prntbuf, caps->tuning_steps[i].modes);
|
sprintf_mode(prntbuf, caps->tuning_steps[i].modes);
|
||||||
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
|
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
fprintf(fout, " None! This backend might be bogus!");
|
fprintf(fout, " None! This backend might be bogus!");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
status = ts_sanity_check(caps->tuning_steps);
|
status = ts_sanity_check(caps->tuning_steps);
|
||||||
fprintf(fout, "Tuning steps status:\t%s (%d)\n",status?"Bad":"OK",status);
|
fprintf(fout, "Tuning steps status:\t%s (%d)\n", status ? "Bad" : "OK", status);
|
||||||
if (status) backend_warnings++;
|
|
||||||
|
if (status) {
|
||||||
|
backend_warnings++;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(fout, "Filters:");
|
fprintf(fout, "Filters:");
|
||||||
for (i=0; i<FLTLSTSIZ && !RIG_IS_FLT_END(caps->filters[i]); i++) {
|
|
||||||
if (caps->filters[i].width == RIG_FLT_ANY)
|
for (i = 0; i < FLTLSTSIZ && !RIG_IS_FLT_END(caps->filters[i]); i++) {
|
||||||
|
if (caps->filters[i].width == RIG_FLT_ANY) {
|
||||||
strcpy(freqbuf, "ANY");
|
strcpy(freqbuf, "ANY");
|
||||||
else
|
} else {
|
||||||
sprintf_freq(freqbuf,caps->filters[i].width);
|
sprintf_freq(freqbuf, caps->filters[i].width);
|
||||||
sprintf_mode(prntbuf,caps->filters[i].modes);
|
}
|
||||||
|
|
||||||
|
sprintf_mode(prntbuf, caps->filters[i].modes);
|
||||||
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
|
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
fprintf(fout, " None. This backend might be bogus!");
|
fprintf(fout, " None. This backend might be bogus!");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
fprintf(fout, "Bandwidths:");
|
fprintf(fout, "Bandwidths:");
|
||||||
|
|
||||||
for (i = 1; i < RIG_MODE_TESTS_MAX; i <<= 1) {
|
for (i = 1; i < RIG_MODE_TESTS_MAX; i <<= 1) {
|
||||||
pbwidth_t pbnorm = rig_passband_normal(rig, i);
|
pbwidth_t pbnorm = rig_passband_normal(rig, i);
|
||||||
|
|
||||||
if (pbnorm == 0)
|
if (pbnorm == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf_freq(freqbuf, pbnorm);
|
sprintf_freq(freqbuf, pbnorm);
|
||||||
fprintf(fout, "\n\t%s\tNormal: %s,\t", rig_strrmode(i), freqbuf);
|
fprintf(fout, "\n\t%s\tNormal: %s,\t", rig_strrmode(i), freqbuf);
|
||||||
|
@ -392,6 +509,7 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
sprintf_freq(freqbuf, rig_passband_wide(rig, i));
|
sprintf_freq(freqbuf, rig_passband_wide(rig, i));
|
||||||
fprintf(fout, "Wide: %s", freqbuf);
|
fprintf(fout, "Wide: %s", freqbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
fprintf(fout, "Has priv data:\t%c\n", caps->priv != NULL ? 'Y' : 'N');
|
fprintf(fout, "Has priv data:\t%c\n", caps->priv != NULL ? 'Y' : 'N');
|
||||||
|
@ -415,24 +533,51 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Can set PTT:\t%c\n", caps->set_ptt != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set PTT:\t%c\n", caps->set_ptt != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get PTT:\t%c\n", caps->get_ptt != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get PTT:\t%c\n", caps->get_ptt != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get DCD:\t%c\n", caps->get_dcd != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get DCD:\t%c\n", caps->get_dcd != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Repeater Duplex:\t%c\n", caps->set_rptr_shift != NULL ? 'Y' : 'N');
|
fprintf(fout,
|
||||||
fprintf(fout, "Can get Repeater Duplex:\t%c\n", caps->get_rptr_shift != NULL ? 'Y' : 'N');
|
"Can set Repeater Duplex:\t%c\n",
|
||||||
fprintf(fout, "Can set Repeater Offset:\t%c\n", caps->set_rptr_offs != NULL ? 'Y' : 'N');
|
caps->set_rptr_shift != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Repeater Offset:\t%c\n", caps->get_rptr_offs != NULL ? 'Y' : 'N');
|
fprintf(fout,
|
||||||
|
"Can get Repeater Duplex:\t%c\n",
|
||||||
|
caps->get_rptr_shift != NULL ? 'Y' : 'N');
|
||||||
|
fprintf(fout,
|
||||||
|
"Can set Repeater Offset:\t%c\n",
|
||||||
|
caps->set_rptr_offs != NULL ? 'Y' : 'N');
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Repeater Offset:\t%c\n",
|
||||||
|
caps->get_rptr_offs != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
can_esplit = caps->set_split_vfo && (caps->set_vfo ||
|
can_esplit = caps->set_split_vfo
|
||||||
(rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op));
|
&& (caps->set_vfo
|
||||||
fprintf(fout, "Can set Split Freq:\t%c\n", caps->set_split_freq != NULL ? 'Y' :
|
|| (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op));
|
||||||
(can_esplit && caps->set_freq ? 'E' : 'N'));
|
|
||||||
fprintf(fout, "Can get Split Freq:\t%c\n", caps->get_split_freq != NULL ? 'Y' :
|
fprintf(fout,
|
||||||
(can_esplit && caps->get_freq ? 'E' : 'N'));
|
"Can set Split Freq:\t%c\n",
|
||||||
fprintf(fout, "Can set Split Mode:\t%c\n", caps->set_split_mode != NULL ? 'Y' :
|
caps->set_split_freq != NULL ? 'Y' : (can_esplit
|
||||||
(can_esplit && caps->set_mode ? 'E' : 'N'));
|
&& caps->set_freq ? 'E' : 'N'));
|
||||||
fprintf(fout, "Can get Split Mode:\t%c\n", caps->get_split_mode != NULL ? 'Y' :
|
|
||||||
(can_esplit && caps->get_mode ? 'E' : 'N'));
|
fprintf(fout,
|
||||||
|
"Can get Split Freq:\t%c\n",
|
||||||
|
caps->get_split_freq != NULL ? 'Y' : (can_esplit
|
||||||
|
&& caps->get_freq ? 'E' : 'N'));
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can set Split Mode:\t%c\n",
|
||||||
|
caps->set_split_mode != NULL ? 'Y' : (can_esplit
|
||||||
|
&& caps->set_mode ? 'E' : 'N'));
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Split Mode:\t%c\n",
|
||||||
|
caps->get_split_mode != NULL ? 'Y' : (can_esplit
|
||||||
|
&& caps->get_mode ? 'E' : 'N'));
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can set Split VFO:\t%c\n",
|
||||||
|
caps->set_split_vfo != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Split VFO:\t%c\n",
|
||||||
|
caps->get_split_vfo != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
fprintf(fout, "Can set Split VFO:\t%c\n", caps->set_split_vfo != NULL ? 'Y' : 'N');
|
|
||||||
fprintf(fout, "Can get Split VFO:\t%c\n", caps->get_split_vfo != NULL ? 'Y' : 'N');
|
|
||||||
fprintf(fout, "Can set Tuning Step:\t%c\n", caps->set_ts != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Tuning Step:\t%c\n", caps->set_ts != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Tuning Step:\t%c\n", caps->get_ts != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Tuning Step:\t%c\n", caps->get_ts != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set RIT:\t%c\n", caps->set_rit != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set RIT:\t%c\n", caps->set_rit != NULL ? 'Y' : 'N');
|
||||||
|
@ -443,17 +588,39 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Can get CTCSS:\t%c\n", caps->get_ctcss_tone != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get CTCSS:\t%c\n", caps->get_ctcss_tone != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set DCS:\t%c\n", caps->set_dcs_code != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set DCS:\t%c\n", caps->set_dcs_code != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get DCS:\t%c\n", caps->get_dcs_code != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get DCS:\t%c\n", caps->get_dcs_code != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set CTCSS Squelch:\t%c\n", caps->set_ctcss_sql != NULL ? 'Y' : 'N');
|
|
||||||
fprintf(fout, "Can get CTCSS Squelch:\t%c\n", caps->get_ctcss_sql != NULL ? 'Y' : 'N');
|
fprintf(fout,
|
||||||
fprintf(fout, "Can set DCS Squelch:\t%c\n", caps->set_dcs_sql != NULL ? 'Y' : 'N');
|
"Can set CTCSS Squelch:\t%c\n",
|
||||||
fprintf(fout, "Can get DCS Squelch:\t%c\n", caps->get_dcs_sql != NULL ? 'Y' : 'N');
|
caps->set_ctcss_sql != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Power Stat:\t%c\n", caps->set_powerstat != NULL ? 'Y' : 'N');
|
|
||||||
fprintf(fout, "Can get Power Stat:\t%c\n", caps->get_powerstat != NULL ? 'Y' : 'N');
|
fprintf(fout,
|
||||||
|
"Can get CTCSS Squelch:\t%c\n",
|
||||||
|
caps->get_ctcss_sql != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can set DCS Squelch:\t%c\n",
|
||||||
|
caps->set_dcs_sql != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get DCS Squelch:\t%c\n",
|
||||||
|
caps->get_dcs_sql != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can set Power Stat:\t%c\n",
|
||||||
|
caps->set_powerstat != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Power Stat:\t%c\n",
|
||||||
|
caps->get_powerstat != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
fprintf(fout, "Can Reset:\t%c\n", caps->reset != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can Reset:\t%c\n", caps->reset != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Ant:\t%c\n", caps->get_ant != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Ant:\t%c\n", caps->get_ant != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Ant:\t%c\n", caps->set_ant != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Ant:\t%c\n", caps->set_ant != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Transceive:\t%c\n", caps->set_trn != NULL ? 'Y' :
|
|
||||||
caps->transceive == RIG_TRN_RIG ? 'E' : 'N');
|
fprintf(fout,
|
||||||
|
"Can set Transceive:\t%c\n",
|
||||||
|
caps->set_trn != NULL ? 'Y' : caps->transceive == RIG_TRN_RIG ? 'E' : 'N');
|
||||||
|
|
||||||
fprintf(fout, "Can get Transceive:\t%c\n", caps->get_trn != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Transceive:\t%c\n", caps->get_trn != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Func:\t%c\n", caps->set_func != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Func:\t%c\n", caps->set_func != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Func:\t%c\n", caps->get_func != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Func:\t%c\n", caps->get_func != NULL ? 'Y' : 'N');
|
||||||
|
@ -461,22 +628,31 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Can get Level:\t%c\n", caps->get_level != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Level:\t%c\n", caps->get_level != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Param:\t%c\n", caps->set_parm != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Param:\t%c\n", caps->set_parm != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Param:\t%c\n", caps->get_parm != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Param:\t%c\n", caps->get_parm != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can send DTMF:\t%c\n", caps->send_dtmf != NULL ? 'Y': 'N');
|
fprintf(fout, "Can send DTMF:\t%c\n", caps->send_dtmf != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can recv DTMF:\t%c\n", caps->recv_dtmf != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can recv DTMF:\t%c\n", caps->recv_dtmf != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can send Morse:\t%c\n", caps->send_morse != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can send Morse:\t%c\n", caps->send_morse != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can decode Events:\t%c\n", caps->decode_event != NULL ? 'Y' : 'N');
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can decode Events:\t%c\n",
|
||||||
|
caps->decode_event != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
fprintf(fout, "Can set Bank:\t%c\n", caps->set_bank != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Bank:\t%c\n", caps->set_bank != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Mem:\t%c\n", caps->set_mem != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Mem:\t%c\n", caps->set_mem != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Mem:\t%c\n", caps->get_mem != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Mem:\t%c\n", caps->get_mem != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
can_echannel = caps->set_mem && (
|
can_echannel = caps->set_mem
|
||||||
(caps->set_vfo && ((rig->state.vfo_list & RIG_VFO_MEM) == RIG_VFO_MEM)) ||
|
&& ((caps->set_vfo
|
||||||
(caps->vfo_op && rig_has_vfo_op(rig, RIG_OP_TO_VFO|RIG_OP_FROM_VFO)));
|
&& ((rig->state.vfo_list & RIG_VFO_MEM) == RIG_VFO_MEM))
|
||||||
|
|| (caps->vfo_op
|
||||||
|
&& rig_has_vfo_op(rig, RIG_OP_TO_VFO | RIG_OP_FROM_VFO)));
|
||||||
|
|
||||||
fprintf(fout, "Can set Channel:\t%c\n", caps->set_channel != NULL ? 'Y' :
|
fprintf(fout,
|
||||||
(can_echannel ? 'E' : 'N'));
|
"Can set Channel:\t%c\n",
|
||||||
fprintf(fout, "Can get Channel:\t%c\n", caps->get_channel != NULL ? 'Y' :
|
caps->set_channel != NULL ? 'Y' : (can_echannel ? 'E' : 'N'));
|
||||||
(can_echannel ? 'E' : 'N'));
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Channel:\t%c\n",
|
||||||
|
caps->get_channel != NULL ? 'Y' : (can_echannel ? 'E' : 'N'));
|
||||||
|
|
||||||
fprintf(fout, "Can ctl Mem/VFO:\t%c\n", caps->vfo_op != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can ctl Mem/VFO:\t%c\n", caps->vfo_op != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can Scan:\t%c\n", caps->scan != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can Scan:\t%c\n", caps->scan != NULL ? 'Y' : 'N');
|
||||||
|
@ -484,7 +660,6 @@ int dumpcaps (RIG* rig, FILE *fout)
|
||||||
fprintf(fout, "Can get power2mW:\t%c\n", caps->power2mW != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get power2mW:\t%c\n", caps->power2mW != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get mW2power:\t%c\n", caps->mW2power != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get mW2power:\t%c\n", caps->mW2power != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
|
||||||
fprintf(fout, "\nOverall backend warnings: %d\n", backend_warnings);
|
fprintf(fout, "\nOverall backend warnings: %d\n", backend_warnings);
|
||||||
|
|
||||||
return backend_warnings;
|
return backend_warnings;
|
||||||
|
@ -516,24 +691,36 @@ int range_sanity_check(const struct freq_range_list range_list[], int rx)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < FRQRANGESIZ; i++) {
|
for (i = 0; i < FRQRANGESIZ; i++) {
|
||||||
if (range_list[i].start == 0 && range_list[i].end == 0)
|
if (range_list[i].start == 0 && range_list[i].end == 0) {
|
||||||
break;
|
break;
|
||||||
if (range_list[i].start > range_list[i].end)
|
}
|
||||||
|
|
||||||
|
if (range_list[i].start > range_list[i].end) {
|
||||||
return -1;
|
return -1;
|
||||||
if (range_list[i].modes == 0)
|
}
|
||||||
|
|
||||||
|
if (range_list[i].modes == 0) {
|
||||||
return -2;
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
if (rx) {
|
if (rx) {
|
||||||
if (range_list[i].low_power > 0 && range_list[i].high_power > 0)
|
if (range_list[i].low_power > 0 && range_list[i].high_power > 0) {
|
||||||
return -3;
|
return -3;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(range_list[i].low_power > 0 && range_list[i].high_power > 0))
|
if (!(range_list[i].low_power > 0 && range_list[i].high_power > 0)) {
|
||||||
return -3;
|
return -3;
|
||||||
if (range_list[i].low_power > range_list[i].high_power)
|
}
|
||||||
|
|
||||||
|
if (range_list[i].low_power > range_list[i].high_power) {
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == FRQRANGESIZ)
|
}
|
||||||
|
|
||||||
|
if (i == FRQRANGESIZ) {
|
||||||
return -4;
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -554,19 +741,30 @@ int ts_sanity_check(const struct tuning_step_list tuning_step[])
|
||||||
|
|
||||||
last_ts = 0;
|
last_ts = 0;
|
||||||
last_modes = RIG_MODE_NONE;
|
last_modes = RIG_MODE_NONE;
|
||||||
for (i=0; i<TSLSTSIZ; i++) {
|
|
||||||
if (RIG_IS_TS_END(tuning_step[i]))
|
for (i = 0; i < TSLSTSIZ; i++) {
|
||||||
|
if (RIG_IS_TS_END(tuning_step[i])) {
|
||||||
break;
|
break;
|
||||||
if (tuning_step[i].ts != RIG_TS_ANY && tuning_step[i].ts < last_ts &&
|
}
|
||||||
last_modes == tuning_step[i].modes)
|
|
||||||
|
if (tuning_step[i].ts != RIG_TS_ANY
|
||||||
|
&& tuning_step[i].ts < last_ts
|
||||||
|
&& last_modes == tuning_step[i].modes) {
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
if (tuning_step[i].modes == 0)
|
}
|
||||||
|
|
||||||
|
if (tuning_step[i].modes == 0) {
|
||||||
return -2;
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
last_ts = tuning_step[i].ts;
|
last_ts = tuning_step[i].ts;
|
||||||
last_modes = tuning_step[i].modes;
|
last_modes = tuning_step[i].modes;
|
||||||
}
|
}
|
||||||
if (i == TSLSTSIZ)
|
|
||||||
|
if (i == TSLSTSIZ) {
|
||||||
return -4;
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -574,36 +772,107 @@ int ts_sanity_check(const struct tuning_step_list tuning_step[])
|
||||||
|
|
||||||
static void dump_chan_caps(const channel_cap_t *chan, FILE *fout)
|
static void dump_chan_caps(const channel_cap_t *chan, FILE *fout)
|
||||||
{
|
{
|
||||||
if (chan->bank_num) fprintf(fout, "BANK ");
|
if (chan->bank_num) {
|
||||||
if (chan->ant) fprintf(fout, "ANT ");
|
fprintf(fout, "BANK ");
|
||||||
if (chan->freq) fprintf(fout, "FREQ ");
|
}
|
||||||
if (chan->mode) fprintf(fout, "MODE ");
|
|
||||||
if (chan->width) fprintf(fout, "WIDTH ");
|
if (chan->ant) {
|
||||||
if (chan->tx_freq) fprintf(fout, "TXFREQ ");
|
fprintf(fout, "ANT ");
|
||||||
if (chan->tx_mode) fprintf(fout, "TXMODE ");
|
}
|
||||||
if (chan->tx_width) fprintf(fout, "TXWIDTH ");
|
|
||||||
if (chan->split) fprintf(fout, "SPLIT ");
|
if (chan->freq) {
|
||||||
if (chan->rptr_shift) fprintf(fout, "RPTRSHIFT ");
|
fprintf(fout, "FREQ ");
|
||||||
if (chan->rptr_offs) fprintf(fout, "RPTROFS ");
|
}
|
||||||
if (chan->tuning_step) fprintf(fout, "TS ");
|
|
||||||
if (chan->rit) fprintf(fout, "RIT ");
|
if (chan->mode) {
|
||||||
if (chan->xit) fprintf(fout, "XIT ");
|
fprintf(fout, "MODE ");
|
||||||
if (chan->funcs) fprintf(fout, "FUNC "); /* TODO: iterate over the list */
|
}
|
||||||
if (chan->levels) fprintf(fout, "LEVEL "); /* TODO: iterate over the list */
|
|
||||||
if (chan->ctcss_tone) fprintf(fout, "TONE ");
|
if (chan->width) {
|
||||||
if (chan->ctcss_sql) fprintf(fout, "CTCSS ");
|
fprintf(fout, "WIDTH ");
|
||||||
if (chan->dcs_code) fprintf(fout, "DCSCODE ");
|
}
|
||||||
if (chan->dcs_sql) fprintf(fout, "DCSSQL ");
|
|
||||||
if (chan->scan_group) fprintf(fout, "SCANGRP ");
|
if (chan->tx_freq) {
|
||||||
if (chan->flags) fprintf(fout, "FLAG "); /* TODO: iterate over the RIG_CHFLAG's */
|
fprintf(fout, "TXFREQ ");
|
||||||
if (chan->channel_desc) fprintf(fout, "NAME ");
|
}
|
||||||
if (chan->ext_levels) fprintf(fout, "EXTLVL ");
|
|
||||||
|
if (chan->tx_mode) {
|
||||||
|
fprintf(fout, "TXMODE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->tx_width) {
|
||||||
|
fprintf(fout, "TXWIDTH ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->split) {
|
||||||
|
fprintf(fout, "SPLIT ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->rptr_shift) {
|
||||||
|
fprintf(fout, "RPTRSHIFT ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->rptr_offs) {
|
||||||
|
fprintf(fout, "RPTROFS ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->tuning_step) {
|
||||||
|
fprintf(fout, "TS ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->rit) {
|
||||||
|
fprintf(fout, "RIT ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->xit) {
|
||||||
|
fprintf(fout, "XIT ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->funcs) {
|
||||||
|
fprintf(fout, "FUNC "); /* TODO: iterate over the list */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->levels) {
|
||||||
|
fprintf(fout, "LEVEL "); /* TODO: iterate over the list */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->ctcss_tone) {
|
||||||
|
fprintf(fout, "TONE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->ctcss_sql) {
|
||||||
|
fprintf(fout, "CTCSS ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->dcs_code) {
|
||||||
|
fprintf(fout, "DCSCODE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->dcs_sql) {
|
||||||
|
fprintf(fout, "DCSSQL ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->scan_group) {
|
||||||
|
fprintf(fout, "SCANGRP ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->flags) {
|
||||||
|
fprintf(fout, "FLAG "); /* TODO: iterate over the RIG_CHFLAG's */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->channel_desc) {
|
||||||
|
fprintf(fout, "NAME ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->ext_levels) {
|
||||||
|
fprintf(fout, "EXTLVL ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dumpconf (RIG* rig, FILE *fout)
|
|
||||||
|
int dumpconf(RIG *rig, FILE *fout)
|
||||||
{
|
{
|
||||||
rig_token_foreach(rig, print_conf_list, (rig_ptr_t)rig);
|
rig_token_foreach(rig, print_conf_list, (rig_ptr_t)rig);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -37,13 +37,14 @@
|
||||||
/*
|
/*
|
||||||
* the rot may be in rot_init state, but not openned
|
* the rot may be in rot_init state, but not openned
|
||||||
*/
|
*/
|
||||||
int dumpcaps_rot (ROT* rot, FILE *fout)
|
int dumpcaps_rot(ROT *rot, FILE *fout)
|
||||||
{
|
{
|
||||||
const struct rot_caps *caps;
|
const struct rot_caps *caps;
|
||||||
int backend_warnings = 0;
|
int backend_warnings = 0;
|
||||||
|
|
||||||
if (!rot || !rot->caps)
|
if (!rot || !rot->caps) {
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
caps = rot->caps;
|
caps = rot->caps;
|
||||||
|
|
||||||
|
@ -54,31 +55,40 @@ int dumpcaps_rot (ROT* rot, FILE *fout)
|
||||||
fprintf(fout, "Backend copyright:\t%s\n", caps->copyright);
|
fprintf(fout, "Backend copyright:\t%s\n", caps->copyright);
|
||||||
fprintf(fout, "Backend status:\t\t%s\n", rig_strstatus(caps->status));
|
fprintf(fout, "Backend status:\t\t%s\n", rig_strstatus(caps->status));
|
||||||
fprintf(fout, "Rot type:\t\t");
|
fprintf(fout, "Rot type:\t\t");
|
||||||
|
|
||||||
switch (caps->rot_type & ROT_TYPE_MASK) {
|
switch (caps->rot_type & ROT_TYPE_MASK) {
|
||||||
case ROT_TYPE_OTHER:
|
case ROT_TYPE_OTHER:
|
||||||
fprintf(fout, "Other\n");
|
fprintf(fout, "Other\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_TYPE_AZIMUTH:
|
case ROT_TYPE_AZIMUTH:
|
||||||
fprintf(fout, "Azimuth\n");
|
fprintf(fout, "Azimuth\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_TYPE_ELEVATION:
|
case ROT_TYPE_ELEVATION:
|
||||||
fprintf(fout, "Elevation\n");
|
fprintf(fout, "Elevation\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_TYPE_AZEL:
|
case ROT_TYPE_AZEL:
|
||||||
fprintf(fout, "Az-El\n");
|
fprintf(fout, "Az-El\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Port type:\t\t");
|
fprintf(fout, "Port type:\t\t");
|
||||||
|
|
||||||
switch (caps->port_type) {
|
switch (caps->port_type) {
|
||||||
case RIG_PORT_SERIAL:
|
case RIG_PORT_SERIAL:
|
||||||
fprintf(fout, "RS-232\n");
|
fprintf(fout, "RS-232\n");
|
||||||
fprintf(fout, "Serial speed:\t\t%d..%d bauds, %d%c%d%s\n", caps->serial_rate_min,
|
fprintf(fout,
|
||||||
caps->serial_rate_max, caps->serial_data_bits,
|
"Serial speed:\t\t%d..%d bauds, %d%c%d%s\n",
|
||||||
caps->serial_parity == RIG_PARITY_NONE ? 'N':
|
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' :
|
caps->serial_parity == RIG_PARITY_ODD ? 'O' :
|
||||||
caps->serial_parity == RIG_PARITY_EVEN ? 'E' :
|
caps->serial_parity == RIG_PARITY_EVEN ? 'E' :
|
||||||
caps->serial_parity == RIG_PARITY_MARK ? 'M' : 'S',
|
caps->serial_parity == RIG_PARITY_MARK ? 'M' : 'S',
|
||||||
|
@ -87,32 +97,44 @@ int dumpcaps_rot (ROT* rot, FILE *fout)
|
||||||
(caps->serial_handshake == RIG_HANDSHAKE_XONXOFF ? " XONXOFF" : " CTS/RTS")
|
(caps->serial_handshake == RIG_HANDSHAKE_XONXOFF ? " XONXOFF" : " CTS/RTS")
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_PARALLEL:
|
case RIG_PORT_PARALLEL:
|
||||||
fprintf(fout, "Parallel\n");
|
fprintf(fout, "Parallel\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_DEVICE:
|
case RIG_PORT_DEVICE:
|
||||||
fprintf(fout, "Device driver\n");
|
fprintf(fout, "Device driver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_USB:
|
case RIG_PORT_USB:
|
||||||
fprintf(fout, "USB\n");
|
fprintf(fout, "USB\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NETWORK:
|
case RIG_PORT_NETWORK:
|
||||||
fprintf(fout, "Network link\n");
|
fprintf(fout, "Network link\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_UDP_NETWORK:
|
case RIG_PORT_UDP_NETWORK:
|
||||||
fprintf(fout, "UDP Network link\n");
|
fprintf(fout, "UDP Network link\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NONE:
|
case RIG_PORT_NONE:
|
||||||
fprintf(fout, "None\n");
|
fprintf(fout, "None\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(fout, "Unknown\n");
|
fprintf(fout, "Unknown\n");
|
||||||
backend_warnings++;
|
backend_warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "Write delay:\t\t%dmS, timeout %dmS, %d retr%s\n",
|
fprintf(fout,
|
||||||
caps->write_delay, caps->timeout, caps->retry, (caps->retry == 1) ? "y" : "ies");
|
"Write delay:\t\t%dmS, timeout %dmS, %d retr%s\n",
|
||||||
fprintf(fout, "Post Write delay:\t%dmS\n",
|
caps->write_delay,
|
||||||
|
caps->timeout, caps->retry,
|
||||||
|
(caps->retry == 1) ? "y" : "ies");
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Post Write delay:\t%dmS\n",
|
||||||
caps->post_write_delay);
|
caps->post_write_delay);
|
||||||
|
|
||||||
fprintf(fout, "Min Azimuth:\t\t%.2f\n", caps->min_az);
|
fprintf(fout, "Min Azimuth:\t\t%.2f\n", caps->min_az);
|
||||||
|
@ -134,8 +156,15 @@ int dumpcaps_rot (ROT* rot, FILE *fout)
|
||||||
fprintf(fout, "Has Close:\t\t%c\n", caps->rot_close != NULL ? 'Y' : 'N');
|
fprintf(fout, "Has Close:\t\t%c\n", caps->rot_close != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Conf:\t\t%c\n", caps->set_conf != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can set Conf:\t\t%c\n", caps->set_conf != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can get Conf:\t\t%c\n", caps->get_conf != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can get Conf:\t\t%c\n", caps->get_conf != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can set Position:\t%c\n", caps->set_position != NULL ? 'Y' : 'N');
|
|
||||||
fprintf(fout, "Can get Position:\t%c\n", caps->get_position != NULL ? 'Y' : 'N');
|
fprintf(fout,
|
||||||
|
"Can set Position:\t%c\n",
|
||||||
|
caps->set_position != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
|
fprintf(fout,
|
||||||
|
"Can get Position:\t%c\n",
|
||||||
|
caps->get_position != NULL ? 'Y' : 'N');
|
||||||
|
|
||||||
fprintf(fout, "Can Stop:\t\t%c\n", caps->stop != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can Stop:\t\t%c\n", caps->stop != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can Park:\t\t%c\n", caps->park != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can Park:\t\t%c\n", caps->park != NULL ? 'Y' : 'N');
|
||||||
fprintf(fout, "Can Reset:\t\t%c\n", caps->reset != NULL ? 'Y' : 'N');
|
fprintf(fout, "Can Reset:\t\t%c\n", caps->reset != NULL ? 'Y' : 'N');
|
||||||
|
@ -146,4 +175,3 @@ int dumpcaps_rot (ROT* rot, FILE *fout)
|
||||||
|
|
||||||
return backend_warnings;
|
return backend_warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
307
tests/dumpmem.c
307
tests/dumpmem.c
|
@ -27,47 +27,50 @@
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#define SERIAL_PORT "/dev/ttyS0"
|
#define SERIAL_PORT "/dev/ttyS0"
|
||||||
|
|
||||||
static char *decode_modes(rmode_t modes);
|
|
||||||
|
static char * decode_modes(rmode_t modes);
|
||||||
static int dump_chan(RIG *rig, int chan_num);
|
static int dump_chan(RIG *rig, int chan_num);
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig;
|
RIG *my_rig;
|
||||||
int status,i,j;
|
int status, i, j;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr,"%s <rig_num>\n",argv[0]);
|
fprintf(stderr, "%s <rig_num>\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_rig = rig_init(atoi(argv[1]));
|
my_rig = rig_init(atoi(argv[1]));
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr,"Unknown rig num: %d\n",atoi(argv[1]));
|
fprintf(stderr, "Unknown rig num: %d\n", atoi(argv[1]));
|
||||||
fprintf(stderr,"Please check riglist.h\n");
|
fprintf(stderr, "Please check riglist.h\n");
|
||||||
exit(1); /* whoops! something went wrong (mem alloc?) */
|
exit(1); /* whoops! something went wrong (mem alloc?) */
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
||||||
|
|
||||||
if (rig_open(my_rig))
|
if (rig_open(my_rig)) {
|
||||||
exit(2);
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
status = rig_set_vfo(my_rig, RIG_VFO_B);
|
status = rig_set_vfo(my_rig, RIG_VFO_B);
|
||||||
|
|
||||||
|
|
||||||
if (status != RIG_OK ) {
|
if (status != RIG_OK) {
|
||||||
printf("rig_set_vfo: error = %s \n", rigerror(status));
|
printf("rig_set_vfo: error = %s \n", rigerror(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* chan_t is used to describe what memory your rig is equipped with
|
* chan_t is used to describe what memory your rig is equipped with
|
||||||
* cf. chan_list field in caps
|
* cf. chan_list field in caps
|
||||||
* Example for the Ic706MkIIG (99 memory channels, 2 scan edges, 2 call chans):
|
* Example for the Ic706MkIIG (99 memory channels, 2 scan edges, 2 call chans):
|
||||||
|
@ -79,7 +82,7 @@ int main (int argc, char *argv[])
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i=0; my_rig->state.chan_list[i].type && i < CHANLSTSIZ; i++) {
|
for (i = 0; my_rig->state.chan_list[i].type && i < CHANLSTSIZ; i++) {
|
||||||
for (j = my_rig->state.chan_list[i].start;
|
for (j = my_rig->state.chan_list[i].start;
|
||||||
j <= my_rig->state.chan_list[i].end; j++) {
|
j <= my_rig->state.chan_list[i].end; j++) {
|
||||||
dump_chan(my_rig, j);
|
dump_chan(my_rig, j);
|
||||||
|
@ -89,7 +92,7 @@ int main (int argc, char *argv[])
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
|
||||||
printf("port %s closed ok \n",SERIAL_PORT);
|
printf("port %s closed ok \n", SERIAL_PORT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -99,24 +102,48 @@ int main (int argc, char *argv[])
|
||||||
* NB: this function is not reentrant, because of the static buf.
|
* NB: this function is not reentrant, because of the static buf.
|
||||||
* but who cares? --SF
|
* but who cares? --SF
|
||||||
*/
|
*/
|
||||||
static char *decode_modes(rmode_t modes)
|
static char * decode_modes(rmode_t modes)
|
||||||
{
|
{
|
||||||
static char buf[80];
|
static char buf[80];
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if (modes&RIG_MODE_AM) strcat(buf,"AM ");
|
|
||||||
if (modes&RIG_MODE_CW) strcat(buf,"CW ");
|
if (modes & RIG_MODE_AM) {
|
||||||
if (modes&RIG_MODE_USB) strcat(buf,"USB ");
|
strcat(buf, "AM ");
|
||||||
if (modes&RIG_MODE_LSB) strcat(buf,"LSB ");
|
}
|
||||||
if (modes&RIG_MODE_RTTY) strcat(buf,"RTTY ");
|
|
||||||
if (modes&RIG_MODE_FM) strcat(buf,"FM ");
|
if (modes & RIG_MODE_CW) {
|
||||||
|
strcat(buf, "CW ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modes & RIG_MODE_USB) {
|
||||||
|
strcat(buf, "USB ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modes & RIG_MODE_LSB) {
|
||||||
|
strcat(buf, "LSB ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modes & RIG_MODE_RTTY) {
|
||||||
|
strcat(buf, "RTTY ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modes & RIG_MODE_FM) {
|
||||||
|
strcat(buf, "FM ");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RIG_MODE_WFM
|
#ifdef RIG_MODE_WFM
|
||||||
if (modes&RIG_MODE_WFM) strcat(buf,"WFM ");
|
|
||||||
|
if (modes & RIG_MODE_WFM) {
|
||||||
|
strcat(buf, "WFM ");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int dump_chan(RIG *rig, int chan_num)
|
int dump_chan(RIG *rig, int chan_num)
|
||||||
{
|
{
|
||||||
channel_t chan;
|
channel_t chan;
|
||||||
|
@ -125,113 +152,199 @@ int dump_chan(RIG *rig, int chan_num)
|
||||||
|
|
||||||
chan.vfo = RIG_VFO_MEM;
|
chan.vfo = RIG_VFO_MEM;
|
||||||
chan.channel_num = chan_num;
|
chan.channel_num = chan_num;
|
||||||
status=rig_get_channel(rig, &chan);
|
status = rig_get_channel(rig, &chan);
|
||||||
|
|
||||||
if (status != RIG_OK ) {
|
if (status != RIG_OK) {
|
||||||
printf("rig_get_channel: error = %s \n", rigerror(status));
|
printf("rig_get_channel: error = %s \n", rigerror(status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Channel: %d\n", chan.channel_num);
|
printf("Channel: %d\n", chan.channel_num);
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.freq);
|
sprintf_freq(freqbuf, chan.freq);
|
||||||
printf("Frequency: %s\n", freqbuf);
|
printf("Frequency: %s\n", freqbuf);
|
||||||
printf("Mode: %s\n", decode_modes(chan.mode));
|
printf("Mode: %s\n", decode_modes(chan.mode));
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.width);
|
sprintf_freq(freqbuf, chan.width);
|
||||||
printf("Width: %s\n", freqbuf);
|
printf("Width: %s\n", freqbuf);
|
||||||
printf("VFO: %d\n", chan.vfo);
|
printf("VFO: %d\n", chan.vfo);
|
||||||
|
|
||||||
printf("Split: %d\n", chan.split);
|
printf("Split: %d\n", chan.split);
|
||||||
sprintf_freq(freqbuf,chan.tx_freq);
|
sprintf_freq(freqbuf, chan.tx_freq);
|
||||||
printf("TXFrequency: %s\n", freqbuf);
|
printf("TXFrequency: %s\n", freqbuf);
|
||||||
printf("TXMode: %s\n", decode_modes(chan.tx_mode));
|
printf("TXMode: %s\n", decode_modes(chan.tx_mode));
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.tx_width);
|
sprintf_freq(freqbuf, chan.tx_width);
|
||||||
printf("TXWidth: %s\n", freqbuf);
|
printf("TXWidth: %s\n", freqbuf);
|
||||||
|
|
||||||
printf("Shift: %s\n", rig_strptrshift(chan.rptr_shift));
|
printf("Shift: %s\n", rig_strptrshift(chan.rptr_shift));
|
||||||
sprintf_freq(freqbuf,chan.rptr_offs);
|
sprintf_freq(freqbuf, chan.rptr_offs);
|
||||||
printf("Offset: %s%s\n", chan.rptr_offs>0?"+":"", freqbuf);
|
printf("Offset: %s%s\n", chan.rptr_offs > 0 ? "+" : "", freqbuf);
|
||||||
|
|
||||||
printf("Antenna: %d\n", chan.ant);
|
printf("Antenna: %d\n", chan.ant);
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.tuning_step);
|
sprintf_freq(freqbuf, chan.tuning_step);
|
||||||
printf("Step: %s\n", freqbuf);
|
printf("Step: %s\n", freqbuf);
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.rit);
|
sprintf_freq(freqbuf, chan.rit);
|
||||||
printf("RIT: %s%s\n", chan.rit>0?"+":"", freqbuf);
|
printf("RIT: %s%s\n", chan.rit > 0 ? "+" : "", freqbuf);
|
||||||
|
|
||||||
sprintf_freq(freqbuf,chan.xit);
|
sprintf_freq(freqbuf, chan.xit);
|
||||||
printf("XIT: %s%s\n", chan.xit>0?"+":"", freqbuf);
|
printf("XIT: %s%s\n", chan.xit > 0 ? "+" : "", freqbuf);
|
||||||
printf("CTCSS: %d.%dHz\n", chan.ctcss_tone/10, chan.ctcss_tone%10);
|
printf("CTCSS: %d.%dHz\n", chan.ctcss_tone / 10, chan.ctcss_tone % 10);
|
||||||
printf("CTCSSsql: %d.%dHz\n", chan.ctcss_sql/10, chan.ctcss_sql%10);
|
printf("CTCSSsql: %d.%dHz\n", chan.ctcss_sql / 10, chan.ctcss_sql % 10);
|
||||||
printf("DCS: %d.%d\n", chan.dcs_code/10, chan.dcs_code%10);
|
printf("DCS: %d.%d\n", chan.dcs_code / 10, chan.dcs_code % 10);
|
||||||
printf("DCSsql: %d.%d\n", chan.dcs_sql/10, chan.dcs_sql%10);
|
printf("DCSsql: %d.%d\n", chan.dcs_sql / 10, chan.dcs_sql % 10);
|
||||||
printf("Name: %s\n", chan.channel_desc);
|
printf("Name: %s\n", chan.channel_desc);
|
||||||
|
|
||||||
printf("Functions: ");
|
printf("Functions: ");
|
||||||
if (chan.funcs!=0) {
|
|
||||||
if (chan.funcs&RIG_FUNC_FAGC) printf("FAGC ");
|
|
||||||
if (chan.funcs&RIG_FUNC_NB) printf("NB ");
|
|
||||||
if (chan.funcs&RIG_FUNC_COMP) printf("COMP ");
|
|
||||||
if (chan.funcs&RIG_FUNC_VOX) printf("VOX ");
|
|
||||||
if (chan.funcs&RIG_FUNC_TONE) printf("TONE ");
|
|
||||||
if (chan.funcs&RIG_FUNC_TSQL) printf("TSQL ");
|
|
||||||
if (chan.funcs&RIG_FUNC_SBKIN) printf("SBKIN ");
|
|
||||||
if (chan.funcs&RIG_FUNC_FBKIN) printf("FBKIN ");
|
|
||||||
if (chan.funcs&RIG_FUNC_ANF) printf("ANF ");
|
|
||||||
if (chan.funcs&RIG_FUNC_NR) printf("NR ");
|
|
||||||
if (chan.funcs&RIG_FUNC_AIP) printf("AIP ");
|
|
||||||
if (chan.funcs&RIG_FUNC_APF) printf("APF ");
|
|
||||||
if (chan.funcs&RIG_FUNC_MON) printf("MON ");
|
|
||||||
if (chan.funcs&RIG_FUNC_MN) printf("MN ");
|
|
||||||
if (chan.funcs&RIG_FUNC_RF) printf("RF ");
|
|
||||||
printf("\n");
|
|
||||||
} else
|
|
||||||
printf("none\n");
|
|
||||||
|
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_PREAMP))
|
if (chan.funcs != 0) {
|
||||||
printf("PREAMP: %ddB\n",chan.levels[rig_setting2idx(RIG_LEVEL_PREAMP)].i);
|
if (chan.funcs & RIG_FUNC_FAGC) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_ATT))
|
printf("FAGC ");
|
||||||
printf("ATT: %ddB\n",chan.levels[rig_setting2idx(RIG_LEVEL_ATT)].i);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_AF))
|
|
||||||
printf("AF: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_AF)].f);
|
if (chan.funcs & RIG_FUNC_NB) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_RF))
|
printf("NB ");
|
||||||
printf("RF: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_RF)].f);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_SQL))
|
|
||||||
printf("SQL: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_SQL)].f);
|
if (chan.funcs & RIG_FUNC_COMP) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_IF))
|
printf("COMP ");
|
||||||
printf("IF: %dHz\n",chan.levels[rig_setting2idx(RIG_LEVEL_IF)].i);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_APF))
|
|
||||||
printf("APF: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_APF)].f);
|
if (chan.funcs & RIG_FUNC_VOX) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_NR))
|
printf("VOX ");
|
||||||
printf("NR: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_NR)].f);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_PBT_IN))
|
|
||||||
printf("PBT_IN: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_PBT_IN)].f);
|
if (chan.funcs & RIG_FUNC_TONE) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_PBT_OUT))
|
printf("TONE ");
|
||||||
printf("PBT_OUT: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_PBT_OUT)].f);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_CWPITCH))
|
|
||||||
printf("CWPITCH: %dHz\n",chan.levels[rig_setting2idx(RIG_LEVEL_CWPITCH)].i);
|
if (chan.funcs & RIG_FUNC_TSQL) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_RFPOWER))
|
printf("TSQL ");
|
||||||
printf("RFPOWER: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_RFPOWER)].f);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_MICGAIN))
|
|
||||||
printf("MICGAIN: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_MICGAIN)].f);
|
if (chan.funcs & RIG_FUNC_SBKIN) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_COMP))
|
printf("SBKIN ");
|
||||||
printf("COMP: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_COMP)].f);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_BALANCE))
|
|
||||||
printf("BALANCE: %g%%\n",100*chan.levels[rig_setting2idx(RIG_LEVEL_BALANCE)].f);
|
if (chan.funcs & RIG_FUNC_FBKIN) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_KEYSPD))
|
printf("FBKIN ");
|
||||||
printf("KEYSPD: %d\n",chan.levels[rig_setting2idx(RIG_LEVEL_KEYSPD)].i);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_NOTCHF))
|
|
||||||
printf("NOTCHF: %d\n",chan.levels[rig_setting2idx(RIG_LEVEL_NOTCHF)].i);
|
if (chan.funcs & RIG_FUNC_ANF) {
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_AGC))
|
printf("ANF ");
|
||||||
printf("AGC: %d\n",chan.levels[rig_setting2idx(RIG_LEVEL_AGC)].i);
|
}
|
||||||
if (rig_has_set_level(rig, RIG_LEVEL_BKINDL))
|
|
||||||
printf("BKINDL: %d\n",chan.levels[rig_setting2idx(RIG_LEVEL_BKINDL)].i);
|
if (chan.funcs & RIG_FUNC_NR) {
|
||||||
|
printf("NR ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan.funcs & RIG_FUNC_AIP) {
|
||||||
|
printf("AIP ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan.funcs & RIG_FUNC_APF) {
|
||||||
|
printf("APF ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan.funcs & RIG_FUNC_MON) {
|
||||||
|
printf("MON ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan.funcs & RIG_FUNC_MN) {
|
||||||
|
printf("MN ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan.funcs & RIG_FUNC_RF) {
|
||||||
|
printf("RF ");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
printf("none\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_PREAMP)) {
|
||||||
|
printf("PREAMP: %ddB\n", chan.levels[rig_setting2idx(RIG_LEVEL_PREAMP)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_ATT)) {
|
||||||
|
printf("ATT: %ddB\n", chan.levels[rig_setting2idx(RIG_LEVEL_ATT)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_AF)) {
|
||||||
|
printf("AF: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_AF)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_RF)) {
|
||||||
|
printf("RF: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_RF)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_SQL)) {
|
||||||
|
printf("SQL: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_SQL)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_IF)) {
|
||||||
|
printf("IF: %dHz\n", chan.levels[rig_setting2idx(RIG_LEVEL_IF)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_APF)) {
|
||||||
|
printf("APF: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_APF)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_NR)) {
|
||||||
|
printf("NR: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_NR)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_PBT_IN)) {
|
||||||
|
printf("PBT_IN: %g%%\n",
|
||||||
|
100 * chan.levels[rig_setting2idx(RIG_LEVEL_PBT_IN)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_PBT_OUT)) {
|
||||||
|
printf("PBT_OUT: %g%%\n",
|
||||||
|
100 * chan.levels[rig_setting2idx(RIG_LEVEL_PBT_OUT)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_CWPITCH)) {
|
||||||
|
printf("CWPITCH: %dHz\n", chan.levels[rig_setting2idx(RIG_LEVEL_CWPITCH)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_RFPOWER)) {
|
||||||
|
printf("RFPOWER: %g%%\n",
|
||||||
|
100 * chan.levels[rig_setting2idx(RIG_LEVEL_RFPOWER)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_MICGAIN)) {
|
||||||
|
printf("MICGAIN: %g%%\n",
|
||||||
|
100 * chan.levels[rig_setting2idx(RIG_LEVEL_MICGAIN)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_COMP)) {
|
||||||
|
printf("COMP: %g%%\n", 100 * chan.levels[rig_setting2idx(RIG_LEVEL_COMP)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_BALANCE)) {
|
||||||
|
printf("BALANCE: %g%%\n",
|
||||||
|
100 * chan.levels[rig_setting2idx(RIG_LEVEL_BALANCE)].f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_KEYSPD)) {
|
||||||
|
printf("KEYSPD: %d\n", chan.levels[rig_setting2idx(RIG_LEVEL_KEYSPD)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_NOTCHF)) {
|
||||||
|
printf("NOTCHF: %d\n", chan.levels[rig_setting2idx(RIG_LEVEL_NOTCHF)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_AGC)) {
|
||||||
|
printf("AGC: %d\n", chan.levels[rig_setting2idx(RIG_LEVEL_AGC)].i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_has_set_level(rig, RIG_LEVEL_BKINDL)) {
|
||||||
|
printf("BKINDL: %d\n", chan.levels[rig_setting2idx(RIG_LEVEL_BKINDL)].i);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
#include <hamlib/riglist.h>
|
#include <hamlib/riglist.h>
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
RIG *my_rig;
|
RIG *my_rig;
|
||||||
char *rig_file, *info_buf, *mm;
|
char *rig_file, *info_buf, *mm;
|
||||||
freq_t freq;
|
freq_t freq;
|
||||||
|
@ -23,58 +25,105 @@ int main() {
|
||||||
rmode_t mode;
|
rmode_t mode;
|
||||||
pbwidth_t width;
|
pbwidth_t width;
|
||||||
|
|
||||||
/* Set verbosity level */
|
/* Set verbosity level */
|
||||||
rig_set_debug(RIG_DEBUG_ERR); // errors only
|
rig_set_debug(RIG_DEBUG_ERR); // errors only
|
||||||
/* Instantiate a rig */
|
|
||||||
|
/* Instantiate a rig */
|
||||||
my_rig = rig_init(RIG_MODEL_TT565); // your rig model.
|
my_rig = rig_init(RIG_MODEL_TT565); // your rig model.
|
||||||
/* Set up serial port, baud rate */
|
|
||||||
|
/* Set up serial port, baud rate */
|
||||||
rig_file = "/dev/ttyUSB0"; // your serial device
|
rig_file = "/dev/ttyUSB0"; // your serial device
|
||||||
|
|
||||||
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
|
||||||
my_rig->state.rigport.parm.serial.rate = 57600; // your baud rate
|
my_rig->state.rigport.parm.serial.rate = 57600; // your baud rate
|
||||||
/* Open my rig */
|
|
||||||
|
/* Open my rig */
|
||||||
retcode = rig_open(my_rig);
|
retcode = rig_open(my_rig);
|
||||||
/* Give me ID info, e.g., firmware version. */
|
|
||||||
|
/* Give me ID info, e.g., firmware version. */
|
||||||
info_buf = (char *)rig_get_info(my_rig);
|
info_buf = (char *)rig_get_info(my_rig);
|
||||||
|
|
||||||
printf("Rig_info: '%s'\n", info_buf);
|
printf("Rig_info: '%s'\n", info_buf);
|
||||||
|
|
||||||
/* Note: As a general practice, we should check to see if a given
|
/* Note: As a general practice, we should check to see if a given
|
||||||
* function is within the rig's capabilities before calling it, but
|
* function is within the rig's capabilities before calling it, but
|
||||||
* we are simplifying here. Also, we should check each call's returned
|
* we are simplifying here. Also, we should check each call's returned
|
||||||
* status in case of error. (That's an inelegant way to catch an unsupported
|
* status in case of error. (That's an inelegant way to catch an unsupported
|
||||||
* operation.)
|
* operation.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Main VFO frequency */
|
/* Main VFO frequency */
|
||||||
status = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
status = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
||||||
|
|
||||||
printf("VFO freq. = %.1f Hz\n", freq);
|
printf("VFO freq. = %.1f Hz\n", freq);
|
||||||
/* Current mode */
|
|
||||||
|
/* Current mode */
|
||||||
status = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width);
|
status = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width);
|
||||||
switch(mode) {
|
|
||||||
case RIG_MODE_USB: mm = "USB"; break;
|
switch (mode) {
|
||||||
case RIG_MODE_LSB: mm = "LSB"; break;
|
case RIG_MODE_USB:
|
||||||
case RIG_MODE_CW: mm = "CW"; break;
|
mm = "USB";
|
||||||
case RIG_MODE_CWR: mm = "CWR"; break;
|
break;
|
||||||
case RIG_MODE_AM: mm = "AM"; break;
|
|
||||||
case RIG_MODE_FM: mm = "FM"; break;
|
case RIG_MODE_LSB:
|
||||||
case RIG_MODE_WFM: mm = "WFM"; break;
|
mm = "LSB";
|
||||||
case RIG_MODE_RTTY:mm = "RTTY"; break;
|
break;
|
||||||
default: mm = "unrecognized"; break; /* there are more possibilities! */
|
|
||||||
|
case RIG_MODE_CW:
|
||||||
|
mm = "CW";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_CWR:
|
||||||
|
mm = "CWR";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_AM:
|
||||||
|
mm = "AM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_FM:
|
||||||
|
mm = "FM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_WFM:
|
||||||
|
mm = "WFM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_RTTY:
|
||||||
|
mm = "RTTY";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
mm = "unrecognized";
|
||||||
|
break; /* there are more possibilities! */
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Current mode = 0x%X = %s, width = %d\n", mode, mm, width);
|
printf("Current mode = 0x%X = %s, width = %d\n", mode, mm, width);
|
||||||
/* rig power output */
|
|
||||||
|
/* rig power output */
|
||||||
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &power);
|
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &power);
|
||||||
|
|
||||||
printf("RF Power relative setting = %.3f (0.0 - 1.0)\n", power.f);
|
printf("RF Power relative setting = %.3f (0.0 - 1.0)\n", power.f);
|
||||||
/* Convert power reading to watts */
|
|
||||||
|
/* Convert power reading to watts */
|
||||||
status = rig_power2mW(my_rig, &mwpower, power.f, freq, mode);
|
status = rig_power2mW(my_rig, &mwpower, power.f, freq, mode);
|
||||||
printf("RF Power calibrated = %.1f Watts\n", mwpower/1000.);
|
|
||||||
/* Raw and calibrated S-meter values */
|
printf("RF Power calibrated = %.1f Watts\n", mwpower / 1000.);
|
||||||
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RAWSTR,
|
|
||||||
&rawstrength);
|
/* Raw and calibrated S-meter values */
|
||||||
|
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RAWSTR, &rawstrength);
|
||||||
|
|
||||||
printf("Raw receive strength = %d\n", rawstrength.i);
|
printf("Raw receive strength = %d\n", rawstrength.i);
|
||||||
|
|
||||||
isz = my_rig->caps->str_cal.size;
|
isz = my_rig->caps->str_cal.size;
|
||||||
|
|
||||||
s_meter = rig_raw2val(rawstrength.i, &my_rig->caps->str_cal);
|
s_meter = rig_raw2val(rawstrength.i, &my_rig->caps->str_cal);
|
||||||
|
|
||||||
printf("S-meter value = %.2f dB relative to S9\n", s_meter);
|
printf("S-meter value = %.2f dB relative to S9\n", s_meter);
|
||||||
|
|
||||||
/* now try using RIG_LEVEL_STRENGTH itself */
|
/* now try using RIG_LEVEL_STRENGTH itself */
|
||||||
status = rig_get_strength(my_rig, RIG_VFO_CURR, &strength);
|
status = rig_get_strength(my_rig, RIG_VFO_CURR, &strength);
|
||||||
|
|
||||||
printf("LEVEL_STRENGTH returns %d\n", strength.i);
|
printf("LEVEL_STRENGTH returns %d\n", strength.i);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,59 +30,73 @@
|
||||||
int print_caps_sum(const struct rig_caps *caps, void *data)
|
int print_caps_sum(const struct rig_caps *caps, void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("%d\t%-10s\t%-12s\t%s\t",caps->rig_model,caps->mfg_name,
|
printf("%d\t%-10s\t%-12s\t%s\t",
|
||||||
caps->model_name, caps->version);
|
caps->rig_model,
|
||||||
|
caps->mfg_name,
|
||||||
|
caps->model_name,
|
||||||
|
caps->version);
|
||||||
|
|
||||||
printf("%-10s\t", rig_strstatus(caps->status));
|
printf("%-10s\t", rig_strstatus(caps->status));
|
||||||
|
|
||||||
switch (caps->rig_type & RIG_TYPE_MASK) {
|
switch (caps->rig_type & RIG_TYPE_MASK) {
|
||||||
case RIG_TYPE_TRANSCEIVER:
|
case RIG_TYPE_TRANSCEIVER:
|
||||||
printf("Transceiver\n");
|
printf("Transceiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_HANDHELD:
|
case RIG_TYPE_HANDHELD:
|
||||||
printf("Handheld\n");
|
printf("Handheld\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_MOBILE:
|
case RIG_TYPE_MOBILE:
|
||||||
printf("Mobile\n");
|
printf("Mobile\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_RECEIVER:
|
case RIG_TYPE_RECEIVER:
|
||||||
printf("Receiver\n");
|
printf("Receiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_PCRECEIVER:
|
case RIG_TYPE_PCRECEIVER:
|
||||||
printf("PC Receiver\n");
|
printf("PC Receiver\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_SCANNER:
|
case RIG_TYPE_SCANNER:
|
||||||
printf("Scanner\n");
|
printf("Scanner\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_TRUNKSCANNER:
|
case RIG_TYPE_TRUNKSCANNER:
|
||||||
printf("Trunking scanner\n");
|
printf("Trunking scanner\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_COMPUTER:
|
case RIG_TYPE_COMPUTER:
|
||||||
printf("Computer\n");
|
printf("Computer\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_OTHER:
|
case RIG_TYPE_OTHER:
|
||||||
printf("Other\n");
|
printf("Other\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown\n");
|
printf("Unknown\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1; /* !=0, we want them all ! */
|
return -1; /* !=0, we want them all ! */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
rig_load_all_backends();
|
rig_load_all_backends();
|
||||||
|
|
||||||
printf("Rig#\tMfg \tModel \tVers.\tStatus \tType\n");
|
printf("Rig#\tMfg \tModel \tVers.\tStatus \tType\n");
|
||||||
status = rig_list_foreach(print_caps_sum,NULL);
|
|
||||||
if (status != RIG_OK ) {
|
status = rig_list_foreach(print_caps_sum, NULL);
|
||||||
|
|
||||||
|
if (status != RIG_OK) {
|
||||||
printf("rig_list_foreach: error = %s \n", rigerror(status));
|
printf("rig_list_foreach: error = %s \n", rigerror(status));
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
567
tests/memcsv.c
567
tests/memcsv.c
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -50,39 +50,59 @@ char csv_sep = ','; /* CSV separator */
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
static int dump_csv_chan(RIG *rig, channel_t **chan, int channel_num, const chan_t *chan_list, rig_ptr_t arg);
|
static int dump_csv_chan(RIG *rig,
|
||||||
|
channel_t **chan,
|
||||||
|
int channel_num,
|
||||||
|
const chan_t *chan_list,
|
||||||
|
rig_ptr_t arg);
|
||||||
|
|
||||||
static void dump_csv_name(const channel_cap_t *mem_caps, FILE *f);
|
static void dump_csv_name(const channel_cap_t *mem_caps, FILE *f);
|
||||||
static int set_channel_data(RIG *rig, channel_t *chan, char **line_key, char **line_data);
|
|
||||||
static char* mystrtok( char *s, char delim );
|
|
||||||
static int tokenize_line( char *line, char **token_list, size_t siz, char delim );
|
|
||||||
static int find_on_list( char **list, char *what );
|
|
||||||
|
|
||||||
int csv_save (RIG *rig, const char *outfilename);
|
static int set_channel_data(RIG *rig,
|
||||||
int csv_load (RIG *rig, const char *infilename);
|
channel_t *chan,
|
||||||
int csv_parm_save (RIG *rig, const char *outfilename);
|
char **line_key,
|
||||||
int csv_parm_load (RIG *rig, const char *infilename);
|
char **line_data);
|
||||||
|
|
||||||
|
static char * mystrtok(char *s, char delim);
|
||||||
|
|
||||||
|
static int tokenize_line(char *line,
|
||||||
|
char **token_list,
|
||||||
|
size_t siz,
|
||||||
|
char delim);
|
||||||
|
|
||||||
|
static int find_on_list(char **list, char *what);
|
||||||
|
|
||||||
|
int csv_save(RIG *rig, const char *outfilename);
|
||||||
|
int csv_load(RIG *rig, const char *infilename);
|
||||||
|
|
||||||
|
int csv_parm_save(RIG *rig, const char *outfilename);
|
||||||
|
int csv_parm_load(RIG *rig, const char *infilename);
|
||||||
|
|
||||||
|
|
||||||
|
int csv_save(RIG *rig, const char *outfilename)
|
||||||
int csv_save (RIG *rig, const char *outfilename)
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(outfilename, "w");
|
f = fopen(outfilename, "w");
|
||||||
if (!f)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (rig->caps->clone_combo_get)
|
if (!f) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig->caps->clone_combo_get) {
|
||||||
printf("About to save data, enter cloning mode: %s\n",
|
printf("About to save data, enter cloning mode: %s\n",
|
||||||
rig->caps->clone_combo_get);
|
rig->caps->clone_combo_get);
|
||||||
|
}
|
||||||
|
|
||||||
status = rig_get_chan_all_cb (rig, dump_csv_chan, f);
|
status = rig_get_chan_all_cb(rig, dump_csv_chan, f);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** csv_load assumes the first line in a csv file is a key line,
|
/** csv_load assumes the first line in a csv file is a key line,
|
||||||
defining entries and their number. First line should not
|
defining entries and their number. First line should not
|
||||||
contain 'empty column', i.e. two adjacent commas.
|
contain 'empty column', i.e. two adjacent commas.
|
||||||
|
@ -91,7 +111,7 @@ int csv_save (RIG *rig, const char *outfilename)
|
||||||
\param rig - a pointer to the rig
|
\param rig - a pointer to the rig
|
||||||
\param infilename - a string with a file name to write to
|
\param infilename - a string with a file name to write to
|
||||||
*/
|
*/
|
||||||
int csv_load (RIG *rig, const char *infilename)
|
int csv_load(RIG *rig, const char *infilename)
|
||||||
{
|
{
|
||||||
int status = RIG_OK;
|
int status = RIG_OK;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -102,51 +122,65 @@ int csv_load (RIG *rig, const char *infilename)
|
||||||
channel_t chan;
|
channel_t chan;
|
||||||
|
|
||||||
f = fopen(infilename, "r");
|
f = fopen(infilename, "r");
|
||||||
if (!f) return -1;
|
|
||||||
|
if (!f) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* First read the first line, containing the key */
|
/* First read the first line, containing the key */
|
||||||
if( fgets( keys, sizeof( keys ), f ) != NULL ){
|
if (fgets(keys, sizeof(keys), f) != NULL) {
|
||||||
|
|
||||||
/* fgets stores '\n' in a buffer, get rid of it */
|
/* fgets stores '\n' in a buffer, get rid of it */
|
||||||
keys[ strlen( keys )-1 ] = '\0';
|
keys[ strlen(keys) - 1 ] = '\0';
|
||||||
printf("Read the key: %s\n", keys );
|
printf("Read the key: %s\n", keys);
|
||||||
|
|
||||||
/* Tokenize the key list */
|
/* Tokenize the key list */
|
||||||
if( !tokenize_line( keys, key_list, sizeof(key_list)/sizeof(char*), ',' ) ){
|
if (!tokenize_line(keys,
|
||||||
fprintf( stderr, "Invalid (possibly too long or empty) key line, cannot continue.\n" );
|
key_list,
|
||||||
|
sizeof(key_list) / sizeof(char *),
|
||||||
|
',')) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Invalid (possibly too long or empty) key line, cannot continue.\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
/* File exists, but is empty */
|
/* File exists, but is empty */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next, read the file line by line */
|
/* Next, read the file line by line */
|
||||||
while ( fgets ( line, sizeof line, f ) != NULL ){
|
while (fgets(line, sizeof line, f) != NULL) {
|
||||||
/* Tokenize the line */
|
/* Tokenize the line */
|
||||||
if( !tokenize_line( line, value_list, sizeof(value_list)/sizeof(char*), ',' ) ){
|
if (!tokenize_line(line,
|
||||||
fprintf( stderr, "Invalid (possibly too long or empty) line ignored\n" );
|
value_list,
|
||||||
|
sizeof(value_list) / sizeof(char *),
|
||||||
|
',')) {
|
||||||
|
|
||||||
|
fprintf(stderr, "Invalid (possibly too long or empty) line ignored\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a line, write channel data into chan */
|
/* Parse a line, write channel data into chan */
|
||||||
set_channel_data( rig, &chan, key_list, value_list );
|
set_channel_data(rig, &chan, key_list, value_list);
|
||||||
|
|
||||||
/* Write a rig memory */
|
/* Write a rig memory */
|
||||||
status=rig_set_channel(rig, &chan);
|
status = rig_set_channel(rig, &chan);
|
||||||
|
|
||||||
if (status != RIG_OK ) {
|
if (status != RIG_OK) {
|
||||||
fprintf( stderr, "rig_get_channel: error = %s \n", rigerror(status));
|
fprintf(stderr, "rig_get_channel: error = %s \n", rigerror(status));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
fclose( f );
|
|
||||||
|
fclose(f);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Function to break a line into a list of tokens. Delimiters are
|
/** Function to break a line into a list of tokens. Delimiters are
|
||||||
replaced by end-of-string characters ('\0'), and a list of pointers
|
replaced by end-of-string characters ('\0'), and a list of pointers
|
||||||
to thus created substrings is created.
|
to thus created substrings is created.
|
||||||
|
@ -159,44 +193,54 @@ int csv_load (RIG *rig, const char *infilename)
|
||||||
\return number of tokens on success, 0 if \param token_list is too small to contain all the tokens,
|
\return number of tokens on success, 0 if \param token_list is too small to contain all the tokens,
|
||||||
or if line was empty.
|
or if line was empty.
|
||||||
*/
|
*/
|
||||||
static int tokenize_line( char *line, char **token_list, size_t siz, char delim ){
|
static int tokenize_line(char *line, char **token_list, size_t siz, char delim)
|
||||||
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char *tok;
|
char *tok;
|
||||||
|
|
||||||
// printf("Starting tokenizer, line pointer %x, list pointer %x, list size = %d...", line, token_list, siz);
|
|
||||||
/* Erase the table */
|
/* Erase the table */
|
||||||
for( i = 0; i < siz; i++ ){
|
for (i = 0; i < siz; i++) {
|
||||||
token_list[i] = NULL;
|
token_list[i] = NULL;
|
||||||
}
|
}
|
||||||
// printf(", list emptied!\n");
|
|
||||||
/* Empty line passed? */
|
/* Empty line passed? */
|
||||||
if( line == NULL ) return 0;
|
if (line == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Reinitialize, find the first token */
|
/* Reinitialize, find the first token */
|
||||||
i = 0;
|
i = 0;
|
||||||
tok = mystrtok( line, delim );
|
tok = mystrtok(line, delim);
|
||||||
|
|
||||||
/* Line contains no delim */
|
/* Line contains no delim */
|
||||||
if( tok == NULL ) return 0;
|
if (tok == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
token_list[ i++ ] = tok;
|
token_list[ i++ ] = tok;
|
||||||
// printf("First token is: %s\n", tok);
|
|
||||||
|
|
||||||
/* Find the remaining tokens */
|
/* Find the remaining tokens */
|
||||||
while( i < siz ){
|
while (i < siz) {
|
||||||
tok = mystrtok( NULL, delim );
|
tok = mystrtok(NULL, delim);
|
||||||
// printf("Next token: %s\n", tok );
|
|
||||||
/* If NULL, no more tokens left */
|
/* If NULL, no more tokens left */
|
||||||
if(tok == NULL) break;
|
if (tok == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add token to the list */
|
/* Add token to the list */
|
||||||
token_list[ i++ ] = tok;
|
token_list[ i++ ] = tok;
|
||||||
}
|
}
|
||||||
// printf("Finished tokenizing, i = %d, siz = %d\n", i, siz);
|
|
||||||
/* Any tokens left? */
|
/* Any tokens left? */
|
||||||
if( i == siz ){
|
if (i == siz) {
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
} else {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Tokenizer that handles two delimiters by returning an empty string.
|
/** Tokenizer that handles two delimiters by returning an empty string.
|
||||||
First param (input) is a string to be tokenized, second is a delimiter (input)
|
First param (input) is a string to be tokenized, second is a delimiter (input)
|
||||||
This tokenizer accepts only one delimiter!
|
This tokenizer accepts only one delimiter!
|
||||||
|
@ -205,75 +249,95 @@ static int tokenize_line( char *line, char **token_list, size_t siz, char delim
|
||||||
\return pointer to token, or NULL if there are no more tokens
|
\return pointer to token, or NULL if there are no more tokens
|
||||||
\sa "man strtok"
|
\sa "man strtok"
|
||||||
*/
|
*/
|
||||||
static char* mystrtok( char *s, char delim ){
|
static char * mystrtok(char *s, char delim)
|
||||||
|
{
|
||||||
static size_t pos = 0, length = 0;
|
static size_t pos = 0, length = 0;
|
||||||
static char *str = 0;
|
static char *str = 0;
|
||||||
if( s != NULL ){
|
|
||||||
|
if (s != NULL) {
|
||||||
str = s;
|
str = s;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
length = strlen( str );
|
length = strlen(str);
|
||||||
}else{
|
} else {
|
||||||
}
|
}
|
||||||
if( str[ pos+1 ] == '\0' ) return NULL;
|
|
||||||
size_t i,ent_pos = pos;
|
if (str[ pos + 1 ] == '\0') {
|
||||||
for( i = pos; i < length; ){
|
return NULL;
|
||||||
if( str[i] == delim ){
|
}
|
||||||
|
|
||||||
|
size_t i, ent_pos = pos;
|
||||||
|
|
||||||
|
for (i = pos; i < length;) {
|
||||||
|
if (str[i] == delim) {
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
pos = i+1;
|
pos = i + 1;
|
||||||
return str+ent_pos;
|
return str + ent_pos;
|
||||||
}else{
|
} else {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str + ent_pos;
|
return str + ent_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int print_parm_name(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
|
|
||||||
|
static int print_parm_name(RIG *rig,
|
||||||
|
const struct confparams *cfp,
|
||||||
|
rig_ptr_t ptr)
|
||||||
{
|
{
|
||||||
fprintf((FILE*)ptr, "%s%c", cfp->name, csv_sep);
|
fprintf((FILE *)ptr, "%s%c", cfp->name, csv_sep);
|
||||||
|
|
||||||
return 1; /* process them all */
|
return 1; /* process them all */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int print_parm_val(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
|
static int print_parm_val(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
|
||||||
{
|
{
|
||||||
value_t val;
|
value_t val;
|
||||||
FILE *f=(FILE*)ptr;
|
FILE *f = (FILE *)ptr;
|
||||||
rig_get_ext_parm(rig, cfp->token, &val);
|
rig_get_ext_parm(rig, cfp->token, &val);
|
||||||
|
|
||||||
switch (cfp->type) {
|
switch (cfp->type) {
|
||||||
case RIG_CONF_CHECKBUTTON:
|
case RIG_CONF_CHECKBUTTON:
|
||||||
case RIG_CONF_COMBO:
|
case RIG_CONF_COMBO:
|
||||||
fprintf(f,"%d%c", val.i, csv_sep);
|
fprintf(f, "%d%c", val.i, csv_sep);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
fprintf(f,"%f%c", val.f, csv_sep);
|
fprintf(f, "%f%c", val.f, csv_sep);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_STRING:
|
case RIG_CONF_STRING:
|
||||||
fprintf(f,"%s%c", val.s, csv_sep);
|
fprintf(f, "%s%c", val.s, csv_sep);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(f,"unknown%c", csv_sep);
|
fprintf(f, "unknown%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1; /* process them all */
|
return 1; /* process them all */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int csv_parm_save (RIG *rig, const char *outfilename)
|
int csv_parm_save(RIG *rig, const char *outfilename)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
setting_t parm, get_parm = all ? 0x7fffffff : rig->state.has_get_parm;
|
setting_t parm, get_parm = all ? 0x7fffffff : rig->state.has_get_parm;
|
||||||
|
|
||||||
f = fopen(outfilename, "w");
|
f = fopen(outfilename, "w");
|
||||||
if (!f)
|
|
||||||
|
if (!f) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms = rig_strparm(get_parm & rig_idx2setting(i));
|
const char *ms = rig_strparm(get_parm & rig_idx2setting(i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(f, "%s%c", ms, csv_sep);
|
fprintf(f, "%s%c", ms, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,17 +351,22 @@ int csv_parm_save (RIG *rig, const char *outfilename)
|
||||||
parm = get_parm & rig_idx2setting(i);
|
parm = get_parm & rig_idx2setting(i);
|
||||||
ms = rig_strparm(parm);
|
ms = rig_strparm(parm);
|
||||||
|
|
||||||
if (!ms || !ms[0])
|
if (!ms || !ms[0]) {
|
||||||
continue;
|
continue;
|
||||||
ret = rig_get_parm(rig, parm, &val);
|
}
|
||||||
if (ret != RIG_OK)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (RIG_PARM_IS_FLOAT(parm))
|
ret = rig_get_parm(rig, parm, &val);
|
||||||
|
|
||||||
|
if (ret != RIG_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RIG_PARM_IS_FLOAT(parm)) {
|
||||||
fprintf(f, "%f%c", val.f, csv_sep);
|
fprintf(f, "%f%c", val.f, csv_sep);
|
||||||
else
|
} else {
|
||||||
fprintf(f, "%d%c", val.i, csv_sep);
|
fprintf(f, "%d%c", val.i, csv_sep);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rig_ext_parm_foreach(rig, print_parm_val, f);
|
rig_ext_parm_foreach(rig, print_parm_val, f);
|
||||||
|
@ -307,7 +376,8 @@ int csv_parm_save (RIG *rig, const char *outfilename)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int csv_parm_load (RIG *rig, const char *infilename)
|
|
||||||
|
int csv_parm_load(RIG *rig, const char *infilename)
|
||||||
{
|
{
|
||||||
return -RIG_ENIMPL;
|
return -RIG_ENIMPL;
|
||||||
/* for every parm/ext_parm, fscanf, parse, set_parm's */
|
/* for every parm/ext_parm, fscanf, parse, set_parm's */
|
||||||
|
@ -328,78 +398,105 @@ void dump_csv_name(const channel_cap_t *mem_caps, FILE *f)
|
||||||
if (mem_caps->channel_desc) {
|
if (mem_caps->channel_desc) {
|
||||||
fprintf(f, "channel_desc%c", csv_sep);
|
fprintf(f, "channel_desc%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->vfo) {
|
if (mem_caps->vfo) {
|
||||||
fprintf(f, "vfo%c", csv_sep);
|
fprintf(f, "vfo%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ant) {
|
if (mem_caps->ant) {
|
||||||
fprintf(f, "ant%c", csv_sep);
|
fprintf(f, "ant%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->freq) {
|
if (mem_caps->freq) {
|
||||||
fprintf(f, "freq%c", csv_sep);
|
fprintf(f, "freq%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->mode) {
|
if (mem_caps->mode) {
|
||||||
fprintf(f, "mode%c", csv_sep);
|
fprintf(f, "mode%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->width) {
|
if (mem_caps->width) {
|
||||||
fprintf(f, "width%c", csv_sep);
|
fprintf(f, "width%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_freq) {
|
if (mem_caps->tx_freq) {
|
||||||
fprintf(f, "tx_freq%c", csv_sep);
|
fprintf(f, "tx_freq%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_mode) {
|
if (mem_caps->tx_mode) {
|
||||||
fprintf(f, "tx_mode%c", csv_sep);
|
fprintf(f, "tx_mode%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_width) {
|
if (mem_caps->tx_width) {
|
||||||
fprintf(f, "tx_width%c", csv_sep);
|
fprintf(f, "tx_width%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->split) {
|
if (mem_caps->split) {
|
||||||
fprintf(f, "split%c", csv_sep);
|
fprintf(f, "split%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_vfo) {
|
if (mem_caps->tx_vfo) {
|
||||||
fprintf(f, "tx_vfo%c", csv_sep);
|
fprintf(f, "tx_vfo%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rptr_shift) {
|
if (mem_caps->rptr_shift) {
|
||||||
fprintf(f, "rptr_shift%c", csv_sep);
|
fprintf(f, "rptr_shift%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rptr_offs) {
|
if (mem_caps->rptr_offs) {
|
||||||
fprintf(f, "rptr_offs%c", csv_sep);
|
fprintf(f, "rptr_offs%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tuning_step) {
|
if (mem_caps->tuning_step) {
|
||||||
fprintf(f, "tuning_step%c", csv_sep);
|
fprintf(f, "tuning_step%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rit) {
|
if (mem_caps->rit) {
|
||||||
fprintf(f, "rit%c", csv_sep);
|
fprintf(f, "rit%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->xit) {
|
if (mem_caps->xit) {
|
||||||
fprintf(f, "xit%c", csv_sep);
|
fprintf(f, "xit%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->funcs) {
|
if (mem_caps->funcs) {
|
||||||
fprintf(f, "funcs%c", csv_sep);
|
fprintf(f, "funcs%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_tone) {
|
if (mem_caps->ctcss_tone) {
|
||||||
fprintf(f, "ctcss_tone%c", csv_sep);
|
fprintf(f, "ctcss_tone%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_sql) {
|
if (mem_caps->ctcss_sql) {
|
||||||
fprintf(f, "ctcss_sql%c", csv_sep);
|
fprintf(f, "ctcss_sql%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_code) {
|
if (mem_caps->dcs_code) {
|
||||||
fprintf(f, "dcs_code%c", csv_sep);
|
fprintf(f, "dcs_code%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_sql) {
|
if (mem_caps->dcs_sql) {
|
||||||
fprintf(f, "dcs_sql%c", csv_sep);
|
fprintf(f, "dcs_sql%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->scan_group) {
|
if (mem_caps->scan_group) {
|
||||||
fprintf(f, "scan_group%c", csv_sep);
|
fprintf(f, "scan_group%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->flags) {
|
if (mem_caps->flags) {
|
||||||
fprintf(f, "flags%c", csv_sep);
|
fprintf(f, "flags%c", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Caution! Keep the function consistent with dump_csv_name and set_channel_data! */
|
/* Caution! Keep the function consistent with dump_csv_name and set_channel_data! */
|
||||||
int dump_csv_chan(RIG *rig, channel_t **chan_pp, int channel_num, const chan_t *chan_list, rig_ptr_t arg)
|
int dump_csv_chan(RIG *rig,
|
||||||
|
channel_t **chan_pp,
|
||||||
|
int channel_num,
|
||||||
|
const chan_t *chan_list,
|
||||||
|
rig_ptr_t arg)
|
||||||
{
|
{
|
||||||
FILE *f = arg;
|
FILE *f = arg;
|
||||||
static channel_t chan;
|
static channel_t chan;
|
||||||
|
@ -421,82 +518,105 @@ int dump_csv_chan(RIG *rig, channel_t **chan_pp, int channel_num, const chan_t *
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f,"%d%c",chan.channel_num, csv_sep);
|
fprintf(f, "%d%c", chan.channel_num, csv_sep);
|
||||||
|
|
||||||
if (mem_caps->bank_num) {
|
if (mem_caps->bank_num) {
|
||||||
fprintf(f,"%d%c",chan.bank_num, csv_sep);
|
fprintf(f, "%d%c", chan.bank_num, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->channel_desc) {
|
if (mem_caps->channel_desc) {
|
||||||
fprintf(f, "%s%c", chan.channel_desc, csv_sep);
|
fprintf(f, "%s%c", chan.channel_desc, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->vfo) {
|
if (mem_caps->vfo) {
|
||||||
fprintf(f,"%s%c",rig_strvfo(chan.vfo), csv_sep);
|
fprintf(f, "%s%c", rig_strvfo(chan.vfo), csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ant) {
|
if (mem_caps->ant) {
|
||||||
fprintf(f,"%d%c",chan.ant, csv_sep);
|
fprintf(f, "%d%c", chan.ant, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->freq) {
|
if (mem_caps->freq) {
|
||||||
fprintf(f,"%.0"PRIfreq"%c",chan.freq, csv_sep);
|
fprintf(f, "%.0"PRIfreq"%c", chan.freq, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->mode) {
|
if (mem_caps->mode) {
|
||||||
fprintf(f, "%s%c", rig_strrmode(chan.mode), csv_sep);
|
fprintf(f, "%s%c", rig_strrmode(chan.mode), csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->width) {
|
if (mem_caps->width) {
|
||||||
fprintf(f,"%d%c",(int)chan.width, csv_sep);
|
fprintf(f, "%d%c", (int)chan.width, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_freq) {
|
if (mem_caps->tx_freq) {
|
||||||
fprintf(f,"%.0"PRIfreq"%c",chan.tx_freq, csv_sep);
|
fprintf(f, "%.0"PRIfreq"%c", chan.tx_freq, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_mode) {
|
if (mem_caps->tx_mode) {
|
||||||
fprintf(f, "%s%c", rig_strrmode(chan.tx_mode), csv_sep);
|
fprintf(f, "%s%c", rig_strrmode(chan.tx_mode), csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_width) {
|
if (mem_caps->tx_width) {
|
||||||
fprintf(f,"%d%c",(int)chan.tx_width, csv_sep);
|
fprintf(f, "%d%c", (int)chan.tx_width, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->split) {
|
if (mem_caps->split) {
|
||||||
fprintf(f, "%s%c", chan.split==RIG_SPLIT_ON?"on":"off", csv_sep);
|
fprintf(f, "%s%c", chan.split == RIG_SPLIT_ON ? "on" : "off", csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_vfo) {
|
if (mem_caps->tx_vfo) {
|
||||||
fprintf(f,"%s%c",rig_strvfo(chan.tx_vfo), csv_sep);
|
fprintf(f, "%s%c", rig_strvfo(chan.tx_vfo), csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rptr_shift) {
|
if (mem_caps->rptr_shift) {
|
||||||
fprintf(f, "%s%c", rig_strptrshift(chan.rptr_shift), csv_sep);
|
fprintf(f, "%s%c", rig_strptrshift(chan.rptr_shift), csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rptr_offs) {
|
if (mem_caps->rptr_offs) {
|
||||||
fprintf(f,"%d%c",(int)chan.rptr_offs, csv_sep);
|
fprintf(f, "%d%c", (int)chan.rptr_offs, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tuning_step) {
|
if (mem_caps->tuning_step) {
|
||||||
fprintf(f,"%d%c",(int)chan.tuning_step, csv_sep);
|
fprintf(f, "%d%c", (int)chan.tuning_step, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rit) {
|
if (mem_caps->rit) {
|
||||||
fprintf(f,"%d%c",(int)chan.rit, csv_sep);
|
fprintf(f, "%d%c", (int)chan.rit, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->xit) {
|
if (mem_caps->xit) {
|
||||||
fprintf(f,"%d%c",(int)chan.xit, csv_sep);
|
fprintf(f, "%d%c", (int)chan.xit, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->funcs) {
|
if (mem_caps->funcs) {
|
||||||
fprintf(f,"%lx%c",chan.funcs, csv_sep);
|
fprintf(f, "%lx%c", chan.funcs, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_tone) {
|
if (mem_caps->ctcss_tone) {
|
||||||
fprintf(f,"%d%c",chan.ctcss_tone, csv_sep);
|
fprintf(f, "%d%c", chan.ctcss_tone, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_sql) {
|
if (mem_caps->ctcss_sql) {
|
||||||
fprintf(f,"%d%c",chan.ctcss_sql, csv_sep);
|
fprintf(f, "%d%c", chan.ctcss_sql, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_code) {
|
if (mem_caps->dcs_code) {
|
||||||
fprintf(f,"%d%c",chan.dcs_code, csv_sep);
|
fprintf(f, "%d%c", chan.dcs_code, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_sql) {
|
if (mem_caps->dcs_sql) {
|
||||||
fprintf(f,"%d%c",chan.dcs_sql, csv_sep);
|
fprintf(f, "%d%c", chan.dcs_sql, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->scan_group) {
|
if (mem_caps->scan_group) {
|
||||||
fprintf(f,"%d%c",chan.scan_group, csv_sep);
|
fprintf(f, "%d%c", chan.scan_group, csv_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->flags) {
|
if (mem_caps->flags) {
|
||||||
fprintf(f,"%x%c",chan.flags, csv_sep);
|
fprintf(f, "%x%c", chan.flags, csv_sep);
|
||||||
}
|
}
|
||||||
fprintf(f,"\n");
|
|
||||||
|
fprintf(f, "\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* keep the same *chan_pp for next round, thanks
|
* keep the same *chan_pp for next round, thanks
|
||||||
|
@ -507,6 +627,7 @@ int dump_csv_chan(RIG *rig, channel_t **chan_pp, int channel_num, const chan_t *
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Function to parse a line read from csv file and store the data into
|
/** Function to parse a line read from csv file and store the data into
|
||||||
appropriate fields of channel_t. The function must be consistent
|
appropriate fields of channel_t. The function must be consistent
|
||||||
with dump_csv_name and dump_csv_chan.
|
with dump_csv_name and dump_csv_chan.
|
||||||
|
@ -516,199 +637,265 @@ int dump_csv_chan(RIG *rig, channel_t **chan_pp, int channel_num, const chan_t *
|
||||||
\param line_data_list - a pointer to a table of strings with values
|
\param line_data_list - a pointer to a table of strings with values
|
||||||
\return 0 on success, negative value on error
|
\return 0 on success, negative value on error
|
||||||
*/
|
*/
|
||||||
int set_channel_data(RIG *rig, channel_t *chan, char **line_key_list, char **line_data_list){
|
int set_channel_data(RIG *rig,
|
||||||
|
channel_t *chan,
|
||||||
|
char **line_key_list,
|
||||||
|
char **line_data_list)
|
||||||
|
{
|
||||||
|
|
||||||
int i,j,n;
|
int i, j, n;
|
||||||
|
|
||||||
memset(chan,0,sizeof(channel_t));
|
memset(chan, 0, sizeof(channel_t));
|
||||||
chan->vfo = RIG_VFO_CURR;
|
chan->vfo = RIG_VFO_CURR;
|
||||||
|
|
||||||
i = find_on_list( line_key_list, "num" );
|
i = find_on_list(line_key_list, "num");
|
||||||
if( i < 0 ){
|
|
||||||
fprintf(stderr,"No channel number\n");
|
if (i < 0) {
|
||||||
|
fprintf(stderr, "No channel number\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
n = chan->channel_num = atoi( line_data_list[ i ] );
|
|
||||||
|
n = chan->channel_num = atoi(line_data_list[ i ]);
|
||||||
|
|
||||||
/* find chanel caps of appropriate memory group? */
|
/* find chanel caps of appropriate memory group? */
|
||||||
for(j=0; j < CHANLSTSIZ; j++)
|
for (j = 0; j < CHANLSTSIZ; j++)
|
||||||
if( rig->state.chan_list[j].start <= n && rig->state.chan_list[j].end >= n)
|
if (rig->state.chan_list[j].start <= n && rig->state.chan_list[j].end >= n) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Requested channel number %d, list number %d\n",n,j);
|
printf("Requested channel number %d, list number %d\n", n, j);
|
||||||
|
|
||||||
const channel_cap_t *mem_caps = &rig->state.chan_list[j].mem_caps;
|
const channel_cap_t *mem_caps = &rig->state.chan_list[j].mem_caps;
|
||||||
|
|
||||||
if (mem_caps->bank_num) {
|
if (mem_caps->bank_num) {
|
||||||
i = find_on_list( line_key_list, "bank_num" );
|
i = find_on_list(line_key_list, "bank_num");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->bank_num = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->bank_num = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->channel_desc) {
|
if (mem_caps->channel_desc) {
|
||||||
i = find_on_list( line_key_list, "channel_desc" );
|
i = find_on_list(line_key_list, "channel_desc");
|
||||||
if( i >= 0 ){
|
|
||||||
strncpy( chan->channel_desc, line_data_list[ i ], rig->caps->chan_desc_sz-1 );
|
if (i >= 0) {
|
||||||
|
strncpy(chan->channel_desc, line_data_list[ i ], rig->caps->chan_desc_sz - 1);
|
||||||
chan->channel_desc[ rig->caps->chan_desc_sz ] = '\0';
|
chan->channel_desc[ rig->caps->chan_desc_sz ] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ant) {
|
if (mem_caps->ant) {
|
||||||
i = find_on_list( line_key_list, "ant" );
|
i = find_on_list(line_key_list, "ant");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->ant = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->ant = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->freq) {
|
if (mem_caps->freq) {
|
||||||
i = find_on_list( line_key_list, "freq" );
|
i = find_on_list(line_key_list, "freq");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->freq = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->freq = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->mode) {
|
if (mem_caps->mode) {
|
||||||
i = find_on_list( line_key_list, "mode" );
|
i = find_on_list(line_key_list, "mode");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->mode = rig_parse_mode( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->mode = rig_parse_mode(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->width) {
|
if (mem_caps->width) {
|
||||||
i = find_on_list( line_key_list, "width" );
|
i = find_on_list(line_key_list, "width");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->width = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->width = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_freq) {
|
if (mem_caps->tx_freq) {
|
||||||
i = find_on_list( line_key_list, "tx_freq" );
|
i = find_on_list(line_key_list, "tx_freq");
|
||||||
if( i >= 0 ){
|
|
||||||
sscanf( line_data_list[i], "%"SCNfreq, &chan->tx_freq );
|
if (i >= 0) {
|
||||||
|
sscanf(line_data_list[i], "%"SCNfreq, &chan->tx_freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_mode) {
|
if (mem_caps->tx_mode) {
|
||||||
i = find_on_list( line_key_list, "tx_mode" );
|
i = find_on_list(line_key_list, "tx_mode");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->tx_mode = rig_parse_mode( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->tx_mode = rig_parse_mode(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_width) {
|
if (mem_caps->tx_width) {
|
||||||
i = find_on_list( line_key_list, "tx_width" );
|
i = find_on_list(line_key_list, "tx_width");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->tx_width = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->tx_width = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->split) {
|
if (mem_caps->split) {
|
||||||
chan->split=RIG_SPLIT_OFF;
|
chan->split = RIG_SPLIT_OFF;
|
||||||
i = find_on_list( line_key_list, "split" );
|
i = find_on_list(line_key_list, "split");
|
||||||
if( i >= 0 ){
|
|
||||||
if( strcmp( line_data_list[i], "on" ) == 0 ) {
|
if (i >= 0) {
|
||||||
chan->split=RIG_SPLIT_ON;
|
if (strcmp(line_data_list[i], "on") == 0) {
|
||||||
|
chan->split = RIG_SPLIT_ON;
|
||||||
|
|
||||||
if (mem_caps->tx_vfo) {
|
if (mem_caps->tx_vfo) {
|
||||||
i = find_on_list( line_key_list, "tx_vfo" );
|
i = find_on_list(line_key_list, "tx_vfo");
|
||||||
if( i >= 0 )
|
|
||||||
sscanf( line_data_list[i],"%x",&chan->tx_vfo);
|
if (i >= 0) {
|
||||||
|
sscanf(line_data_list[i], "%x", &chan->tx_vfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mem_caps->rptr_shift) {
|
if (mem_caps->rptr_shift) {
|
||||||
i = find_on_list( line_key_list, "rptr_shift" );
|
i = find_on_list(line_key_list, "rptr_shift");
|
||||||
if( i >= 0 ){
|
|
||||||
switch( line_data_list[i][0] ) {
|
if (i >= 0) {
|
||||||
case '=': chan->rptr_shift=RIG_RPT_SHIFT_NONE;
|
switch (line_data_list[i][0]) {
|
||||||
|
case '=':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_NONE;
|
||||||
break;
|
break;
|
||||||
case '+': chan->rptr_shift=RIG_RPT_SHIFT_PLUS;
|
|
||||||
|
case '+':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_PLUS;
|
||||||
break;
|
break;
|
||||||
case '-': chan->rptr_shift=RIG_RPT_SHIFT_MINUS;
|
|
||||||
|
case '-':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_MINUS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( mem_caps->rptr_offs && chan->rptr_shift != RIG_RPT_SHIFT_NONE ){
|
|
||||||
i = find_on_list( line_key_list, "rptr_offs" );
|
if (mem_caps->rptr_offs && chan->rptr_shift != RIG_RPT_SHIFT_NONE) {
|
||||||
if( i >= 0 )
|
i = find_on_list(line_key_list, "rptr_offs");
|
||||||
chan->rptr_offs = atoi( line_data_list[ i ] );
|
|
||||||
|
if (i >= 0) {
|
||||||
|
chan->rptr_offs = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mem_caps->tuning_step) {
|
if (mem_caps->tuning_step) {
|
||||||
i = find_on_list( line_key_list, "tuning_step" );
|
i = find_on_list(line_key_list, "tuning_step");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->tuning_step = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->tuning_step = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->rit) {
|
if (mem_caps->rit) {
|
||||||
i = find_on_list( line_key_list, "rit" );
|
i = find_on_list(line_key_list, "rit");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->rit = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->rit = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->xit) {
|
if (mem_caps->xit) {
|
||||||
i = find_on_list( line_key_list, "xit" );
|
i = find_on_list(line_key_list, "xit");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->xit = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->xit = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->funcs) {
|
if (mem_caps->funcs) {
|
||||||
i = find_on_list( line_key_list, "funcs" );
|
i = find_on_list(line_key_list, "funcs");
|
||||||
if( i >= 0 ){
|
|
||||||
sscanf( line_data_list[i], "%lx", &chan->funcs );
|
if (i >= 0) {
|
||||||
|
sscanf(line_data_list[i], "%lx", &chan->funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_tone) {
|
if (mem_caps->ctcss_tone) {
|
||||||
i = find_on_list( line_key_list, "ctcss_tone" );
|
i = find_on_list(line_key_list, "ctcss_tone");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->ctcss_tone = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->ctcss_tone = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ctcss_sql) {
|
if (mem_caps->ctcss_sql) {
|
||||||
i = find_on_list( line_key_list, "ctcss_sql" );
|
i = find_on_list(line_key_list, "ctcss_sql");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->ctcss_sql = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->ctcss_sql = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_code) {
|
if (mem_caps->dcs_code) {
|
||||||
i = find_on_list( line_key_list, "dcs_code" );
|
i = find_on_list(line_key_list, "dcs_code");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->dcs_code = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->dcs_code = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->dcs_sql) {
|
if (mem_caps->dcs_sql) {
|
||||||
i = find_on_list( line_key_list, "dcs_sql" );
|
i = find_on_list(line_key_list, "dcs_sql");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->dcs_sql = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->dcs_sql = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->scan_group) {
|
if (mem_caps->scan_group) {
|
||||||
i = find_on_list( line_key_list, "scan_group" );
|
i = find_on_list(line_key_list, "scan_group");
|
||||||
if( i >= 0 ){
|
|
||||||
chan->scan_group = atoi( line_data_list[ i ] );
|
if (i >= 0) {
|
||||||
|
chan->scan_group = atoi(line_data_list[ i ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->flags) {
|
if (mem_caps->flags) {
|
||||||
i = find_on_list( line_key_list, "flags" );
|
i = find_on_list(line_key_list, "flags");
|
||||||
if( i >= 0 ){
|
|
||||||
sscanf( line_data_list[i], "%x", &chan->flags );
|
if (i >= 0) {
|
||||||
|
sscanf(line_data_list[i], "%x", &chan->flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Find a string on the list. Assumes the last element on the list is NULL
|
/** Find a string on the list. Assumes the last element on the list is NULL
|
||||||
\param list - a list
|
\param list - a list
|
||||||
\param what - a string to find
|
\param what - a string to find
|
||||||
\return string position on the list on success,
|
\return string position on the list on success,
|
||||||
-1 if string not found or if string is empty
|
-1 if string not found or if string is empty
|
||||||
*/
|
*/
|
||||||
int find_on_list( char **list, char *what ){
|
int find_on_list(char **list, char *what)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if( !what ) return -1;
|
|
||||||
while( list[i] != NULL ){
|
if (!what) {
|
||||||
if( strcmp( list[i], what ) == 0 ){
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (list[i] != NULL) {
|
||||||
|
if (strcmp(list[i], what) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}else{
|
} else {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !list[i] ){
|
|
||||||
|
if (!list[i]) {
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
} else {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
280
tests/memload.c
280
tests/memload.c
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -32,55 +32,67 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
#include <libxml/parser.h>
|
# include <libxml/parser.h>
|
||||||
#include <libxml/tree.h>
|
# include <libxml/tree.h>
|
||||||
|
|
||||||
static int set_chan(RIG *rig, channel_t *chan ,xmlNodePtr node);
|
static int set_chan(RIG *rig, channel_t *chan , xmlNodePtr node);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int xml_load (RIG *my_rig, const char *infilename)
|
int xml_load(RIG *my_rig, const char *infilename)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
xmlDocPtr Doc;
|
xmlDocPtr Doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
/* load xlm Doc */
|
/* load xlm Doc */
|
||||||
Doc=xmlParseFile(infilename);
|
Doc = xmlParseFile(infilename);
|
||||||
if(Doc==NULL) {
|
|
||||||
fprintf(stderr,"xmlParse failed\n");
|
if (Doc == NULL) {
|
||||||
|
fprintf(stderr, "xmlParse failed\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
node=xmlDocGetRootElement(Doc);
|
node = xmlDocGetRootElement(Doc);
|
||||||
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
fprintf(stderr,"get root failed\n");
|
fprintf(stderr, "get root failed\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if(strcmp((char *) node->name, "hamlib")) {
|
|
||||||
fprintf(stderr,"no hamlib tag found\n");
|
if (strcmp((char *) node->name, "hamlib")) {
|
||||||
|
fprintf(stderr, "no hamlib tag found\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
for(node=node->xmlChildrenNode;node!=NULL;node=node->next) {
|
|
||||||
if(xmlNodeIsText(node)) continue;
|
for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
|
||||||
if(strcmp((char *) node->name, "channels")==0)
|
if (xmlNodeIsText(node)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp((char *) node->name, "channels") == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(node==NULL) {
|
}
|
||||||
fprintf(stderr,"no channels\n");
|
|
||||||
|
if (node == NULL) {
|
||||||
|
fprintf(stderr, "no channels\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
for(node=node->xmlChildrenNode;node!=NULL;node=node->next) {
|
|
||||||
|
for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
|
||||||
channel_t chan;
|
channel_t chan;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if(xmlNodeIsText(node)) continue;
|
if (xmlNodeIsText(node)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
set_chan(my_rig,&chan,node);
|
set_chan(my_rig, &chan, node);
|
||||||
|
|
||||||
status=rig_set_channel(my_rig, &chan);
|
status = rig_set_channel(my_rig, &chan);
|
||||||
|
|
||||||
if (status != RIG_OK ) {
|
if (status != RIG_OK) {
|
||||||
printf("rig_get_channel: error = %s \n", rigerror(status));
|
printf("rig_get_channel: error = %s \n", rigerror(status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -95,166 +107,242 @@ int xml_load (RIG *my_rig, const char *infilename)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xml_parm_load (RIG *my_rig, const char *infilename)
|
|
||||||
|
int xml_parm_load(RIG *my_rig, const char *infilename)
|
||||||
{
|
{
|
||||||
return -RIG_ENIMPL;
|
return -RIG_ENIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
int set_chan(RIG *rig, channel_t *chan, xmlNodePtr node)
|
int set_chan(RIG *rig, channel_t *chan, xmlNodePtr node)
|
||||||
{
|
{
|
||||||
xmlChar *prop;
|
xmlChar *prop;
|
||||||
int i,n;
|
int i, n;
|
||||||
|
|
||||||
memset(chan,0,sizeof(channel_t));
|
memset(chan, 0, sizeof(channel_t));
|
||||||
chan->vfo = RIG_VFO_MEM;
|
chan->vfo = RIG_VFO_MEM;
|
||||||
|
|
||||||
|
|
||||||
prop=xmlGetProp(node,(unsigned char *) "num");
|
prop = xmlGetProp(node, (unsigned char *) "num");
|
||||||
if(prop==NULL) {
|
|
||||||
fprintf(stderr,"no num\n");
|
if (prop == NULL) {
|
||||||
|
fprintf(stderr, "no num\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
n=chan->channel_num = atoi((char *) prop);
|
|
||||||
|
n = chan->channel_num = atoi((char *) prop);
|
||||||
|
|
||||||
/* find chanel caps */
|
/* find chanel caps */
|
||||||
for(i=0;i<CHANLSTSIZ ;i++)
|
for (i = 0; i < CHANLSTSIZ ; i++)
|
||||||
if (rig->state.chan_list[i].start<=n && rig->state.chan_list[i].end>=n)
|
if (rig->state.chan_list[i].start <= n
|
||||||
break;
|
&& rig->state.chan_list[i].end >= n) {
|
||||||
|
|
||||||
fprintf(stderr,"node %d %d\n",n,i);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "node %d %d\n", n, i);
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.bank_num) {
|
if (rig->state.chan_list[i].mem_caps.bank_num) {
|
||||||
prop=xmlGetProp(node, (unsigned char *) "bank_num");
|
prop = xmlGetProp(node, (unsigned char *) "bank_num");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->bank_num = atoi((char *) prop);
|
chan->bank_num = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.channel_desc) {
|
if (rig->state.chan_list[i].mem_caps.channel_desc) {
|
||||||
prop=xmlGetProp(node, (unsigned char *) "channel_desc");
|
prop = xmlGetProp(node, (unsigned char *) "channel_desc");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
strncpy(chan->channel_desc, (char *) prop, 7);
|
strncpy(chan->channel_desc, (char *) prop, 7);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.ant) {
|
if (rig->state.chan_list[i].mem_caps.ant) {
|
||||||
prop=xmlGetProp(node, (unsigned char *) "ant");
|
prop = xmlGetProp(node, (unsigned char *) "ant");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->ant = atoi((char *) prop);
|
chan->ant = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
if (rig->state.chan_list[i].mem_caps.freq) {
|
|
||||||
prop=xmlGetProp(node, (unsigned char *) "freq");
|
|
||||||
if(prop!=NULL)
|
|
||||||
sscanf((char *) prop,"%"SCNfreq,&chan->freq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rig->state.chan_list[i].mem_caps.freq) {
|
||||||
|
prop = xmlGetProp(node, (unsigned char *) "freq");
|
||||||
|
|
||||||
|
if (prop != NULL) {
|
||||||
|
sscanf((char *) prop, "%"SCNfreq, &chan->freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.mode) {
|
if (rig->state.chan_list[i].mem_caps.mode) {
|
||||||
prop=xmlGetProp(node, (unsigned char *) "mode");
|
prop = xmlGetProp(node, (unsigned char *) "mode");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->mode = rig_parse_mode((char *) prop);
|
chan->mode = rig_parse_mode((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.width) {
|
if (rig->state.chan_list[i].mem_caps.width) {
|
||||||
prop=xmlGetProp(node, (unsigned char *) "width");
|
prop = xmlGetProp(node, (unsigned char *) "width");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->width = atoi((char *) prop);
|
chan->width = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
if (rig->state.chan_list[i].mem_caps.tx_freq) {
|
|
||||||
prop=xmlGetProp(node, (unsigned char *) "tx_freq");
|
|
||||||
if(prop!=NULL)
|
|
||||||
sscanf((char *) prop,"%"SCNfreq,&chan->tx_freq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rig->state.chan_list[i].mem_caps.tx_freq) {
|
||||||
|
prop = xmlGetProp(node, (unsigned char *) "tx_freq");
|
||||||
|
|
||||||
|
if (prop != NULL) {
|
||||||
|
sscanf((char *) prop, "%"SCNfreq, &chan->tx_freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.tx_mode) {
|
if (rig->state.chan_list[i].mem_caps.tx_mode) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"tx_mode");
|
prop = xmlGetProp(node, (unsigned char *)"tx_mode");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->tx_mode = rig_parse_mode((char *) prop);
|
chan->tx_mode = rig_parse_mode((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.tx_width) {
|
if (rig->state.chan_list[i].mem_caps.tx_width) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"tx_width");
|
prop = xmlGetProp(node, (unsigned char *)"tx_width");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->tx_width = atoi((char *) prop);
|
chan->tx_width = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.split) {
|
if (rig->state.chan_list[i].mem_caps.split) {
|
||||||
chan->split=RIG_SPLIT_OFF;
|
chan->split = RIG_SPLIT_OFF;
|
||||||
prop=xmlGetProp(node, (unsigned char *)"split");
|
prop = xmlGetProp(node, (unsigned char *)"split");
|
||||||
if(prop!=NULL) {
|
|
||||||
if(strcmp((char *) prop,"on")==0) {
|
if (prop != NULL) {
|
||||||
chan->split=RIG_SPLIT_ON;
|
if (strcmp((char *) prop, "on") == 0) {
|
||||||
|
chan->split = RIG_SPLIT_ON;
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.tx_vfo) {
|
if (rig->state.chan_list[i].mem_caps.tx_vfo) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"tx_vfo");
|
prop = xmlGetProp(node, (unsigned char *)"tx_vfo");
|
||||||
if(prop!=NULL)
|
|
||||||
sscanf((char *) prop,"%x",&chan->tx_vfo);
|
if (prop != NULL) {
|
||||||
|
sscanf((char *) prop, "%x", &chan->tx_vfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.rptr_shift) {
|
if (rig->state.chan_list[i].mem_caps.rptr_shift) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"rptr_shift");
|
prop = xmlGetProp(node, (unsigned char *)"rptr_shift");
|
||||||
if(prop)
|
|
||||||
switch(prop[0]) {
|
if (prop)
|
||||||
case '=': chan->rptr_shift=RIG_RPT_SHIFT_NONE;
|
switch (prop[0]) {
|
||||||
|
case '=':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_NONE;
|
||||||
break;
|
break;
|
||||||
case '+': chan->rptr_shift=RIG_RPT_SHIFT_PLUS;
|
|
||||||
|
case '+':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_PLUS;
|
||||||
break;
|
break;
|
||||||
case '-': chan->rptr_shift=RIG_RPT_SHIFT_MINUS;
|
|
||||||
|
case '-':
|
||||||
|
chan->rptr_shift = RIG_RPT_SHIFT_MINUS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rig->state.chan_list[i].mem_caps.rptr_offs && chan->rptr_shift!=RIG_RPT_SHIFT_NONE) {
|
|
||||||
prop=xmlGetProp(node, (unsigned char *)"rptr_offs");
|
if (rig->state.chan_list[i].mem_caps.rptr_offs
|
||||||
if(prop!=NULL)
|
&& chan->rptr_shift != RIG_RPT_SHIFT_NONE) {
|
||||||
|
prop = xmlGetProp(node, (unsigned char *)"rptr_offs");
|
||||||
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->rptr_offs = atoi((char *) prop);
|
chan->rptr_offs = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.tuning_step) {
|
if (rig->state.chan_list[i].mem_caps.tuning_step) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"tuning_step");
|
prop = xmlGetProp(node, (unsigned char *)"tuning_step");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->tuning_step = atoi((char *) prop);
|
chan->tuning_step = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.rit) {
|
if (rig->state.chan_list[i].mem_caps.rit) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"rit");
|
prop = xmlGetProp(node, (unsigned char *)"rit");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->rit = atoi((char *) prop);
|
chan->rit = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.xit) {
|
if (rig->state.chan_list[i].mem_caps.xit) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"xit");
|
prop = xmlGetProp(node, (unsigned char *)"xit");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->xit = atoi((char *) prop);
|
chan->xit = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
if (rig->state.chan_list[i].mem_caps.funcs) {
|
|
||||||
prop=xmlGetProp(node, (unsigned char *)"funcs");
|
|
||||||
if(prop!=NULL)
|
|
||||||
sscanf((char *) prop,"%lx",&chan->funcs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rig->state.chan_list[i].mem_caps.funcs) {
|
||||||
|
prop = xmlGetProp(node, (unsigned char *)"funcs");
|
||||||
|
|
||||||
|
if (prop != NULL) {
|
||||||
|
sscanf((char *) prop, "%lx", &chan->funcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.ctcss_tone) {
|
if (rig->state.chan_list[i].mem_caps.ctcss_tone) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"ctcss_tone");
|
prop = xmlGetProp(node, (unsigned char *)"ctcss_tone");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->ctcss_tone = atoi((char *) prop);
|
chan->ctcss_tone = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.ctcss_sql) {
|
if (rig->state.chan_list[i].mem_caps.ctcss_sql) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"ctcss_sql");
|
prop = xmlGetProp(node, (unsigned char *)"ctcss_sql");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->ctcss_sql = atoi((char *) prop);
|
chan->ctcss_sql = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.dcs_code) {
|
if (rig->state.chan_list[i].mem_caps.dcs_code) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"dcs_code");
|
prop = xmlGetProp(node, (unsigned char *)"dcs_code");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->dcs_code = atoi((char *) prop);
|
chan->dcs_code = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.dcs_sql) {
|
if (rig->state.chan_list[i].mem_caps.dcs_sql) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"dcs_sql");
|
prop = xmlGetProp(node, (unsigned char *)"dcs_sql");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->dcs_sql = atoi((char *) prop);
|
chan->dcs_sql = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.scan_group) {
|
if (rig->state.chan_list[i].mem_caps.scan_group) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"scan_group");
|
prop = xmlGetProp(node, (unsigned char *)"scan_group");
|
||||||
if(prop!=NULL)
|
|
||||||
|
if (prop != NULL) {
|
||||||
chan->scan_group = atoi((char *) prop);
|
chan->scan_group = atoi((char *) prop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rig->state.chan_list[i].mem_caps.flags) {
|
if (rig->state.chan_list[i].mem_caps.flags) {
|
||||||
prop=xmlGetProp(node, (unsigned char *)"flags");
|
prop = xmlGetProp(node, (unsigned char *)"flags");
|
||||||
if(prop!=NULL)
|
|
||||||
sscanf((char *) prop,"%x",&chan->flags);
|
if (prop != NULL) {
|
||||||
|
sscanf((char *) prop, "%x", &chan->flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
136
tests/memsave.c
136
tests/memsave.c
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -32,13 +32,18 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
#include <libxml/parser.h>
|
# include <libxml/parser.h>
|
||||||
#include <libxml/tree.h>
|
# include <libxml/tree.h>
|
||||||
|
|
||||||
static int dump_xml_chan(RIG *rig, channel_t **chan, int channel_num, const chan_t *chan_list, rig_ptr_t arg);
|
static int dump_xml_chan(RIG *rig,
|
||||||
|
channel_t **chan,
|
||||||
|
int channel_num,
|
||||||
|
const chan_t *chan_list,
|
||||||
|
rig_ptr_t arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int xml_save (RIG *rig, const char *outfilename)
|
|
||||||
|
int xml_save(RIG *rig, const char *outfilename)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -46,19 +51,21 @@ int xml_save (RIG *rig, const char *outfilename)
|
||||||
xmlNodePtr root;
|
xmlNodePtr root;
|
||||||
|
|
||||||
/* create xlm Doc */
|
/* create xlm Doc */
|
||||||
Doc=xmlNewDoc((unsigned char *) "1.0");
|
Doc = xmlNewDoc((unsigned char *) "1.0");
|
||||||
root=xmlNewNode(NULL,(unsigned char *) "hamlib");
|
root = xmlNewNode(NULL, (unsigned char *) "hamlib");
|
||||||
xmlDocSetRootElement(Doc, root);
|
xmlDocSetRootElement(Doc, root);
|
||||||
root=xmlNewChild(root,NULL,(unsigned char *) "channels",NULL);
|
root = xmlNewChild(root, NULL, (unsigned char *) "channels", NULL);
|
||||||
|
|
||||||
|
|
||||||
if (rig->caps->clone_combo_get)
|
if (rig->caps->clone_combo_get)
|
||||||
printf("About to save data, enter cloning mode: %s\n",
|
printf("About to save data, enter cloning mode: %s\n",
|
||||||
rig->caps->clone_combo_get);
|
rig->caps->clone_combo_get);
|
||||||
|
|
||||||
retval = rig_get_chan_all_cb (rig, dump_xml_chan, root);
|
retval = rig_get_chan_all_cb(rig, dump_xml_chan, root);
|
||||||
if (retval != RIG_OK)
|
|
||||||
|
if (retval != RIG_OK) {
|
||||||
return retval;
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* write xml File */
|
/* write xml File */
|
||||||
|
|
||||||
|
@ -73,15 +80,19 @@ int xml_save (RIG *rig, const char *outfilename)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xml_parm_save (RIG *rig, const char *outfilename)
|
|
||||||
|
int xml_parm_save(RIG *rig, const char *outfilename)
|
||||||
{
|
{
|
||||||
return -RIG_ENIMPL;
|
return -RIG_ENIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
int dump_xml_chan(RIG *rig, channel_t **chan_pp, int chan_num, const chan_t *chan_list, rig_ptr_t arg)
|
int dump_xml_chan(RIG *rig,
|
||||||
|
channel_t **chan_pp,
|
||||||
|
int chan_num,
|
||||||
|
const chan_t *chan_list,
|
||||||
|
rig_ptr_t arg)
|
||||||
{
|
{
|
||||||
char attrbuf[20];
|
char attrbuf[20];
|
||||||
xmlNodePtr root = arg;
|
xmlNodePtr root = arg;
|
||||||
|
@ -103,119 +114,146 @@ int dump_xml_chan(RIG *rig, channel_t **chan_pp, int chan_num, const chan_t *cha
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan_list->type == RIG_MTYPE_NONE)
|
if (chan_list->type == RIG_MTYPE_NONE) {
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
mtype = rig_strmtype(chan_list->type);
|
mtype = rig_strmtype(chan_list->type);
|
||||||
for (i=0; i<strlen(mtype); i++)
|
|
||||||
|
for (i = 0; i < strlen(mtype); i++) {
|
||||||
attrbuf[i] = tolower(mtype[i]);
|
attrbuf[i] = tolower(mtype[i]);
|
||||||
|
}
|
||||||
|
|
||||||
attrbuf[i] = '\0';
|
attrbuf[i] = '\0';
|
||||||
|
|
||||||
node=xmlNewChild(root,NULL,(unsigned char *)attrbuf,NULL);
|
node = xmlNewChild(root, NULL, (unsigned char *)attrbuf, NULL);
|
||||||
|
|
||||||
if (mem_caps->bank_num) {
|
if (mem_caps->bank_num) {
|
||||||
sprintf(attrbuf,"%d",chan.bank_num);
|
sprintf(attrbuf, "%d", chan.bank_num);
|
||||||
xmlNewProp(node, (unsigned char *) "bank_num", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "bank_num", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(attrbuf,"%d",chan.channel_num);
|
sprintf(attrbuf, "%d", chan.channel_num);
|
||||||
xmlNewProp(node, (unsigned char *) "num", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "num", (unsigned char *) attrbuf);
|
||||||
|
|
||||||
if (mem_caps->channel_desc && chan.channel_desc[0]!='\0') {
|
if (mem_caps->channel_desc && chan.channel_desc[0] != '\0') {
|
||||||
xmlNewProp(node,
|
xmlNewProp(node,
|
||||||
(unsigned char *) "channel_desc",
|
(unsigned char *) "channel_desc",
|
||||||
(unsigned char *) chan.channel_desc);
|
(unsigned char *) chan.channel_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->vfo) {
|
if (mem_caps->vfo) {
|
||||||
sprintf(attrbuf,"%d",chan.vfo);
|
sprintf(attrbuf, "%d", chan.vfo);
|
||||||
xmlNewProp(node, (unsigned char *) "vfo", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "vfo", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->ant && chan.ant != RIG_ANT_NONE) {
|
if (mem_caps->ant && chan.ant != RIG_ANT_NONE) {
|
||||||
sprintf(attrbuf,"%d",chan.ant);
|
sprintf(attrbuf, "%d", chan.ant);
|
||||||
xmlNewProp(node, (unsigned char *) "ant", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "ant", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->freq && chan.freq != RIG_FREQ_NONE) {
|
if (mem_caps->freq && chan.freq != RIG_FREQ_NONE) {
|
||||||
sprintf(attrbuf,"%"PRIll,(int64_t)chan.freq);
|
sprintf(attrbuf, "%"PRIll, (int64_t)chan.freq);
|
||||||
xmlNewProp(node, (unsigned char *) "freq", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "freq", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->mode && chan.mode != RIG_MODE_NONE) {
|
if (mem_caps->mode && chan.mode != RIG_MODE_NONE) {
|
||||||
xmlNewProp(node, (unsigned char *) "mode", (unsigned char *) rig_strrmode(chan.mode));
|
xmlNewProp(node, (unsigned char *) "mode",
|
||||||
|
(unsigned char *) rig_strrmode(chan.mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->width && chan.width != 0) {
|
if (mem_caps->width && chan.width != 0) {
|
||||||
sprintf(attrbuf,"%d",(int)chan.width);
|
sprintf(attrbuf, "%d", (int)chan.width);
|
||||||
xmlNewProp(node, (unsigned char *) "width", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "width", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_freq && chan.tx_freq != RIG_FREQ_NONE) {
|
if (mem_caps->tx_freq && chan.tx_freq != RIG_FREQ_NONE) {
|
||||||
sprintf(attrbuf,"%"PRIll,(int64_t)chan.tx_freq);
|
sprintf(attrbuf, "%"PRIll, (int64_t)chan.tx_freq);
|
||||||
xmlNewProp(node, (unsigned char *) "tx_freq", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "tx_freq", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->tx_mode && chan.tx_mode != RIG_MODE_NONE) {
|
if (mem_caps->tx_mode && chan.tx_mode != RIG_MODE_NONE) {
|
||||||
xmlNewProp(node,
|
xmlNewProp(node,
|
||||||
(unsigned char *) "tx_mode",
|
(unsigned char *) "tx_mode",
|
||||||
(unsigned char *) rig_strrmode(chan.tx_mode));
|
(unsigned char *) rig_strrmode(chan.tx_mode));
|
||||||
}
|
}
|
||||||
if (mem_caps->tx_width && chan.tx_width!=0) {
|
|
||||||
sprintf(attrbuf,"%d",(int)chan.tx_width);
|
if (mem_caps->tx_width && chan.tx_width != 0) {
|
||||||
|
sprintf(attrbuf, "%d", (int)chan.tx_width);
|
||||||
xmlNewProp(node, (unsigned char *) "tx_width", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "tx_width", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->split && chan.split!=RIG_SPLIT_OFF) {
|
|
||||||
|
if (mem_caps->split && chan.split != RIG_SPLIT_OFF) {
|
||||||
xmlNewProp(node, (unsigned char *) "split", (unsigned char *) "on");
|
xmlNewProp(node, (unsigned char *) "split", (unsigned char *) "on");
|
||||||
|
|
||||||
if (mem_caps->tx_vfo) {
|
if (mem_caps->tx_vfo) {
|
||||||
sprintf(attrbuf,"%x",chan.tx_vfo);
|
sprintf(attrbuf, "%x", chan.tx_vfo);
|
||||||
xmlNewProp(node,
|
xmlNewProp(node,
|
||||||
(unsigned char *) "tx_vfo",
|
(unsigned char *) "tx_vfo",
|
||||||
(unsigned char *) attrbuf);
|
(unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mem_caps->rptr_shift && chan.rptr_shift!=RIG_RPT_SHIFT_NONE) {
|
|
||||||
|
if (mem_caps->rptr_shift && chan.rptr_shift != RIG_RPT_SHIFT_NONE) {
|
||||||
xmlNewProp(node,
|
xmlNewProp(node,
|
||||||
(unsigned char *) "rptr_shift",
|
(unsigned char *) "rptr_shift",
|
||||||
(unsigned char *) rig_strptrshift(chan.rptr_shift));
|
(unsigned char *) rig_strptrshift(chan.rptr_shift));
|
||||||
if (mem_caps->rptr_offs && (int)chan.rptr_offs!=0) {
|
|
||||||
sprintf(attrbuf,"%d",(int)chan.rptr_offs);
|
if (mem_caps->rptr_offs && (int)chan.rptr_offs != 0) {
|
||||||
|
sprintf(attrbuf, "%d", (int)chan.rptr_offs);
|
||||||
xmlNewProp(node,
|
xmlNewProp(node,
|
||||||
(unsigned char *) "rptr_offs",
|
(unsigned char *) "rptr_offs",
|
||||||
(unsigned char *) attrbuf);
|
(unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mem_caps->tuning_step && chan.tuning_step !=0) {
|
|
||||||
sprintf(attrbuf,"%d",(int)chan.tuning_step);
|
if (mem_caps->tuning_step && chan.tuning_step != 0) {
|
||||||
|
sprintf(attrbuf, "%d", (int)chan.tuning_step);
|
||||||
xmlNewProp(node, (unsigned char *) "tuning_step", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "tuning_step", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->rit && chan.rit!=0) {
|
|
||||||
sprintf(attrbuf,"%d",(int)chan.rit);
|
if (mem_caps->rit && chan.rit != 0) {
|
||||||
|
sprintf(attrbuf, "%d", (int)chan.rit);
|
||||||
xmlNewProp(node, (unsigned char *) "rit", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "rit", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->xit && chan.xit !=0) {
|
|
||||||
sprintf(attrbuf,"%d",(int)chan.xit);
|
if (mem_caps->xit && chan.xit != 0) {
|
||||||
|
sprintf(attrbuf, "%d", (int)chan.xit);
|
||||||
xmlNewProp(node, (unsigned char *) "xit", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "xit", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->funcs) {
|
if (mem_caps->funcs) {
|
||||||
sprintf(attrbuf,"%lx",chan.funcs);
|
sprintf(attrbuf, "%lx", chan.funcs);
|
||||||
xmlNewProp(node, (unsigned char *) "funcs", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "funcs", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->ctcss_tone && chan.ctcss_tone !=0) {
|
|
||||||
sprintf(attrbuf,"%d",chan.ctcss_tone);
|
if (mem_caps->ctcss_tone && chan.ctcss_tone != 0) {
|
||||||
|
sprintf(attrbuf, "%d", chan.ctcss_tone);
|
||||||
xmlNewProp(node, (unsigned char *) "ctcss_tone", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "ctcss_tone", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->ctcss_sql && chan.ctcss_sql !=0) {
|
|
||||||
sprintf(attrbuf,"%d",chan.ctcss_sql);
|
if (mem_caps->ctcss_sql && chan.ctcss_sql != 0) {
|
||||||
|
sprintf(attrbuf, "%d", chan.ctcss_sql);
|
||||||
xmlNewProp(node, (unsigned char *) "ctcss_sql", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "ctcss_sql", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->dcs_code && chan.dcs_code !=0) {
|
|
||||||
sprintf(attrbuf,"%d",chan.dcs_code);
|
if (mem_caps->dcs_code && chan.dcs_code != 0) {
|
||||||
|
sprintf(attrbuf, "%d", chan.dcs_code);
|
||||||
xmlNewProp(node, (unsigned char *) "dcs_code", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "dcs_code", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
if (mem_caps->dcs_sql && chan.dcs_sql !=0) {
|
|
||||||
sprintf(attrbuf,"%d",chan.dcs_sql);
|
if (mem_caps->dcs_sql && chan.dcs_sql != 0) {
|
||||||
|
sprintf(attrbuf, "%d", chan.dcs_sql);
|
||||||
xmlNewProp(node, (unsigned char *) "dcs_sql", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "dcs_sql", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->scan_group) {
|
if (mem_caps->scan_group) {
|
||||||
sprintf(attrbuf,"%d",chan.scan_group);
|
sprintf(attrbuf, "%d", chan.scan_group);
|
||||||
xmlNewProp(node, (unsigned char *) "scan_group", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "scan_group", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_caps->flags) {
|
if (mem_caps->flags) {
|
||||||
sprintf(attrbuf,"%x",chan.flags);
|
sprintf(attrbuf, "%x", chan.flags);
|
||||||
xmlNewProp(node, (unsigned char *) "flags", (unsigned char *) attrbuf);
|
xmlNewProp(node, (unsigned char *) "flags", (unsigned char *) attrbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
#define SERIAL_PORT "/dev/ttyS0"
|
#define SERIAL_PORT "/dev/ttyS0"
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig; /* handle to rig (nstance) */
|
RIG *my_rig; /* handle to rig (nstance) */
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
|
@ -49,20 +50,25 @@ int main (int argc, char *argv[])
|
||||||
my_rig = rig_init(myrig_model);
|
my_rig = rig_init(myrig_model);
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr,"Unknown rig num: %d\n", myrig_model);
|
fprintf(stderr, "Unknown rig num: %d\n", myrig_model);
|
||||||
fprintf(stderr,"Please check riglist.h\n");
|
fprintf(stderr, "Please check riglist.h\n");
|
||||||
exit(1); /* whoops! something went wrong (mem alloc?) */
|
exit(1); /* whoops! something went wrong (mem alloc?) */
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
my_rig->caps->rig_model,
|
||||||
my_rig->caps->model_name);
|
my_rig->caps->model_name);
|
||||||
|
|
||||||
printf("Backend version: %s, Status: %s\n",
|
printf("Backend version: %s, Status: %s\n",
|
||||||
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
my_rig->caps->version,
|
||||||
|
rig_strstatus(my_rig->caps->status));
|
||||||
|
|
||||||
printf("Serial speed: %d bauds\n", my_rig->state.rigport.parm.serial.rate);
|
printf("Serial speed: %d bauds\n", my_rig->state.rigport.parm.serial.rate);
|
||||||
|
|
||||||
strncpy(my_rig->state.rigport.pathname,SERIAL_PORT,FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
retcode = rig_open(my_rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_open: error = %s\n", rigerror(retcode));
|
printf("rig_open: error = %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -75,34 +81,39 @@ int main (int argc, char *argv[])
|
||||||
* we're not using getrusage here because we want effective time
|
* we're not using getrusage here because we want effective time
|
||||||
*/
|
*/
|
||||||
gettimeofday(&tv1, NULL);
|
gettimeofday(&tv1, NULL);
|
||||||
for (i=0; i<LOOP_COUNT; i++) {
|
|
||||||
|
for (i = 0; i < LOOP_COUNT; i++) {
|
||||||
freq_t freq;
|
freq_t freq;
|
||||||
rmode_t rmode;
|
rmode_t rmode;
|
||||||
pbwidth_t width;
|
pbwidth_t width;
|
||||||
|
|
||||||
retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
||||||
if (retcode != RIG_OK ) {
|
|
||||||
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_get_freq: error = %s \n", rigerror(retcode));
|
printf("rig_get_freq: error = %s \n", rigerror(retcode));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
if (retcode != RIG_OK ) {
|
|
||||||
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_get_mode: error = %s \n", rigerror(retcode));
|
printf("rig_get_mode: error = %s \n", rigerror(retcode));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&tv2, NULL);
|
gettimeofday(&tv2, NULL);
|
||||||
|
|
||||||
elapsed = tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec)/1000000.0;
|
elapsed = tv2.tv_sec - tv1.tv_sec + (tv2.tv_usec - tv1.tv_usec) / 1000000.0;
|
||||||
printf("Elapsed: %.3fs, Avg: %f loops/s, %f s/loop\n",
|
printf("Elapsed: %.3fs, Avg: %f loops/s, %f s/loop\n",
|
||||||
elapsed, LOOP_COUNT/elapsed, elapsed/LOOP_COUNT
|
elapsed,
|
||||||
);
|
LOOP_COUNT / elapsed,
|
||||||
|
elapsed / LOOP_COUNT);
|
||||||
|
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
|
||||||
printf("port %s closed ok \n",SERIAL_PORT);
|
printf("port %s closed ok \n", SERIAL_PORT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
214
tests/rigctl.c
214
tests/rigctl.c
|
@ -25,7 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
# elif defined(HAVE_READLINE_H) /* !defined(HAVE_READLINE_READLINE_H) */
|
# elif defined(HAVE_READLINE_H) /* !defined(HAVE_READLINE_READLINE_H) */
|
||||||
# include <readline.h>
|
# include <readline.h>
|
||||||
# else /* !defined(HAVE_READLINE_H) */
|
# else /* !defined(HAVE_READLINE_H) */
|
||||||
extern char *readline ();
|
extern char * readline();
|
||||||
# endif /* HAVE_READLINE_H */
|
# endif /* HAVE_READLINE_H */
|
||||||
#else
|
#else
|
||||||
/* no readline */
|
/* no readline */
|
||||||
|
@ -56,9 +56,9 @@ extern char *readline ();
|
||||||
# elif defined(HAVE_HISTORY_H)
|
# elif defined(HAVE_HISTORY_H)
|
||||||
# include <history.h>
|
# include <history.h>
|
||||||
# else /* !defined(HAVE_HISTORY_H) */
|
# else /* !defined(HAVE_HISTORY_H) */
|
||||||
extern void add_history ();
|
extern void add_history();
|
||||||
extern int write_history ();
|
extern int write_history();
|
||||||
extern int read_history ();
|
extern int read_history();
|
||||||
# endif /* defined(HAVE_READLINE_HISTORY_H) */
|
# endif /* defined(HAVE_READLINE_HISTORY_H) */
|
||||||
#else
|
#else
|
||||||
/* no history */
|
/* no history */
|
||||||
|
@ -88,8 +88,7 @@ void usage(void);
|
||||||
* TODO: add an option to read from a file
|
* TODO: add an option to read from a file
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhV"
|
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhV"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
{"rig-file", 1, 0, 'r'},
|
{"rig-file", 1, 0, 'r'},
|
||||||
{"ptt-file", 1, 0, 'p'},
|
{"ptt-file", 1, 0, 'p'},
|
||||||
|
@ -131,9 +130,9 @@ int vfo_mode = 0; /* vfo_mode = 0 means target VFO is 'currVFO' */
|
||||||
|
|
||||||
char send_cmd_term = '\r'; /* send_cmd termination char */
|
char send_cmd_term = '\r'; /* send_cmd termination char */
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig; /* handle to rig (nstance) */
|
RIG *my_rig; /* handle to rig (instance) */
|
||||||
rig_model_t my_model = RIG_MODEL_DUMMY;
|
rig_model_t my_model = RIG_MODEL_DUMMY;
|
||||||
|
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
|
@ -150,163 +149,206 @@ int main (int argc, char *argv[])
|
||||||
char *hist_path = NULL;
|
char *hist_path = NULL;
|
||||||
struct stat hist_dir_stat;
|
struct stat hist_dir_stat;
|
||||||
#endif
|
#endif
|
||||||
const char *rig_file=NULL, *ptt_file=NULL, *dcd_file=NULL;
|
const char *rig_file = NULL, *ptt_file = NULL, *dcd_file = NULL;
|
||||||
ptt_type_t ptt_type = RIG_PTT_NONE;
|
ptt_type_t ptt_type = RIG_PTT_NONE;
|
||||||
dcd_type_t dcd_type = RIG_DCD_NONE;
|
dcd_type_t dcd_type = RIG_DCD_NONE;
|
||||||
int serial_rate = 0;
|
int serial_rate = 0;
|
||||||
char *civaddr = NULL; /* NULL means no need to set conf */
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
||||||
char conf_parms[MAXCONFLEN] = "";
|
char conf_parms[MAXCONFLEN] = "";
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long (argc, argv, SHORT_OPTIONS HST_SHRT_OPTS,
|
c = getopt_long(argc,
|
||||||
long_options, &option_index);
|
argv,
|
||||||
if (c == -1)
|
SHORT_OPTIONS HST_SHRT_OPTS,
|
||||||
break;
|
long_options,
|
||||||
|
&option_index);
|
||||||
|
|
||||||
switch(c) {
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_model = atoi(optarg);
|
my_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_file = optarg;
|
rig_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptt_file = optarg;
|
ptt_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcd_file = optarg;
|
dcd_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "RIG"))
|
|
||||||
|
if (!strcmp(optarg, "RIG")) {
|
||||||
ptt_type = RIG_PTT_RIG;
|
ptt_type = RIG_PTT_RIG;
|
||||||
else if (!strcmp(optarg, "DTR"))
|
} else if (!strcmp(optarg, "DTR")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_DTR;
|
ptt_type = RIG_PTT_SERIAL_DTR;
|
||||||
else if (!strcmp(optarg, "RTS"))
|
} else if (!strcmp(optarg, "RTS")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_RTS;
|
ptt_type = RIG_PTT_SERIAL_RTS;
|
||||||
else if (!strcmp(optarg, "PARALLEL"))
|
} else if (!strcmp(optarg, "PARALLEL")) {
|
||||||
ptt_type = RIG_PTT_PARALLEL;
|
ptt_type = RIG_PTT_PARALLEL;
|
||||||
else if (!strcmp(optarg, "CM108"))
|
} else if (!strcmp(optarg, "CM108")) {
|
||||||
ptt_type = RIG_PTT_CM108;
|
ptt_type = RIG_PTT_CM108;
|
||||||
else if (!strcmp(optarg, "GPIO"))
|
} else if (!strcmp(optarg, "GPIO")) {
|
||||||
ptt_type = RIG_PTT_GPIO;
|
ptt_type = RIG_PTT_GPIO;
|
||||||
else if (!strcmp(optarg, "GPION"))
|
} else if (!strcmp(optarg, "GPION")) {
|
||||||
ptt_type = RIG_PTT_GPION;
|
ptt_type = RIG_PTT_GPION;
|
||||||
else if (!strcmp(optarg, "NONE"))
|
} else if (!strcmp(optarg, "NONE")) {
|
||||||
ptt_type = RIG_PTT_NONE;
|
ptt_type = RIG_PTT_NONE;
|
||||||
else
|
} else {
|
||||||
ptt_type = atoi(optarg);
|
ptt_type = atoi(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "RIG"))
|
|
||||||
|
if (!strcmp(optarg, "RIG")) {
|
||||||
dcd_type = RIG_DCD_RIG;
|
dcd_type = RIG_DCD_RIG;
|
||||||
else if (!strcmp(optarg, "DSR"))
|
} else if (!strcmp(optarg, "DSR")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_DSR;
|
dcd_type = RIG_DCD_SERIAL_DSR;
|
||||||
else if (!strcmp(optarg, "CTS"))
|
} else if (!strcmp(optarg, "CTS")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_CTS;
|
dcd_type = RIG_DCD_SERIAL_CTS;
|
||||||
else if (!strcmp(optarg, "CD"))
|
} else if (!strcmp(optarg, "CD")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_CAR;
|
dcd_type = RIG_DCD_SERIAL_CAR;
|
||||||
else if (!strcmp(optarg, "PARALLEL"))
|
} else if (!strcmp(optarg, "PARALLEL")) {
|
||||||
dcd_type = RIG_DCD_PARALLEL;
|
dcd_type = RIG_DCD_PARALLEL;
|
||||||
else if (!strcmp(optarg, "CM108"))
|
} else if (!strcmp(optarg, "CM108")) {
|
||||||
dcd_type = RIG_DCD_CM108;
|
dcd_type = RIG_DCD_CM108;
|
||||||
else if (!strcmp(optarg, "NONE"))
|
} else if (!strcmp(optarg, "NONE")) {
|
||||||
dcd_type = RIG_DCD_NONE;
|
dcd_type = RIG_DCD_NONE;
|
||||||
else
|
} else {
|
||||||
dcd_type = atoi(optarg);
|
dcd_type = atoi(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
civaddr = optarg;
|
civaddr = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (strlen(optarg) > 1)
|
|
||||||
|
if (strlen(optarg) > 1) {
|
||||||
send_cmd_term = strtol(optarg, NULL, 0);
|
send_cmd_term = strtol(optarg, NULL, 0);
|
||||||
else
|
} else {
|
||||||
send_cmd_term = optarg[0];
|
send_cmd_term = optarg[0];
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_rate = atoi(optarg);
|
serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*conf_parms != '\0')
|
|
||||||
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN-strlen(conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
vfo_mode++;
|
vfo_mode++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
rig_no_restore_ai();
|
rig_no_restore_ai();
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
rd_hist++;
|
rd_hist++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
sv_hist++;
|
sv_hist++;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
show_conf++;
|
show_conf++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
list_models();
|
list_models();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
dump_caps_opt++;
|
dump_caps_opt++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -316,50 +358,65 @@ int main (int argc, char *argv[])
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rigctl, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rigctl, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* at least one command on command line,
|
* at least one command on command line,
|
||||||
* disable interactive mode
|
* disable interactive mode
|
||||||
*/
|
*/
|
||||||
if (optind < argc)
|
if (optind < argc) {
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
|
}
|
||||||
|
|
||||||
my_rig = rig_init(my_model);
|
my_rig = rig_init(my_model);
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rig num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
retcode = set_conf(my_rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file) {
|
||||||
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ex: RIG_PTT_PARALLEL and /dev/parport0
|
* ex: RIG_PTT_PARALLEL and /dev/parport0
|
||||||
*/
|
*/
|
||||||
if (ptt_type != RIG_PTT_NONE)
|
if (ptt_type != RIG_PTT_NONE) {
|
||||||
my_rig->state.pttport.type.ptt = ptt_type;
|
my_rig->state.pttport.type.ptt = ptt_type;
|
||||||
if (dcd_type != RIG_DCD_NONE)
|
}
|
||||||
|
|
||||||
|
if (dcd_type != RIG_DCD_NONE) {
|
||||||
my_rig->state.dcdport.type.dcd = dcd_type;
|
my_rig->state.dcdport.type.dcd = dcd_type;
|
||||||
if (ptt_file)
|
}
|
||||||
|
|
||||||
|
if (ptt_file) {
|
||||||
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
||||||
if (dcd_file)
|
}
|
||||||
|
|
||||||
|
if (dcd_file) {
|
||||||
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
||||||
if (civaddr)
|
}
|
||||||
|
|
||||||
|
if (civaddr) {
|
||||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out conf parameters
|
* print out conf parameters
|
||||||
|
@ -369,7 +426,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out capabilities, and exists immediately
|
* print out capabilities, and exit immediately
|
||||||
* We may be interested only in only caps, and rig_open may fail.
|
* We may be interested only in only caps, and rig_open may fail.
|
||||||
*/
|
*/
|
||||||
if (dump_caps_opt) {
|
if (dump_caps_opt) {
|
||||||
|
@ -379,67 +436,94 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
retcode = rig_open(my_rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
my_rig->caps->rig_model,
|
||||||
my_rig->caps->model_name);
|
my_rig->caps->model_name);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
}
|
||||||
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
|
"Backend version: %s, Status: %s\n",
|
||||||
|
my_rig->caps->version,
|
||||||
|
rig_strstatus(my_rig->caps->status));
|
||||||
|
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
|
||||||
if (interactive && prompt && have_rl) {
|
if (interactive && prompt && have_rl) {
|
||||||
rl_readline_name = "rigctl";
|
rl_readline_name = "rigctl";
|
||||||
|
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
using_history(); /* Initialize Readline History */
|
using_history(); /* Initialize Readline History */
|
||||||
|
|
||||||
if (rd_hist || sv_hist) {
|
if (rd_hist || sv_hist) {
|
||||||
if (!(hist_dir = getenv("RIGCTL_HIST_DIR")))
|
if (!(hist_dir = getenv("RIGCTL_HIST_DIR"))) {
|
||||||
hist_dir = getenv("HOME");
|
hist_dir = getenv("HOME");
|
||||||
|
}
|
||||||
|
|
||||||
if (((stat(hist_dir, &hist_dir_stat) == -1) && (errno == ENOENT))
|
if (((stat(hist_dir, &hist_dir_stat) == -1) && (errno == ENOENT))
|
||||||
|| !(S_ISDIR(hist_dir_stat.st_mode))) {
|
|| !(S_ISDIR(hist_dir_stat.st_mode))) {
|
||||||
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
|
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
hist_path = (char *)calloc((sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1)), sizeof(char));
|
hist_path = (char *)calloc((sizeof(char)
|
||||||
|
* (strlen(hist_dir)
|
||||||
|
+ strlen(hist_file) + 1)),
|
||||||
|
sizeof(char));
|
||||||
|
|
||||||
strncpy(hist_path, hist_dir, strlen(hist_dir));
|
strncpy(hist_path, hist_dir, strlen(hist_dir));
|
||||||
strncat(hist_path, hist_file, strlen(hist_file));
|
strncat(hist_path, hist_file, strlen(hist_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rd_hist && hist_path)
|
if (rd_hist && hist_path) {
|
||||||
if (read_history(hist_path) == ENOENT)
|
if (read_history(hist_path) == ENOENT) {
|
||||||
fprintf(stderr, "Warning: Could not read history from %s\n", hist_path);
|
fprintf(stderr,
|
||||||
|
"Warning: Could not read history from %s\n",
|
||||||
|
hist_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LIBREADLINE */
|
#endif /* HAVE_LIBREADLINE */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
retcode = rigctl_parse(my_rig, stdin, stdout, argv, argc);
|
retcode = rigctl_parse(my_rig, stdin, stdout, argv, argc);
|
||||||
if (retcode == 2)
|
|
||||||
|
if (retcode == 2) {
|
||||||
exitcode = 2;
|
exitcode = 2;
|
||||||
}
|
}
|
||||||
while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL);
|
} while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL);
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
|
||||||
if (interactive && prompt && have_rl) {
|
if (interactive && prompt && have_rl) {
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
if (sv_hist && hist_path)
|
|
||||||
if (write_history(hist_path) == ENOENT)
|
if (sv_hist && hist_path) {
|
||||||
fprintf(stderr, "\nWarning: Could not write history to %s\n", hist_path);
|
if (write_history(hist_path) == ENOENT) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"\nWarning: Could not write history to %s\n",
|
||||||
|
hist_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((rd_hist || sv_hist) && hist_path) {
|
if ((rd_hist || sv_hist) && hist_path) {
|
||||||
free(hist_path);
|
free(hist_path);
|
||||||
hist_path = (char *)NULL;
|
hist_path = (char *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
@ -474,7 +558,7 @@ void usage(void)
|
||||||
" -i, --read-history read prior interactive session history\n"
|
" -i, --read-history read prior interactive session history\n"
|
||||||
" -I, --save-history save current interactive session history\n"
|
" -I, --save-history save current interactive session history\n"
|
||||||
#endif
|
#endif
|
||||||
" -v, --verbose set verbose mode, cumulative\n"
|
" -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n"
|
||||||
" -h, --help display this help and exit\n"
|
" -h, --help display this help and exit\n"
|
||||||
" -V, --version output version information and exit\n\n"
|
" -V, --version output version information and exit\n\n"
|
||||||
);
|
);
|
||||||
|
|
1551
tests/rigctl_parse.c
1551
tests/rigctl_parse.c
Plik diff jest za duży
Load Diff
|
@ -32,8 +32,8 @@
|
||||||
* external prototype
|
* external prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int dumpcaps (RIG *, FILE *);
|
int dumpcaps(RIG *, FILE *);
|
||||||
int dumpconf (RIG *, FILE *);
|
int dumpconf(RIG *, FILE *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
|
@ -41,7 +41,7 @@ int dumpconf (RIG *, FILE *);
|
||||||
void usage_rig(FILE *);
|
void usage_rig(FILE *);
|
||||||
void version();
|
void version();
|
||||||
void list_models();
|
void list_models();
|
||||||
int dump_chan(FILE *, RIG*, channel_t*);
|
int dump_chan(FILE *, RIG *, channel_t *);
|
||||||
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
||||||
int set_conf(RIG *my_rig, char *conf_parms);
|
int set_conf(RIG *my_rig, char *conf_parms);
|
||||||
|
|
||||||
|
|
169
tests/rigctld.c
169
tests/rigctld.c
|
@ -42,9 +42,11 @@
|
||||||
#ifdef HAVE_NETINET_IN_H
|
#ifdef HAVE_NETINET_IN_H
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
#ifdef HAVE_ARPA_INET_H
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
#elif HAVE_WS2TCPIP_H
|
#elif HAVE_WS2TCPIP_H
|
||||||
|
@ -54,6 +56,7 @@
|
||||||
# include <wspiapi.h>
|
# include <wspiapi.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_NETDB_H
|
#ifdef HAVE_NETDB_H
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,6 +73,7 @@
|
||||||
|
|
||||||
#include "rigctl_parse.h"
|
#include "rigctl_parse.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reminder: when adding long options,
|
* Reminder: when adding long options,
|
||||||
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
|
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
|
||||||
|
@ -99,6 +103,7 @@ static struct option long_options[] = {
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct handle_data {
|
struct handle_data {
|
||||||
RIG *rig;
|
RIG *rig;
|
||||||
int sock;
|
int sock;
|
||||||
|
@ -106,9 +111,11 @@ struct handle_data {
|
||||||
socklen_t clilen;
|
socklen_t clilen;
|
||||||
};
|
};
|
||||||
|
|
||||||
void *handle_socket(void *arg);
|
|
||||||
|
void * handle_socket(void *arg);
|
||||||
void usage(void);
|
void usage(void);
|
||||||
|
|
||||||
|
|
||||||
int interactive = 1; /* no cmd because of daemon */
|
int interactive = 1; /* no cmd because of daemon */
|
||||||
int prompt = 0; /* Daemon mode for rigparse return string */
|
int prompt = 0; /* Daemon mode for rigparse return string */
|
||||||
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
|
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
|
||||||
|
@ -120,6 +127,7 @@ const char *src_addr = NULL; /* INADDR_ANY */
|
||||||
|
|
||||||
#define MAXCONFLEN 128
|
#define MAXCONFLEN 128
|
||||||
|
|
||||||
|
|
||||||
static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
|
@ -129,14 +137,14 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
||||||
lpMsgBuf = (LPVOID)"Unknown error";
|
lpMsgBuf = (LPVOID)"Unknown error";
|
||||||
e = WSAGetLastError();
|
e = WSAGetLastError();
|
||||||
|
|
||||||
if (FormatMessage(
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL, e,
|
NULL, e,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
// Default language
|
// Default language
|
||||||
(LPTSTR)&lpMsgBuf, 0, NULL)) {
|
(LPTSTR)&lpMsgBuf, 0, NULL)) {
|
||||||
|
|
||||||
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,6 +157,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig; /* handle to rig (instance) */
|
RIG *my_rig; /* handle to rig (instance) */
|
||||||
|
@ -183,11 +192,15 @@ int main(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long(argc, argv, SHORT_OPTIONS,
|
c = getopt_long(argc,
|
||||||
long_options, &option_index);
|
argv,
|
||||||
|
SHORT_OPTIONS,
|
||||||
|
long_options,
|
||||||
|
&option_index);
|
||||||
|
|
||||||
if (c == -1)
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -240,20 +253,21 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(optarg, "RIG"))
|
if (!strcmp(optarg, "RIG")) {
|
||||||
ptt_type = RIG_PTT_RIG;
|
ptt_type = RIG_PTT_RIG;
|
||||||
else if (!strcmp(optarg, "DTR"))
|
} else if (!strcmp(optarg, "DTR")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_DTR;
|
ptt_type = RIG_PTT_SERIAL_DTR;
|
||||||
else if (!strcmp(optarg, "RTS"))
|
} else if (!strcmp(optarg, "RTS")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_RTS;
|
ptt_type = RIG_PTT_SERIAL_RTS;
|
||||||
else if (!strcmp(optarg, "PARALLEL"))
|
} else if (!strcmp(optarg, "PARALLEL")) {
|
||||||
ptt_type = RIG_PTT_PARALLEL;
|
ptt_type = RIG_PTT_PARALLEL;
|
||||||
else if (!strcmp(optarg, "CM108"))
|
} else if (!strcmp(optarg, "CM108")) {
|
||||||
ptt_type = RIG_PTT_CM108;
|
ptt_type = RIG_PTT_CM108;
|
||||||
else if (!strcmp(optarg, "NONE"))
|
} else if (!strcmp(optarg, "NONE")) {
|
||||||
ptt_type = RIG_PTT_NONE;
|
ptt_type = RIG_PTT_NONE;
|
||||||
else
|
} else {
|
||||||
ptt_type = atoi(optarg);
|
ptt_type = atoi(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -263,20 +277,21 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(optarg, "RIG"))
|
if (!strcmp(optarg, "RIG")) {
|
||||||
dcd_type = RIG_DCD_RIG;
|
dcd_type = RIG_DCD_RIG;
|
||||||
else if (!strcmp(optarg, "DSR"))
|
} else if (!strcmp(optarg, "DSR")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_DSR;
|
dcd_type = RIG_DCD_SERIAL_DSR;
|
||||||
else if (!strcmp(optarg, "CTS"))
|
} else if (!strcmp(optarg, "CTS")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_CTS;
|
dcd_type = RIG_DCD_SERIAL_CTS;
|
||||||
else if (!strcmp(optarg, "CD"))
|
} else if (!strcmp(optarg, "CD")) {
|
||||||
dcd_type = RIG_DCD_SERIAL_CAR;
|
dcd_type = RIG_DCD_SERIAL_CAR;
|
||||||
else if (!strcmp(optarg, "PARALLEL"))
|
} else if (!strcmp(optarg, "PARALLEL")) {
|
||||||
dcd_type = RIG_DCD_PARALLEL;
|
dcd_type = RIG_DCD_PARALLEL;
|
||||||
else if (!strcmp(optarg, "NONE"))
|
} else if (!strcmp(optarg, "NONE")) {
|
||||||
dcd_type = RIG_DCD_NONE;
|
dcd_type = RIG_DCD_NONE;
|
||||||
else
|
} else {
|
||||||
dcd_type = atoi(optarg);
|
dcd_type = atoi(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -304,8 +319,9 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*conf_parms != '\0')
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
|
}
|
||||||
|
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
@ -357,14 +373,16 @@ int main(int argc, char *argv[])
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rigctld, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rigctld, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
my_rig = rig_init(my_model);
|
my_rig = rig_init(my_model);
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rig num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -376,30 +394,37 @@ int main(int argc, char *argv[])
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file) {
|
||||||
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ex: RIG_PTT_PARALLEL and /dev/parport0
|
* ex: RIG_PTT_PARALLEL and /dev/parport0
|
||||||
*/
|
*/
|
||||||
if (ptt_type != RIG_PTT_NONE)
|
if (ptt_type != RIG_PTT_NONE) {
|
||||||
my_rig->state.pttport.type.ptt = ptt_type;
|
my_rig->state.pttport.type.ptt = ptt_type;
|
||||||
|
}
|
||||||
|
|
||||||
if (dcd_type != RIG_DCD_NONE)
|
if (dcd_type != RIG_DCD_NONE) {
|
||||||
my_rig->state.dcdport.type.dcd = dcd_type;
|
my_rig->state.dcdport.type.dcd = dcd_type;
|
||||||
|
}
|
||||||
|
|
||||||
if (ptt_file)
|
if (ptt_file) {
|
||||||
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (dcd_file)
|
if (dcd_file) {
|
||||||
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN - 1);
|
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
||||||
|
}
|
||||||
|
|
||||||
if (civaddr)
|
if (civaddr) {
|
||||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out conf parameters
|
* print out conf parameters
|
||||||
|
@ -425,9 +450,11 @@ int main(int argc, char *argv[])
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
my_rig->caps->rig_model,
|
||||||
my_rig->caps->model_name);
|
my_rig->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
||||||
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
||||||
|
@ -451,7 +478,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
sockopt = SO_SYNCHRONOUS_NONALERT;
|
sockopt = SO_SYNCHRONOUS_NONALERT;
|
||||||
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sockopt, sizeof(sockopt));
|
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sockopt,
|
||||||
|
sizeof(sockopt));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -473,7 +501,8 @@ int main(int argc, char *argv[])
|
||||||
saved_result = result;
|
saved_result = result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sock_listen = socket(result->ai_family, result->ai_socktype,
|
sock_listen = socket(result->ai_family,
|
||||||
|
result->ai_socktype,
|
||||||
result->ai_protocol);
|
result->ai_protocol);
|
||||||
|
|
||||||
if (sock_listen < 0) {
|
if (sock_listen < 0) {
|
||||||
|
@ -482,8 +511,13 @@ int main(int argc, char *argv[])
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR,
|
if (setsockopt(sock_listen,
|
||||||
(char *)&reuseaddr, sizeof(reuseaddr)) < 0) {
|
SOL_SOCKET,
|
||||||
|
SO_REUSEADDR,
|
||||||
|
(char *)&reuseaddr,
|
||||||
|
sizeof(reuseaddr))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
||||||
freeaddrinfo(saved_result); /* No longer needed */
|
freeaddrinfo(saved_result); /* No longer needed */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -496,8 +530,13 @@ int main(int argc, char *argv[])
|
||||||
this to 1 (i.e. disallowed) and we prefer it off */
|
this to 1 (i.e. disallowed) and we prefer it off */
|
||||||
sockopt = 0;
|
sockopt = 0;
|
||||||
|
|
||||||
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
|
if (setsockopt(sock_listen,
|
||||||
(char *)&sockopt, sizeof(sockopt)) < 0) {
|
IPPROTO_IPV6,
|
||||||
|
IPV6_V6ONLY,
|
||||||
|
(char *)&sockopt,
|
||||||
|
sizeof(sockopt))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
||||||
freeaddrinfo(saved_result); /* No longer needed */
|
freeaddrinfo(saved_result); /* No longer needed */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -536,15 +575,18 @@ int main(int argc, char *argv[])
|
||||||
inherit this disposition which is what we want. */
|
inherit this disposition which is what we want. */
|
||||||
#if HAVE_SIGACTION
|
#if HAVE_SIGACTION
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset (&act, 0, sizeof act);
|
memset(&act, 0, sizeof act);
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
act.sa_flags = SA_RESTART;
|
act.sa_flags = SA_RESTART;
|
||||||
if (sigaction (SIGPIPE, &act, NULL)) {
|
|
||||||
handle_error (RIG_DEBUG_ERR, "sigaction");
|
if (sigaction(SIGPIPE, &act, NULL)) {
|
||||||
|
handle_error(RIG_DEBUG_ERR, "sigaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_SIGNAL
|
#elif HAVE_SIGNAL
|
||||||
if (SIG_ERR == signal (SIGPIPE, SIG_IGN)))
|
|
||||||
handle_error (RIG_DEBUG_ERR, "signal");
|
if (SIG_ERR == signal(SIGPIPE, SIG_IGN)) {
|
||||||
|
handle_error(RIG_DEBUG_ERR, "signal");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -562,15 +604,24 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
arg->rig = my_rig;
|
arg->rig = my_rig;
|
||||||
arg->clilen = sizeof(arg->cli_addr);
|
arg->clilen = sizeof(arg->cli_addr);
|
||||||
arg->sock = accept(sock_listen, (struct sockaddr *)&arg->cli_addr, &arg->clilen);
|
arg->sock = accept(sock_listen,
|
||||||
|
(struct sockaddr *)&arg->cli_addr,
|
||||||
|
&arg->clilen);
|
||||||
|
|
||||||
if (arg->sock < 0) {
|
if (arg->sock < 0) {
|
||||||
handle_error(RIG_DEBUG_ERR, "accept");
|
handle_error(RIG_DEBUG_ERR, "accept");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retcode = getnameinfo((struct sockaddr const *)&arg->cli_addr, arg->clilen, host,
|
if ((retcode = getnameinfo((struct sockaddr const *)&arg->cli_addr,
|
||||||
sizeof(host), serv, sizeof(serv), NI_NOFQDN)) < 0) {
|
arg->clilen,
|
||||||
|
host,
|
||||||
|
sizeof(host),
|
||||||
|
serv,
|
||||||
|
sizeof(serv),
|
||||||
|
NI_NOFQDN))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +657,7 @@ int main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* This is the function run by the threads
|
* This is the function run by the threads
|
||||||
*/
|
*/
|
||||||
void *handle_socket(void *arg)
|
void * handle_socket(void *arg)
|
||||||
{
|
{
|
||||||
struct handle_data *handle_data_arg = (struct handle_data *)arg;
|
struct handle_data *handle_data_arg = (struct handle_data *)arg;
|
||||||
FILE *fsockin;
|
FILE *fsockin;
|
||||||
|
@ -649,13 +700,20 @@ void *handle_socket(void *arg)
|
||||||
do {
|
do {
|
||||||
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
|
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
|
||||||
|
|
||||||
if (ferror(fsockin) || ferror(fsockout))
|
if (ferror(fsockin) || ferror(fsockout)) {
|
||||||
retcode = 1;
|
retcode = 1;
|
||||||
} while (retcode == 0 || retcode == 2 || retcode==-RIG_ENAVAIL);
|
}
|
||||||
|
} while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL);
|
||||||
|
|
||||||
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
|
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
|
||||||
handle_data_arg->clilen, host, sizeof(host),
|
handle_data_arg->clilen,
|
||||||
serv, sizeof(serv), NI_NOFQDN)) < 0) {
|
host,
|
||||||
|
sizeof(host),
|
||||||
|
serv,
|
||||||
|
sizeof(serv),
|
||||||
|
NI_NOFQDN))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,6 +739,7 @@ handle_exit:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: rigctld [OPTION]...\n"
|
printf("Usage: rigctld [OPTION]...\n"
|
||||||
|
@ -703,7 +762,7 @@ void usage(void)
|
||||||
" -l, --list list all model numbers and exit\n"
|
" -l, --list list all model numbers and exit\n"
|
||||||
" -u, --dump-caps dump capabilities and exit\n"
|
" -u, --dump-caps dump capabilities and exit\n"
|
||||||
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
|
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
|
||||||
" -v, --verbose set verbose mode, cumulative\n"
|
" -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n"
|
||||||
" -h, --help display this help and exit\n"
|
" -h, --help display this help and exit\n"
|
||||||
" -V, --version output version information and exit\n\n",
|
" -V, --version output version information and exit\n\n",
|
||||||
portno);
|
portno);
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
|
|
||||||
static setting_t bitmap_func, bitmap_level, bitmap_parm;
|
static setting_t bitmap_func, bitmap_level, bitmap_parm;
|
||||||
|
|
||||||
int create_png_range(const freq_range_t rx_range_list[], const freq_range_t tx_range_list[], int num);
|
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)
|
int print_caps_sum(const struct rig_caps *caps, void *data)
|
||||||
{
|
{
|
||||||
|
@ -42,41 +43,52 @@ int print_caps_sum(const struct rig_caps *caps, void *data)
|
||||||
printf("<TR><TD><A HREF=\"support/model%d.txt\">%s</A></TD><TD>%s</TD>"
|
printf("<TR><TD><A HREF=\"support/model%d.txt\">%s</A></TD><TD>%s</TD>"
|
||||||
"<TD>%s</TD><TD>%s</TD><TD>",
|
"<TD>%s</TD><TD>%s</TD><TD>",
|
||||||
caps->rig_model,
|
caps->rig_model,
|
||||||
caps->model_name,caps->mfg_name,caps->version,
|
caps->model_name,
|
||||||
rig_strstatus(caps->status)
|
caps->mfg_name,
|
||||||
);
|
caps->version,
|
||||||
|
rig_strstatus(caps->status));
|
||||||
|
|
||||||
switch (caps->rig_type & RIG_TYPE_MASK) {
|
switch (caps->rig_type & RIG_TYPE_MASK) {
|
||||||
case RIG_TYPE_TRANSCEIVER:
|
case RIG_TYPE_TRANSCEIVER:
|
||||||
printf("Transceiver");
|
printf("Transceiver");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_HANDHELD:
|
case RIG_TYPE_HANDHELD:
|
||||||
printf("Handheld");
|
printf("Handheld");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_MOBILE:
|
case RIG_TYPE_MOBILE:
|
||||||
printf("Mobile");
|
printf("Mobile");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_RECEIVER:
|
case RIG_TYPE_RECEIVER:
|
||||||
printf("Receiver");
|
printf("Receiver");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_PCRECEIVER:
|
case RIG_TYPE_PCRECEIVER:
|
||||||
printf("PC Receiver");
|
printf("PC Receiver");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_SCANNER:
|
case RIG_TYPE_SCANNER:
|
||||||
printf("Scanner");
|
printf("Scanner");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_TRUNKSCANNER:
|
case RIG_TYPE_TRUNKSCANNER:
|
||||||
printf("Trunking scanner");
|
printf("Trunking scanner");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_COMPUTER:
|
case RIG_TYPE_COMPUTER:
|
||||||
printf("Computer");
|
printf("Computer");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_TYPE_OTHER:
|
case RIG_TYPE_OTHER:
|
||||||
printf("Other");
|
printf("Other");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown");
|
printf("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("</TD><TD><A HREF=\"#rng%d\">range</A></TD>"
|
printf("</TD><TD><A HREF=\"#rng%d\">range</A></TD>"
|
||||||
"<TD><A HREF=\"#parms%d\">parms</A></TD>"
|
"<TD><A HREF=\"#parms%d\">parms</A></TD>"
|
||||||
"<TD><A HREF=\"#caps%d\">caps</A></TD>"
|
"<TD><A HREF=\"#caps%d\">caps</A></TD>"
|
||||||
|
@ -89,12 +101,12 @@ int print_caps_sum(const struct rig_caps *caps, void *data)
|
||||||
"</TR>\n",
|
"</TR>\n",
|
||||||
caps->rig_model, caps->rig_model, caps->rig_model,
|
caps->rig_model, caps->rig_model, caps->rig_model,
|
||||||
caps->rig_model, caps->rig_model, caps->rig_model,
|
caps->rig_model, caps->rig_model, caps->rig_model,
|
||||||
caps->rig_model, caps->rig_model, caps->rig_model
|
caps->rig_model, caps->rig_model, caps->rig_model);
|
||||||
);
|
|
||||||
|
|
||||||
return 1; /* !=0, we want them all ! */
|
return 1; /* !=0, we want them all ! */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IO params et al.
|
* IO params et al.
|
||||||
*/
|
*/
|
||||||
|
@ -108,16 +120,20 @@ int print_caps_parameters(const struct rig_caps *caps, void *data)
|
||||||
case RIG_PTT_RIG:
|
case RIG_PTT_RIG:
|
||||||
printf("rig");
|
printf("rig");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_PARALLEL:
|
case RIG_PTT_PARALLEL:
|
||||||
printf("parallel");
|
printf("parallel");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_RTS:
|
case RIG_PTT_SERIAL_RTS:
|
||||||
case RIG_PTT_SERIAL_DTR:
|
case RIG_PTT_SERIAL_DTR:
|
||||||
printf("serial");
|
printf("serial");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_NONE:
|
case RIG_PTT_NONE:
|
||||||
printf("None");
|
printf("None");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown");
|
printf("Unknown");
|
||||||
}
|
}
|
||||||
|
@ -128,16 +144,20 @@ int print_caps_parameters(const struct rig_caps *caps, void *data)
|
||||||
case RIG_DCD_RIG:
|
case RIG_DCD_RIG:
|
||||||
printf("rig");
|
printf("rig");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_PARALLEL:
|
case RIG_DCD_PARALLEL:
|
||||||
printf("parallel");
|
printf("parallel");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_SERIAL_CTS:
|
case RIG_DCD_SERIAL_CTS:
|
||||||
case RIG_DCD_SERIAL_DSR:
|
case RIG_DCD_SERIAL_DSR:
|
||||||
printf("serial");
|
printf("serial");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_DCD_NONE:
|
case RIG_DCD_NONE:
|
||||||
printf("None");
|
printf("None");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown");
|
printf("Unknown");
|
||||||
}
|
}
|
||||||
|
@ -148,37 +168,45 @@ int print_caps_parameters(const struct rig_caps *caps, void *data)
|
||||||
case RIG_PORT_SERIAL:
|
case RIG_PORT_SERIAL:
|
||||||
printf("serial");
|
printf("serial");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_DEVICE:
|
case RIG_PORT_DEVICE:
|
||||||
printf("device");
|
printf("device");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NETWORK:
|
case RIG_PORT_NETWORK:
|
||||||
printf("network");
|
printf("network");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_UDP_NETWORK:
|
case RIG_PORT_UDP_NETWORK:
|
||||||
printf("UDP network");
|
printf("UDP network");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NONE:
|
case RIG_PORT_NONE:
|
||||||
printf("None");
|
printf("None");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown");
|
printf("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("</TD><TD>%d</TD><TD>%d</TD><TD>%d%c%d</TD><TD>%s</TD>",
|
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_rate_min,
|
||||||
|
caps->serial_rate_max,
|
||||||
caps->serial_data_bits,
|
caps->serial_data_bits,
|
||||||
caps->serial_parity==RIG_PARITY_NONE?'N':
|
caps->serial_parity == RIG_PARITY_NONE ? 'N' :
|
||||||
caps->serial_parity==RIG_PARITY_ODD?'O':
|
caps->serial_parity == RIG_PARITY_ODD ? 'O' :
|
||||||
caps->serial_parity==RIG_PARITY_EVEN?'E':
|
caps->serial_parity == RIG_PARITY_EVEN ? 'E' :
|
||||||
caps->serial_parity==RIG_PARITY_MARK?'M':'S',
|
caps->serial_parity == RIG_PARITY_MARK ? 'M' : 'S',
|
||||||
caps->serial_stop_bits,
|
caps->serial_stop_bits,
|
||||||
caps->serial_handshake==RIG_HANDSHAKE_NONE?"none":
|
caps->serial_handshake == RIG_HANDSHAKE_NONE ? "none" :
|
||||||
(caps->serial_handshake==RIG_HANDSHAKE_XONXOFF?"XONXOFF":"CTS/RTS")
|
(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",
|
printf("<TD>%dms</TD><TD>%dms</TD><TD>%dms</TD><TD>%d</TD></TR></A>\n",
|
||||||
caps->write_delay, caps->post_write_delay,
|
caps->write_delay,
|
||||||
caps->timeout, caps->retry);
|
caps->post_write_delay,
|
||||||
|
caps->timeout,
|
||||||
|
caps->retry);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +262,7 @@ int print_caps_caps(const struct rig_caps *caps, void *data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/Set parm abilities
|
* Get/Set parm abilities
|
||||||
*/
|
*/
|
||||||
|
@ -242,13 +271,14 @@ int print_caps_parm(const struct rig_caps *caps, void *data)
|
||||||
setting_t parm;
|
setting_t parm;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!data)
|
if (!data) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
parm = (*(int*)data)? caps->has_set_parm : caps->has_get_parm;
|
parm = (*(int *)data) ? caps->has_set_parm : caps->has_get_parm;
|
||||||
|
|
||||||
printf("<A NAME=\"%sparm%d\"><TR><TD>%s</TD>",
|
printf("<A NAME=\"%sparm%d\"><TR><TD>%s</TD>",
|
||||||
(*(int*)data)? "set":"get",
|
(*(int *)data) ? "set" : "get",
|
||||||
caps->rig_model,
|
caps->rig_model,
|
||||||
caps->model_name);
|
caps->model_name);
|
||||||
|
|
||||||
|
@ -256,14 +286,17 @@ int print_caps_parm(const struct rig_caps *caps, void *data)
|
||||||
* bitmap_parm: only those who have a label
|
* bitmap_parm: only those who have a label
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
if (rig_idx2setting(i) & bitmap_parm)
|
if (rig_idx2setting(i) & bitmap_parm) {
|
||||||
print_yn(parm & rig_idx2setting(i));
|
print_yn(parm & rig_idx2setting(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("</TR></A>\n");
|
printf("</TR></A>\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/Set level abilities
|
* Get/Set level abilities
|
||||||
*/
|
*/
|
||||||
|
@ -272,13 +305,14 @@ int print_caps_level(const struct rig_caps *caps, void *data)
|
||||||
setting_t level;
|
setting_t level;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!data)
|
if (!data) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
level = (*(int*)data)? caps->has_set_level : caps->has_get_level;
|
level = (*(int *)data) ? caps->has_set_level : caps->has_get_level;
|
||||||
|
|
||||||
printf("<A NAME=\"%slevel%d\"><TR><TD>%s</TD>",
|
printf("<A NAME=\"%slevel%d\"><TR><TD>%s</TD>",
|
||||||
(*(int*)data)? "set":"get",
|
(*(int *)data) ? "set" : "get",
|
||||||
caps->rig_model,
|
caps->rig_model,
|
||||||
caps->model_name);
|
caps->model_name);
|
||||||
|
|
||||||
|
@ -286,14 +320,17 @@ int print_caps_level(const struct rig_caps *caps, void *data)
|
||||||
* bitmap_level: only those who have a label
|
* bitmap_level: only those who have a label
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
if (rig_idx2setting(i) & bitmap_level)
|
if (rig_idx2setting(i) & bitmap_level) {
|
||||||
print_yn(level & rig_idx2setting(i));
|
print_yn(level & rig_idx2setting(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("</TR></A>\n");
|
printf("</TR></A>\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/Set func abilities
|
* Get/Set func abilities
|
||||||
*/
|
*/
|
||||||
|
@ -302,13 +339,14 @@ int print_caps_func(const struct rig_caps *caps, void *data)
|
||||||
setting_t func;
|
setting_t func;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!data)
|
if (!data) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
func = (*(int*)data)? caps->has_set_func : caps->has_get_func;
|
func = (*(int *)data) ? caps->has_set_func : caps->has_get_func;
|
||||||
|
|
||||||
printf("<A NAME=\"%sfunc%d\"><TR><TD>%s</TD>",
|
printf("<A NAME=\"%sfunc%d\"><TR><TD>%s</TD>",
|
||||||
(*(int*)data)? "set":"get",
|
(*(int *)data) ? "set" : "get",
|
||||||
caps->rig_model,
|
caps->rig_model,
|
||||||
caps->model_name);
|
caps->model_name);
|
||||||
|
|
||||||
|
@ -316,9 +354,11 @@ int print_caps_func(const struct rig_caps *caps, void *data)
|
||||||
* bitmap_func: only those who have a label
|
* bitmap_func: only those who have a label
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
if (rig_idx2setting(i) & bitmap_func)
|
if (rig_idx2setting(i) & bitmap_func) {
|
||||||
print_yn(func & rig_idx2setting(i));
|
print_yn(func & rig_idx2setting(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("</TR></A>\n");
|
printf("</TR></A>\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -343,6 +383,7 @@ int print_caps_range(const struct rig_caps *caps, void *data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define RANGE_WIDTH 600
|
#define RANGE_WIDTH 600
|
||||||
#define RANGE_HEIGHT 16
|
#define RANGE_HEIGHT 16
|
||||||
#define RANGE_MIDHEIGHT (RANGE_HEIGHT/2)
|
#define RANGE_MIDHEIGHT (RANGE_HEIGHT/2)
|
||||||
|
@ -359,15 +400,21 @@ int print_caps_range(const struct rig_caps *caps, void *data)
|
||||||
#define UHF_H 50
|
#define UHF_H 50
|
||||||
#define IM_LGD 21
|
#define IM_LGD 21
|
||||||
|
|
||||||
static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h1, int h2, int rgb)
|
|
||||||
|
static void draw_range(const freq_range_t range_list[],
|
||||||
|
gdImagePtr im_rng,
|
||||||
|
int h1,
|
||||||
|
int h2,
|
||||||
|
int rgb)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i<FRQRANGESIZ; i++) {
|
for (i = 0; i < FRQRANGESIZ; i++) {
|
||||||
float start_pix, end_pix;
|
float start_pix, end_pix;
|
||||||
|
|
||||||
if (range_list[i].start == 0 && range_list[i].end == 0)
|
if (range_list[i].start == 0 && range_list[i].end == 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
start_pix = range_list[i].start;
|
start_pix = range_list[i].start;
|
||||||
end_pix = range_list[i].end;
|
end_pix = range_list[i].end;
|
||||||
|
@ -378,12 +425,19 @@ static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h
|
||||||
if (range_list[i].start < MHz(30)) {
|
if (range_list[i].start < MHz(30)) {
|
||||||
start_pix = start_pix / MHz(30) * RANGE_WIDTH;
|
start_pix = start_pix / MHz(30) * RANGE_WIDTH;
|
||||||
end_pix = end_pix / MHz(30) * RANGE_WIDTH;
|
end_pix = end_pix / MHz(30) * RANGE_WIDTH;
|
||||||
if (end_pix >= RANGE_WIDTH)
|
|
||||||
end_pix = RANGE_WIDTH-1;
|
if (end_pix >= RANGE_WIDTH) {
|
||||||
|
end_pix = RANGE_WIDTH - 1;
|
||||||
|
}
|
||||||
|
|
||||||
start_pix += IM_LGD;
|
start_pix += IM_LGD;
|
||||||
end_pix += IM_LGD;
|
end_pix += IM_LGD;
|
||||||
gdImageFilledRectangle(im_rng, start_pix, HF_H+h1, end_pix, HF_H+h2, rgb);
|
gdImageFilledRectangle(im_rng,
|
||||||
|
start_pix,
|
||||||
|
HF_H + h1,
|
||||||
|
end_pix,
|
||||||
|
HF_H + h2,
|
||||||
|
rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -391,18 +445,30 @@ static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h
|
||||||
*/
|
*/
|
||||||
start_pix = range_list[i].start;
|
start_pix = range_list[i].start;
|
||||||
end_pix = range_list[i].end;
|
end_pix = range_list[i].end;
|
||||||
|
|
||||||
if ((range_list[i].start > MHz(30) && range_list[i].start < MHz(300))
|
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))) {
|
|| (range_list[i].start < MHz(30)
|
||||||
start_pix = (start_pix-MHz(30)) / MHz(300) * RANGE_WIDTH;
|
&& range_list[i].end > MHz(30))) {
|
||||||
end_pix = (end_pix-MHz(30)) / MHz(300) * RANGE_WIDTH;
|
|
||||||
if (start_pix < 0)
|
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;
|
start_pix = 0;
|
||||||
if (end_pix >= RANGE_WIDTH)
|
}
|
||||||
end_pix = RANGE_WIDTH-1;
|
|
||||||
|
if (end_pix >= RANGE_WIDTH) {
|
||||||
|
end_pix = RANGE_WIDTH - 1;
|
||||||
|
}
|
||||||
|
|
||||||
start_pix += IM_LGD;
|
start_pix += IM_LGD;
|
||||||
end_pix += IM_LGD;
|
end_pix += IM_LGD;
|
||||||
gdImageFilledRectangle(im_rng, start_pix, VHF_H+h1, end_pix, VHF_H+h2, rgb);
|
gdImageFilledRectangle(im_rng,
|
||||||
|
start_pix,
|
||||||
|
VHF_H + h1,
|
||||||
|
end_pix,
|
||||||
|
VHF_H + h2,
|
||||||
|
rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -410,25 +476,39 @@ static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h
|
||||||
*/
|
*/
|
||||||
start_pix = range_list[i].start;
|
start_pix = range_list[i].start;
|
||||||
end_pix = range_list[i].end;
|
end_pix = range_list[i].end;
|
||||||
|
|
||||||
if ((range_list[i].start > MHz(300) && range_list[i].start < GHz(3))
|
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))) {
|
|| (range_list[i].start < MHz(300)
|
||||||
start_pix = (start_pix-MHz(300)) / GHz(3) * RANGE_WIDTH;
|
&& range_list[i].end > MHz(300))) {
|
||||||
end_pix = (end_pix-MHz(300)) / GHz(3) * RANGE_WIDTH;
|
|
||||||
if (start_pix < 0)
|
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;
|
start_pix = 0;
|
||||||
if (end_pix >= RANGE_WIDTH)
|
}
|
||||||
end_pix = RANGE_WIDTH-1;
|
|
||||||
|
if (end_pix >= RANGE_WIDTH) {
|
||||||
|
end_pix = RANGE_WIDTH - 1;
|
||||||
|
}
|
||||||
|
|
||||||
start_pix += IM_LGD;
|
start_pix += IM_LGD;
|
||||||
end_pix += IM_LGD;
|
end_pix += IM_LGD;
|
||||||
gdImageFilledRectangle(im_rng, start_pix, UHF_H+h1, end_pix, UHF_H+h2, rgb);
|
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[],
|
int create_png_range(const freq_range_t rx_range_list[],
|
||||||
const freq_range_t tx_range_list[], int num)
|
const freq_range_t tx_range_list[],
|
||||||
|
int num)
|
||||||
{
|
{
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
|
@ -437,14 +517,18 @@ int create_png_range(const freq_range_t rx_range_list[],
|
||||||
char rng_fname[128];
|
char rng_fname[128];
|
||||||
|
|
||||||
/* Color indexes */
|
/* Color indexes */
|
||||||
int white, black;
|
#if 0
|
||||||
int rx_rgb,tx_rgb;
|
int white;
|
||||||
|
#endif
|
||||||
|
int black;
|
||||||
|
int rx_rgb, tx_rgb;
|
||||||
|
|
||||||
/* Create output image, x by y pixels. */
|
/* Create output image, x by y pixels. */
|
||||||
im_rng = gdImageCreate(RANGE_WIDTH+IM_LGD, UHF_H+RANGE_HEIGHT);
|
im_rng = gdImageCreate(RANGE_WIDTH + IM_LGD, UHF_H + RANGE_HEIGHT);
|
||||||
|
|
||||||
/* First color allocated is background. */
|
/* First color allocated is background. */
|
||||||
white = gdImageColorAllocate(im_rng, 255, 255, 255);
|
// white = gdImageColorAllocate(im_rng, 255, 255, 255);
|
||||||
|
gdImageColorAllocate(im_rng, 255, 255, 255);
|
||||||
black = gdImageColorAllocate(im_rng, 0, 0, 0);
|
black = gdImageColorAllocate(im_rng, 0, 0, 0);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -458,20 +542,51 @@ int create_png_range(const freq_range_t rx_range_list[],
|
||||||
tx_rgb = gdImageColorAllocate(im_rng, TX_R, TX_G, TX_B);
|
tx_rgb = gdImageColorAllocate(im_rng, TX_R, TX_G, TX_B);
|
||||||
rx_rgb = gdImageColorAllocate(im_rng, RX_R, RX_G, RX_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(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);
|
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,
|
||||||
gdImageRectangle(im_rng, IM_LGD, VHF_H, IM_LGD+RANGE_WIDTH-1, VHF_H+RANGE_HEIGHT-1, black);
|
IM_LGD,
|
||||||
gdImageRectangle(im_rng, IM_LGD, UHF_H, IM_LGD+RANGE_WIDTH-1, UHF_H+RANGE_HEIGHT-1, black);
|
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 */
|
/* gdImageStringUp */
|
||||||
gdImageString(im_rng, gdFontSmall, 1, HF_H+1,
|
gdImageString(im_rng,
|
||||||
(unsigned char *) "HF", black);
|
gdFontSmall,
|
||||||
gdImageString(im_rng, gdFontSmall, 1, VHF_H+1,
|
1,
|
||||||
(unsigned char *) "VHF", black);
|
HF_H + 1,
|
||||||
gdImageString(im_rng, gdFontSmall, 1, UHF_H+1,
|
(unsigned char *) "HF",
|
||||||
(unsigned char *) "UHF", black);
|
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,
|
/* Make output image interlaced (allows "fade in" in some viewers,
|
||||||
and in the latest web browsers) */
|
and in the latest web browsers) */
|
||||||
|
@ -479,6 +594,7 @@ int create_png_range(const freq_range_t rx_range_list[],
|
||||||
|
|
||||||
sprintf(rng_fname, "range%d.png", num);
|
sprintf(rng_fname, "range%d.png", num);
|
||||||
out = fopen(rng_fname, "wb");
|
out = fopen(rng_fname, "wb");
|
||||||
|
|
||||||
/* Write PNG */
|
/* Write PNG */
|
||||||
gdImagePng(im_rng, out);
|
gdImagePng(im_rng, out);
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
@ -487,9 +603,9 @@ int create_png_range(const freq_range_t rx_range_list[],
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
time_t gentime;
|
time_t gentime;
|
||||||
int set_or_get;
|
int set_or_get;
|
||||||
int i;
|
int i;
|
||||||
|
@ -509,7 +625,7 @@ int main (int argc, char *argv[])
|
||||||
"<TD>Get parm</TD>"
|
"<TD>Get parm</TD>"
|
||||||
"<TD>Set parm</TD>"
|
"<TD>Set parm</TD>"
|
||||||
"</TR>\n");
|
"</TR>\n");
|
||||||
status = rig_list_foreach(print_caps_sum,NULL);
|
rig_list_foreach(print_caps_sum, NULL);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -519,14 +635,14 @@ int main (int argc, char *argv[])
|
||||||
"<TD>Speed min</TD><TD>Speed max</TD>"
|
"<TD>Speed min</TD><TD>Speed max</TD>"
|
||||||
"<TD>Parm.</TD><TD>Handshake</TD><TD>Write delay</TD>"
|
"<TD>Parm.</TD><TD>Handshake</TD><TD>Write delay</TD>"
|
||||||
"<TD>Post delay</TD><TD>Timeout</TD><TD>Retry</TD></TR>\n");
|
"<TD>Post delay</TD><TD>Timeout</TD><TD>Retry</TD></TR>\n");
|
||||||
status = rig_list_foreach(print_caps_parameters,NULL);
|
rig_list_foreach(print_caps_parameters, NULL);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD><TD>Freq. range</TD></TR>\n");
|
printf("<TR><TD>Model</TD><TD>Freq. range</TD></TR>\n");
|
||||||
status = rig_list_foreach(print_caps_range,NULL);
|
rig_list_foreach(print_caps_range, NULL);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -548,7 +664,7 @@ int main (int argc, char *argv[])
|
||||||
"<TD>Set trn</TD><TD>Get trn</TD>"
|
"<TD>Set trn</TD><TD>Get trn</TD>"
|
||||||
"<TD>Decode</TD><TD>Get info</TD>"
|
"<TD>Decode</TD><TD>Get info</TD>"
|
||||||
"</TR>\n");
|
"</TR>\n");
|
||||||
status = rig_list_foreach(print_caps_caps,NULL);
|
rig_list_foreach(print_caps_caps, NULL);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -556,11 +672,15 @@ int main (int argc, char *argv[])
|
||||||
bitmap_func = 0;
|
bitmap_func = 0;
|
||||||
prntbuf[0] = '\0';
|
prntbuf[0] = '\0';
|
||||||
pbuf = prntbuf;
|
pbuf = prntbuf;
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
setting_t func = rig_idx2setting(i);
|
setting_t func = rig_idx2setting(i);
|
||||||
const char *s = rig_strfunc(func);
|
const char *s = rig_strfunc(func);
|
||||||
if (!s)
|
|
||||||
|
if (!s) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bitmap_func |= func;
|
bitmap_func |= func;
|
||||||
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
||||||
}
|
}
|
||||||
|
@ -569,7 +689,7 @@ int main (int argc, char *argv[])
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 1;
|
set_or_get = 1;
|
||||||
status = rig_list_foreach(print_caps_func,&set_or_get);
|
rig_list_foreach(print_caps_func, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -578,7 +698,7 @@ int main (int argc, char *argv[])
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 0;
|
set_or_get = 0;
|
||||||
status = rig_list_foreach(print_caps_func,&set_or_get);
|
rig_list_foreach(print_caps_func, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -586,11 +706,15 @@ int main (int argc, char *argv[])
|
||||||
bitmap_level = 0;
|
bitmap_level = 0;
|
||||||
prntbuf[0] = '\0';
|
prntbuf[0] = '\0';
|
||||||
pbuf = prntbuf;
|
pbuf = prntbuf;
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
setting_t level = rig_idx2setting(i);
|
setting_t level = rig_idx2setting(i);
|
||||||
const char *s = rig_strlevel(level);
|
const char *s = rig_strlevel(level);
|
||||||
if (!s)
|
|
||||||
|
if (!s) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bitmap_level |= level;
|
bitmap_level |= level;
|
||||||
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
||||||
}
|
}
|
||||||
|
@ -599,7 +723,7 @@ int main (int argc, char *argv[])
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 1;
|
set_or_get = 1;
|
||||||
status = rig_list_foreach(print_caps_level,&set_or_get);
|
rig_list_foreach(print_caps_level, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -608,7 +732,7 @@ int main (int argc, char *argv[])
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 0;
|
set_or_get = 0;
|
||||||
status = rig_list_foreach(print_caps_level,&set_or_get);
|
rig_list_foreach(print_caps_level, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -616,19 +740,24 @@ int main (int argc, char *argv[])
|
||||||
bitmap_parm = 0;
|
bitmap_parm = 0;
|
||||||
prntbuf[0] = '\0';
|
prntbuf[0] = '\0';
|
||||||
pbuf = prntbuf;
|
pbuf = prntbuf;
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
setting_t parm = rig_idx2setting(i);
|
setting_t parm = rig_idx2setting(i);
|
||||||
const char *s = rig_strparm(parm);
|
const char *s = rig_strparm(parm);
|
||||||
if (!s)
|
|
||||||
|
if (!s) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bitmap_parm |= parm;
|
bitmap_parm |= parm;
|
||||||
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Set parm");
|
printf("Set parm");
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 1;
|
set_or_get = 1;
|
||||||
status = rig_list_foreach(print_caps_parm,&set_or_get);
|
rig_list_foreach(print_caps_parm, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
@ -637,16 +766,15 @@ int main (int argc, char *argv[])
|
||||||
printf("<TABLE BORDER=1>\n");
|
printf("<TABLE BORDER=1>\n");
|
||||||
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
|
||||||
set_or_get = 0;
|
set_or_get = 0;
|
||||||
status = rig_list_foreach(print_caps_parm,&set_or_get);
|
rig_list_foreach(print_caps_parm, &set_or_get);
|
||||||
printf("</TABLE>\n");
|
printf("</TABLE>\n");
|
||||||
|
|
||||||
printf("<P>");
|
printf("<P>");
|
||||||
|
|
||||||
time(&gentime);
|
time(&gentime);
|
||||||
printf("Rigmatrix generated %s by %s\n",ctime(&gentime), getenv("USER"));
|
printf("Rigmatrix generated %s by %s\n", ctime(&gentime), getenv("USER"));
|
||||||
|
|
||||||
printf("</body></html>\n");
|
printf("</body></html>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
192
tests/rigmem.c
192
tests/rigmem.c
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -47,15 +47,15 @@
|
||||||
* external prototype
|
* external prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int xml_save (RIG *rig, const char *outfilename);
|
extern int xml_save(RIG *rig, const char *outfilename);
|
||||||
extern int xml_load (RIG *rig, const char *infilename);
|
extern int xml_load(RIG *rig, const char *infilename);
|
||||||
extern int xml_parm_save (RIG *rig, const char *outfilename);
|
extern int xml_parm_save(RIG *rig, const char *outfilename);
|
||||||
extern int xml_parm_load (RIG *rig, const char *infilename);
|
extern int xml_parm_load(RIG *rig, const char *infilename);
|
||||||
|
|
||||||
extern int csv_save (RIG *rig, const char *outfilename);
|
extern int csv_save(RIG *rig, const char *outfilename);
|
||||||
extern int csv_load (RIG *rig, const char *infilename);
|
extern int csv_load(RIG *rig, const char *infilename);
|
||||||
extern int csv_parm_save (RIG *rig, const char *outfilename);
|
extern int csv_parm_save(RIG *rig, const char *outfilename);
|
||||||
extern int csv_parm_load (RIG *rig, const char *infilename);
|
extern int csv_parm_load(RIG *rig, const char *infilename);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
|
@ -64,7 +64,7 @@ void usage();
|
||||||
void version();
|
void version();
|
||||||
int set_conf(RIG *rig, char *conf_parms);
|
int set_conf(RIG *rig, char *conf_parms);
|
||||||
|
|
||||||
int clear_chans (RIG *rig, const char *infilename);
|
int clear_chans(RIG *rig, const char *infilename);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reminder: when adding long options,
|
* Reminder: when adding long options,
|
||||||
|
@ -72,8 +72,7 @@ int clear_chans (RIG *rig, const char *infilename);
|
||||||
* NB: do NOT use -W since it's reserved by POSIX.
|
* NB: do NOT use -W since it's reserved by POSIX.
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "m:r:s:c:C:p:axvhV"
|
#define SHORT_OPTIONS "m:r:s:c:C:p:axvhV"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
{"rig-file", 1, 0, 'r'},
|
{"rig-file", 1, 0, 'r'},
|
||||||
{"serial-speed", 1, 0, 's'},
|
{"serial-speed", 1, 0, 's'},
|
||||||
|
@ -94,7 +93,7 @@ static struct option long_options[] =
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *rig; /* handle to rig (nstance) */
|
RIG *rig; /* handle to rig (nstance) */
|
||||||
rig_model_t my_model = RIG_MODEL_DUMMY;
|
rig_model_t my_model = RIG_MODEL_DUMMY;
|
||||||
|
@ -102,96 +101,117 @@ int main (int argc, char *argv[])
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
|
|
||||||
int verbose = 0, xml = 0;
|
int verbose = 0, xml = 0;
|
||||||
const char *rig_file=NULL;
|
const char *rig_file = NULL;
|
||||||
int serial_rate = 0;
|
int serial_rate = 0;
|
||||||
char *civaddr = NULL; /* NULL means no need to set conf */
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
||||||
char conf_parms[MAXCONFLEN] = "";
|
char conf_parms[MAXCONFLEN] = "";
|
||||||
extern char csv_sep;
|
extern char csv_sep;
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long (argc, argv, SHORT_OPTIONS,
|
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
|
||||||
long_options, &option_index);
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch(c) {
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_model = atoi(optarg);
|
my_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_file = optarg;
|
rig_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
civaddr = optarg;
|
civaddr = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_rate = atoi(optarg);
|
serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*conf_parms != '\0')
|
|
||||||
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN-strlen(conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
csv_sep = optarg[0];
|
csv_sep = optarg[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
all++;
|
all++;
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_XML2
|
#ifdef HAVE_XML2
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
xml++;
|
xml++;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_set_debug(verbose<2 ? RIG_DEBUG_WARN: verbose);
|
rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rigmem, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rigmem, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
|
"Report bugs to "
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
if (optind+1 >= argc) {
|
if (optind + 1 >= argc) {
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -199,23 +219,30 @@ int main (int argc, char *argv[])
|
||||||
rig = rig_init(my_model);
|
rig = rig_init(my_model);
|
||||||
|
|
||||||
if (!rig) {
|
if (!rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rig num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(rig, conf_parms);
|
retcode = set_conf(rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check channel support */
|
/* check channel support */
|
||||||
if (rig->caps->set_channel == NULL && rig->caps->get_channel == NULL &&
|
if (rig->caps->set_channel == NULL
|
||||||
rig->caps->set_chan_all_cb == NULL && rig->caps->get_chan_all_cb == NULL &&
|
&& rig->caps->get_channel == NULL
|
||||||
(rig->caps->set_mem == NULL || rig->caps->set_vfo == NULL)) {
|
&& rig->caps->set_chan_all_cb == NULL
|
||||||
fprintf(stderr, "Error: rig num %d has no memory support implemented/available.\n",
|
&& rig->caps->get_chan_all_cb == NULL
|
||||||
|
&& (rig->caps->set_mem == NULL || rig->caps->set_vfo == NULL)) {
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: rig num %d has no memory support implemented/available.\n",
|
||||||
my_model);
|
my_model);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
@ -227,56 +254,66 @@ int main (int argc, char *argv[])
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file) {
|
||||||
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
rig->state.rigport.parm.serial.rate = serial_rate;
|
rig->state.rigport.parm.serial.rate = serial_rate;
|
||||||
if (civaddr)
|
}
|
||||||
|
|
||||||
|
if (civaddr) {
|
||||||
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
||||||
|
}
|
||||||
|
|
||||||
retcode = rig_open(rig);
|
retcode = rig_open(rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rig model %d, '%s'\n", rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
rig->caps->rig_model,
|
||||||
rig->caps->model_name);
|
rig->caps->model_name);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
}
|
||||||
rig->caps->version, rig_strstatus(rig->caps->status));
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
|
"Backend version: %s, Status: %s\n",
|
||||||
|
rig->caps->version,
|
||||||
|
rig_strstatus(rig->caps->status));
|
||||||
|
|
||||||
/* on some rigs, this accelerates the backup/restore */
|
/* on some rigs, this accelerates the backup/restore */
|
||||||
rig_set_vfo(rig, RIG_VFO_MEM);
|
rig_set_vfo(rig, RIG_VFO_MEM);
|
||||||
|
|
||||||
if (!strcmp(argv[optind], "save")) {
|
if (!strcmp(argv[optind], "save")) {
|
||||||
if (xml)
|
if (xml) {
|
||||||
retcode = xml_save(rig, argv[optind+1]);
|
retcode = xml_save(rig, argv[optind + 1]);
|
||||||
else
|
} else {
|
||||||
retcode = csv_save(rig, argv[optind+1]);
|
retcode = csv_save(rig, argv[optind + 1]);
|
||||||
} else
|
}
|
||||||
if (!strcmp(argv[optind], "load")) {
|
} else if (!strcmp(argv[optind], "load")) {
|
||||||
if (xml)
|
if (xml) {
|
||||||
retcode = xml_load(rig, argv[optind+1]);
|
retcode = xml_load(rig, argv[optind + 1]);
|
||||||
else
|
} else {
|
||||||
retcode = csv_load(rig, argv[optind+1]);
|
retcode = csv_load(rig, argv[optind + 1]);
|
||||||
} else
|
}
|
||||||
if (!strcmp(argv[optind], "save_parm")) {
|
} else if (!strcmp(argv[optind], "save_parm")) {
|
||||||
if (xml)
|
if (xml) {
|
||||||
retcode = xml_parm_save(rig, argv[optind+1]);
|
retcode = xml_parm_save(rig, argv[optind + 1]);
|
||||||
else
|
} else {
|
||||||
retcode = csv_parm_save(rig, argv[optind+1]);
|
retcode = csv_parm_save(rig, argv[optind + 1]);
|
||||||
} else
|
}
|
||||||
if (!strcmp(argv[optind], "load_parm")) {
|
} else if (!strcmp(argv[optind], "load_parm")) {
|
||||||
if (xml)
|
if (xml) {
|
||||||
retcode = xml_parm_load(rig, argv[optind+1]);
|
retcode = xml_parm_load(rig, argv[optind + 1]);
|
||||||
else
|
} else {
|
||||||
retcode = csv_parm_load(rig, argv[optind+1]);
|
retcode = csv_parm_load(rig, argv[optind + 1]);
|
||||||
} else
|
}
|
||||||
if (!strcmp(argv[optind], "clear")) {
|
} else if (!strcmp(argv[optind], "clear")) {
|
||||||
retcode = clear_chans(rig, argv[optind+1]);
|
retcode = clear_chans(rig, argv[optind + 1]);
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -294,13 +331,13 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void version()
|
void version()
|
||||||
{
|
{
|
||||||
printf("rigmem, %s\n\n", hamlib_version);
|
printf("rigmem, %s\n\n", hamlib_version);
|
||||||
printf("%s\n", hamlib_copyright);
|
printf("%s\n", hamlib_copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("Usage: rigmem [OPTION]... COMMAND...FILE\n"
|
printf("Usage: rigmem [OPTION]... COMMAND...FILE\n"
|
||||||
|
@ -336,26 +373,38 @@ void usage()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_conf(RIG *rig, char *conf_parms)
|
int set_conf(RIG *rig, char *conf_parms)
|
||||||
{
|
{
|
||||||
char *p, *q, *n;
|
char *p, *q, *n;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
p = conf_parms;
|
p = conf_parms;
|
||||||
|
|
||||||
while (p && *p != '\0') {
|
while (p && *p != '\0') {
|
||||||
/* FIXME: left hand value of = cannot be null */
|
/* FIXME: left hand value of = cannot be null */
|
||||||
q = strchr(p, '=');
|
q = strchr(p, '=');
|
||||||
if ( !q )
|
|
||||||
|
if (!q) {
|
||||||
return RIG_EINVAL;
|
return RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
n = strchr(q, ',');
|
n = strchr(q, ',');
|
||||||
if (n) *n++ = '\0';
|
|
||||||
|
if (n) {
|
||||||
|
*n++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
||||||
if (ret != RIG_OK)
|
|
||||||
|
if (ret != RIG_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,9 +412,9 @@ int set_conf(RIG *rig, char *conf_parms)
|
||||||
/*
|
/*
|
||||||
* Pretty nasty, clears everything you have in rig memory
|
* Pretty nasty, clears everything you have in rig memory
|
||||||
*/
|
*/
|
||||||
int clear_chans (RIG *rig, const char *infilename)
|
int clear_chans(RIG *rig, const char *infilename)
|
||||||
{
|
{
|
||||||
int i,j,ret;
|
int i, j, ret;
|
||||||
channel_t chan;
|
channel_t chan;
|
||||||
|
|
||||||
memset(&chan, 0, sizeof(chan));
|
memset(&chan, 0, sizeof(chan));
|
||||||
|
@ -375,11 +424,13 @@ int clear_chans (RIG *rig, const char *infilename)
|
||||||
chan.tx_mode = RIG_MODE_NONE;
|
chan.tx_mode = RIG_MODE_NONE;
|
||||||
chan.vfo = RIG_VFO_MEM;
|
chan.vfo = RIG_VFO_MEM;
|
||||||
|
|
||||||
for (i=0; rig->state.chan_list[i].type && i < CHANLSTSIZ; i++) {
|
for (i = 0; rig->state.chan_list[i].type && i < CHANLSTSIZ; i++) {
|
||||||
for (j = rig->state.chan_list[i].start;
|
for (j = rig->state.chan_list[i].start;
|
||||||
j <= rig->state.chan_list[i].end; j++) {
|
j <= rig->state.chan_list[i].end; j++) {
|
||||||
|
|
||||||
chan.channel_num = j;
|
chan.channel_num = j;
|
||||||
ret = rig_set_channel(rig, &chan);
|
ret = rig_set_channel(rig, &chan);
|
||||||
|
|
||||||
if (ret != RIG_OK) {
|
if (ret != RIG_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -388,4 +439,3 @@ int clear_chans (RIG *rig, const char *infilename)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
173
tests/rigsmtr.c
173
tests/rigsmtr.c
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -53,8 +53,7 @@ static int set_conf_rot(ROT *rot, char *conf_parms);
|
||||||
* NB: do NOT use -W since it's reserved by POSIX.
|
* NB: do NOT use -W since it's reserved by POSIX.
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "m:r:s:c:C:M:R:S:N:vhV"
|
#define SHORT_OPTIONS "m:r:s:c:C:M:R:S:N:vhV"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
{"rig-file", 1, 0, 'r'},
|
{"rig-file", 1, 0, 'r'},
|
||||||
{"serial-speed", 1, 0, 's'},
|
{"serial-speed", 1, 0, 's'},
|
||||||
|
@ -73,7 +72,7 @@ static struct option long_options[] =
|
||||||
#define MAXCONFLEN 128
|
#define MAXCONFLEN 128
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *rig; /* handle to rig (instance) */
|
RIG *rig; /* handle to rig (instance) */
|
||||||
ROT *rot; /* handle to rotator (instance) */
|
ROT *rot; /* handle to rotator (instance) */
|
||||||
|
@ -83,7 +82,7 @@ int main (int argc, char *argv[])
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
const char *rig_file=NULL, *rot_file=NULL;
|
const char *rig_file = NULL, *rot_file = NULL;
|
||||||
int serial_rate = 0;
|
int serial_rate = 0;
|
||||||
int rot_serial_rate = 0;
|
int rot_serial_rate = 0;
|
||||||
char *civaddr = NULL; /* NULL means no need to set conf */
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
||||||
|
@ -95,103 +94,129 @@ int main (int argc, char *argv[])
|
||||||
elevation_t elevation;
|
elevation_t elevation;
|
||||||
unsigned step = 1000000; /* 1e6 us */
|
unsigned step = 1000000; /* 1e6 us */
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long (argc, argv, SHORT_OPTIONS,
|
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
|
||||||
long_options, &option_index);
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch(c) {
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_model = atoi(optarg);
|
rig_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_file = optarg;
|
rig_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
civaddr = optarg;
|
civaddr = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_rate = atoi(optarg);
|
serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*rig_conf_parms != '\0')
|
|
||||||
|
if (*rig_conf_parms != '\0') {
|
||||||
strcat(rig_conf_parms, ",");
|
strcat(rig_conf_parms, ",");
|
||||||
strncat(rig_conf_parms, optarg, MAXCONFLEN-strlen(rig_conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(rig_conf_parms, optarg, MAXCONFLEN - strlen(rig_conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rot_model = atoi(optarg);
|
rot_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rot_file = optarg;
|
rot_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rot_serial_rate = atoi(optarg);
|
rot_serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*rot_conf_parms != '\0')
|
|
||||||
|
if (*rot_conf_parms != '\0') {
|
||||||
strcat(rot_conf_parms, ",");
|
strcat(rot_conf_parms, ",");
|
||||||
strncat(rot_conf_parms, optarg, MAXCONFLEN-strlen(rot_conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(rot_conf_parms, optarg, MAXCONFLEN - strlen(rot_conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_set_debug(verbose<2 ? RIG_DEBUG_WARN: verbose);
|
rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rigsmtr, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rigsmtr, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The radio
|
* The radio
|
||||||
|
@ -199,44 +224,55 @@ int main (int argc, char *argv[])
|
||||||
rig = rig_init(rig_model);
|
rig = rig_init(rig_model);
|
||||||
|
|
||||||
if (!rig) {
|
if (!rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rig num %d, or initialization error.\n",
|
||||||
rig_model);
|
rig_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf_rig(rig, rig_conf_parms);
|
retcode = set_conf_rig(rig, rig_conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file) {
|
||||||
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
rig->state.rigport.parm.serial.rate = serial_rate;
|
rig->state.rigport.parm.serial.rate = serial_rate;
|
||||||
if (civaddr)
|
}
|
||||||
|
|
||||||
|
if (civaddr) {
|
||||||
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!rig_has_get_level(rig,RIG_LEVEL_STRENGTH)) {
|
if (!rig_has_get_level(rig, RIG_LEVEL_STRENGTH)) {
|
||||||
fprintf(stderr,"rig backend for %s could not get S-Meter"
|
fprintf(stderr,
|
||||||
|
"rig backend for %s could not get S-Meter"
|
||||||
"or has unsufficient capability\nSorry\n",
|
"or has unsufficient capability\nSorry\n",
|
||||||
rig->caps->model_name);
|
rig->caps->model_name);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_open(rig);
|
retcode = rig_open(rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rig model %d, '%s'\n", rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
rig->caps->rig_model,
|
||||||
rig->caps->model_name);
|
rig->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The rotator
|
* The rotator
|
||||||
|
@ -244,28 +280,34 @@ int main (int argc, char *argv[])
|
||||||
rot = rot_init(rot_model);
|
rot = rot_init(rot_model);
|
||||||
|
|
||||||
if (!rot) {
|
if (!rot) {
|
||||||
fprintf(stderr, "Unknown rot num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rot num %d, or initialization error.\n",
|
||||||
rot_model);
|
rot_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf_rot(rot, rot_conf_parms);
|
retcode = set_conf_rot(rot, rot_conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rot_file)
|
if (rot_file) {
|
||||||
strncpy(rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
strncpy(rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (rot_serial_rate != 0)
|
if (rot_serial_rate != 0) {
|
||||||
rot->state.rotport.parm.serial.rate = rot_serial_rate;
|
rot->state.rotport.parm.serial.rate = rot_serial_rate;
|
||||||
|
}
|
||||||
|
|
||||||
retcode = rot_open(rot);
|
retcode = rot_open(rot);
|
||||||
|
|
||||||
if (retcode != RIG_OK && rot_model != ROT_MODEL_DUMMY) {
|
if (retcode != RIG_OK && rot_model != ROT_MODEL_DUMMY) {
|
||||||
fprintf(stderr,"rot_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rot_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,26 +317,29 @@ int main (int argc, char *argv[])
|
||||||
/* if (rot_model == ROT_MODEL_DUMMY) */
|
/* if (rot_model == ROT_MODEL_DUMMY) */
|
||||||
/* with_rot = 1; */
|
/* with_rot = 1; */
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rotator model %d, '%s'\n", rot->caps->rot_model,
|
printf("Opened rotator model %d, '%s'\n",
|
||||||
|
rot->caps->rot_model,
|
||||||
rot->caps->model_name);
|
rot->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************/
|
/*******************************/
|
||||||
if (optind < argc)
|
if (optind < argc) {
|
||||||
step = atof(argv[optind])*1e6;
|
step = atof(argv[optind]) * 1e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Setting rotator to azimuth %.1f°\n", rot->state.min_az);
|
||||||
|
rot_set_position(rot, rot->state.min_az, 0);
|
||||||
|
fprintf(stderr, "Wait for rotator to move...\n");
|
||||||
|
rot_get_position(rot, &azimuth, &elevation);
|
||||||
|
|
||||||
fprintf(stderr,"Setting rotator to azimuth %.1f°\n",rot->state.min_az);
|
|
||||||
rot_set_position (rot, rot->state.min_az, 0);
|
|
||||||
fprintf(stderr,"Wait for rotator to move...\n");
|
|
||||||
rot_get_position (rot, &azimuth, &elevation);
|
|
||||||
while (fabs(azimuth - rot->state.min_az) > 1.) {
|
while (fabs(azimuth - rot->state.min_az) > 1.) {
|
||||||
rot_get_position (rot, &azimuth, &elevation);
|
rot_get_position(rot, &azimuth, &elevation);
|
||||||
usleep(step);
|
usleep(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,"Now initiating full 360° rotation...\n");
|
fprintf(stderr, "Now initiating full 360° rotation...\n");
|
||||||
rot_set_position (rot, rot->state.max_az, 0);
|
rot_set_position(rot, rot->state.max_az, 0);
|
||||||
|
|
||||||
/* TODO: check CW or CCW */
|
/* TODO: check CW or CCW */
|
||||||
/* disable AGC? */
|
/* disable AGC? */
|
||||||
|
@ -302,9 +347,9 @@ int main (int argc, char *argv[])
|
||||||
while (fabs(rot->state.max_az - azimuth) > 1.) {
|
while (fabs(rot->state.max_az - azimuth) > 1.) {
|
||||||
value_t strength;
|
value_t strength;
|
||||||
|
|
||||||
rig_get_level(rig,RIG_VFO_CURR,RIG_LEVEL_STRENGTH,&strength);
|
rig_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_STRENGTH, &strength);
|
||||||
|
|
||||||
rot_get_position (rot, &azimuth, &elevation);
|
rot_get_position(rot, &azimuth, &elevation);
|
||||||
|
|
||||||
printf("%.1f %d\n", azimuth, strength.i);
|
printf("%.1f %d\n", azimuth, strength.i);
|
||||||
}
|
}
|
||||||
|
@ -323,6 +368,7 @@ void version()
|
||||||
printf("%s\n", hamlib_copyright);
|
printf("%s\n", hamlib_copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("Usage: rigsmtr [OPTION]... [time]\n"
|
printf("Usage: rigsmtr [OPTION]... [time]\n"
|
||||||
|
@ -347,46 +393,71 @@ void usage()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_conf_rig(RIG *rig, char *conf_parms)
|
int set_conf_rig(RIG *rig, char *conf_parms)
|
||||||
{
|
{
|
||||||
char *p, *q, *n;
|
char *p, *q, *n;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
p = conf_parms;
|
p = conf_parms;
|
||||||
|
|
||||||
while (p && *p != '\0') {
|
while (p && *p != '\0') {
|
||||||
/* FIXME: left hand value of = cannot be null */
|
/* FIXME: left hand value of = cannot be null */
|
||||||
q = strchr(p, '=');
|
q = strchr(p, '=');
|
||||||
if ( !q )
|
|
||||||
|
if (!q) {
|
||||||
return RIG_EINVAL;
|
return RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
n = strchr(q, ',');
|
n = strchr(q, ',');
|
||||||
if (n) *n++ = '\0';
|
|
||||||
|
if (n) {
|
||||||
|
*n++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
||||||
if (ret != RIG_OK)
|
|
||||||
|
if (ret != RIG_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_conf_rot(ROT *rot, char *conf_parms)
|
int set_conf_rot(ROT *rot, char *conf_parms)
|
||||||
{
|
{
|
||||||
char *p, *q, *n;
|
char *p, *q, *n;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
p = conf_parms;
|
p = conf_parms;
|
||||||
|
|
||||||
while (p && *p != '\0') {
|
while (p && *p != '\0') {
|
||||||
/* FIXME: left hand value of = cannot be null */
|
/* FIXME: left hand value of = cannot be null */
|
||||||
q = strchr(p, '=');
|
q = strchr(p, '=');
|
||||||
if (q) *q++ = '\0';
|
|
||||||
|
if (q) {
|
||||||
|
*q++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
n = strchr(q, ',');
|
n = strchr(q, ',');
|
||||||
if (n) *n++ = '\0';
|
|
||||||
|
if (n) {
|
||||||
|
*n++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
ret = rot_set_conf(rot, rot_token_lookup(rot, p), q);
|
ret = rot_set_conf(rot, rot_token_lookup(rot, p), q);
|
||||||
if (ret != RIG_OK)
|
|
||||||
|
if (ret != RIG_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
166
tests/rigswr.c
166
tests/rigswr.c
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* rigswr.c - (C) Stephane Fillod and Thierry Leconte 2004
|
* rigswr.c - (C) Stephane Fillod and Thierry Leconte 2004
|
||||||
*
|
*
|
||||||
* This program output swr curve value
|
* This program outputs an swr curve value using Hamlib.
|
||||||
* using Hamlib.
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -22,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -51,8 +50,7 @@ static int set_conf(RIG *rig, char *conf_parms);
|
||||||
* NB: do NOT use -W since it's reserved by POSIX.
|
* NB: do NOT use -W since it's reserved by POSIX.
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "m:r:s:c:C:p:P:vhV"
|
#define SHORT_OPTIONS "m:r:s:c:C:p:P:vhV"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
{"rig-file", 1, 0, 'r'},
|
{"rig-file", 1, 0, 'r'},
|
||||||
{"serial-speed", 1, 0, 's'},
|
{"serial-speed", 1, 0, 's'},
|
||||||
|
@ -69,7 +67,7 @@ static struct option long_options[] =
|
||||||
#define MAXCONFLEN 128
|
#define MAXCONFLEN 128
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *rig; /* handle to rig (nstance) */
|
RIG *rig; /* handle to rig (nstance) */
|
||||||
rig_model_t my_model = RIG_MODEL_DUMMY;
|
rig_model_t my_model = RIG_MODEL_DUMMY;
|
||||||
|
@ -77,109 +75,131 @@ int main (int argc, char *argv[])
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
const char *rig_file=NULL, *ptt_file=NULL;
|
const char *rig_file = NULL, *ptt_file = NULL;
|
||||||
ptt_type_t ptt_type = RIG_PTT_NONE;
|
ptt_type_t ptt_type = RIG_PTT_NONE;
|
||||||
int serial_rate = 0;
|
int serial_rate = 0;
|
||||||
char *civaddr = NULL; /* NULL means no need to set conf */
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
||||||
char conf_parms[MAXCONFLEN] = "";
|
char conf_parms[MAXCONFLEN] = "";
|
||||||
freq_t freq,freqstop;
|
freq_t freq, freqstop;
|
||||||
freq_t step=kHz(100);
|
freq_t step = kHz(100);
|
||||||
value_t pwr;
|
value_t pwr;
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long (argc, argv, SHORT_OPTIONS,
|
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
|
||||||
long_options, &option_index);
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch(c) {
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_model = atoi(optarg);
|
my_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_file = optarg;
|
rig_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
civaddr = optarg;
|
civaddr = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_rate = atoi(optarg);
|
serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*conf_parms != '\0')
|
|
||||||
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN-strlen(conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptt_file = optarg;
|
ptt_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!strcmp(optarg, "RIG"))
|
|
||||||
|
if (!strcmp(optarg, "RIG")) {
|
||||||
ptt_type = RIG_PTT_RIG;
|
ptt_type = RIG_PTT_RIG;
|
||||||
else if (!strcmp(optarg, "DTR"))
|
} else if (!strcmp(optarg, "DTR")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_DTR;
|
ptt_type = RIG_PTT_SERIAL_DTR;
|
||||||
else if (!strcmp(optarg, "RTS"))
|
} else if (!strcmp(optarg, "RTS")) {
|
||||||
ptt_type = RIG_PTT_SERIAL_RTS;
|
ptt_type = RIG_PTT_SERIAL_RTS;
|
||||||
else if (!strcmp(optarg, "PARALLEL"))
|
} else if (!strcmp(optarg, "PARALLEL")) {
|
||||||
ptt_type = RIG_PTT_PARALLEL;
|
ptt_type = RIG_PTT_PARALLEL;
|
||||||
else if (!strcmp(optarg, "NONE"))
|
} else if (!strcmp(optarg, "NONE")) {
|
||||||
ptt_type = RIG_PTT_NONE;
|
ptt_type = RIG_PTT_NONE;
|
||||||
else
|
} else {
|
||||||
ptt_type = atoi(optarg);
|
ptt_type = atoi(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_set_debug(verbose<2 ? RIG_DEBUG_WARN: verbose);
|
rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rigswr, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rigswr, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
if (optind+1 >= argc) {
|
if (optind + 1 >= argc) {
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -187,73 +207,91 @@ int main (int argc, char *argv[])
|
||||||
rig = rig_init(my_model);
|
rig = rig_init(my_model);
|
||||||
|
|
||||||
if (!rig) {
|
if (!rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rig num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(rig, conf_parms);
|
retcode = set_conf(rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptt_type != RIG_PTT_NONE)
|
if (ptt_type != RIG_PTT_NONE) {
|
||||||
rig->state.pttport.type.ptt = ptt_type;
|
rig->state.pttport.type.ptt = ptt_type;
|
||||||
if (ptt_file)
|
}
|
||||||
strncpy(rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
|
||||||
|
|
||||||
if (rig_file)
|
if (ptt_file) {
|
||||||
|
strncpy(rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rig_file) {
|
||||||
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
rig->state.rigport.parm.serial.rate = serial_rate;
|
rig->state.rigport.parm.serial.rate = serial_rate;
|
||||||
if (civaddr)
|
}
|
||||||
|
|
||||||
|
if (civaddr) {
|
||||||
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!rig_has_get_level(rig,RIG_LEVEL_SWR) ||
|
if (!rig_has_get_level(rig, RIG_LEVEL_SWR)
|
||||||
rig->state.pttport.type.ptt == RIG_PTT_NONE) {
|
|| rig->state.pttport.type.ptt == RIG_PTT_NONE) {
|
||||||
fprintf(stderr,"rig backend for %s could not get SWR"
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"rig backend for %s could not get SWR"
|
||||||
"or has unsufficient capability\nSorry\n",
|
"or has unsufficient capability\nSorry\n",
|
||||||
rig->caps->model_name);
|
rig->caps->model_name);
|
||||||
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_open(rig);
|
retcode = rig_open(rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rig model %d, '%s'\n", rig->caps->rig_model,
|
printf("Opened rig model %d, '%s'\n",
|
||||||
|
rig->caps->rig_model,
|
||||||
rig->caps->model_name);
|
rig->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
freq=atof(argv[optind++]);
|
freq = atof(argv[optind++]);
|
||||||
freqstop=atof(argv[optind++]);
|
freqstop = atof(argv[optind++]);
|
||||||
if (optind < argc)
|
|
||||||
step=atof(argv[optind]);
|
|
||||||
|
|
||||||
rig_set_freq(rig,RIG_VFO_CURR,freq);
|
if (optind < argc) {
|
||||||
rig_set_mode(rig,RIG_VFO_CURR,RIG_MODE_CW,RIG_PASSBAND_NORMAL);
|
step = atof(argv[optind]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rig_set_freq(rig, RIG_VFO_CURR, freq);
|
||||||
|
rig_set_mode(rig, RIG_VFO_CURR, RIG_MODE_CW, RIG_PASSBAND_NORMAL);
|
||||||
|
|
||||||
pwr.f = 0.25; /* 25% of RF POWER */
|
pwr.f = 0.25; /* 25% of RF POWER */
|
||||||
rig_set_level(rig,RIG_VFO_CURR,RIG_LEVEL_RFPOWER,pwr);
|
rig_set_level(rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, pwr);
|
||||||
|
|
||||||
while(freq<=freqstop) {
|
while (freq <= freqstop) {
|
||||||
value_t swr;
|
value_t swr;
|
||||||
|
|
||||||
rig_set_ptt(rig,RIG_VFO_CURR,RIG_PTT_ON);
|
rig_set_ptt(rig, RIG_VFO_CURR, RIG_PTT_ON);
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
rig_get_level(rig,RIG_VFO_CURR,RIG_LEVEL_SWR,&swr);
|
rig_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_SWR, &swr);
|
||||||
rig_set_ptt(rig,RIG_VFO_CURR,RIG_PTT_OFF);
|
rig_set_ptt(rig, RIG_VFO_CURR, RIG_PTT_OFF);
|
||||||
|
|
||||||
printf("%10.0f %4.2f\n",freq,swr.f);
|
printf("%10.0f %4.2f\n", freq, swr.f);
|
||||||
freq+=step;
|
freq += step;
|
||||||
rig_set_freq(rig,RIG_VFO_CURR,freq);
|
rig_set_freq(rig, RIG_VFO_CURR, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_close(rig);
|
rig_close(rig);
|
||||||
|
@ -262,13 +300,13 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void version()
|
void version()
|
||||||
{
|
{
|
||||||
printf("rigswr, %s\n\n", hamlib_version);
|
printf("rigswr, %s\n\n", hamlib_version);
|
||||||
printf("%s\n", hamlib_copyright);
|
printf("%s\n", hamlib_copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("Usage: rigswr [OPTION]... start_freq stop_freq [freq_step]\n"
|
printf("Usage: rigswr [OPTION]... start_freq stop_freq [freq_step]\n"
|
||||||
|
@ -292,25 +330,37 @@ void usage()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_conf(RIG *rig, char *conf_parms)
|
int set_conf(RIG *rig, char *conf_parms)
|
||||||
{
|
{
|
||||||
char *p, *q, *n;
|
char *p, *q, *n;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
p = conf_parms;
|
p = conf_parms;
|
||||||
|
|
||||||
while (p && *p != '\0') {
|
while (p && *p != '\0') {
|
||||||
/* FIXME: left hand value of = cannot be null */
|
/* FIXME: left hand value of = cannot be null */
|
||||||
q = strchr(p, '=');
|
q = strchr(p, '=');
|
||||||
if ( !q )
|
|
||||||
|
if (!q) {
|
||||||
return RIG_EINVAL;
|
return RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
n = strchr(q, ',');
|
n = strchr(q, ',');
|
||||||
if (n) *n++ = '\0';
|
|
||||||
|
if (n) {
|
||||||
|
*n++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
||||||
if (ret != RIG_OK)
|
|
||||||
|
if (ret != RIG_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
148
tests/rotctl.c
148
tests/rotctl.c
|
@ -25,7 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
# elif defined(HAVE_READLINE_H) /* !defined(HAVE_READLINE_READLINE_H) */
|
# elif defined(HAVE_READLINE_H) /* !defined(HAVE_READLINE_READLINE_H) */
|
||||||
# include <readline.h>
|
# include <readline.h>
|
||||||
# else /* !defined(HAVE_READLINE_H) */
|
# else /* !defined(HAVE_READLINE_H) */
|
||||||
extern char *readline ();
|
extern char *readline();
|
||||||
# endif /* HAVE_READLINE_H */
|
# endif /* HAVE_READLINE_H */
|
||||||
#else
|
#else
|
||||||
/* no readline */
|
/* no readline */
|
||||||
|
@ -56,9 +56,9 @@ extern char *readline ();
|
||||||
# elif defined(HAVE_HISTORY_H)
|
# elif defined(HAVE_HISTORY_H)
|
||||||
# include <history.h>
|
# include <history.h>
|
||||||
# else /* !defined(HAVE_HISTORY_H) */
|
# else /* !defined(HAVE_HISTORY_H) */
|
||||||
extern void add_history ();
|
extern void add_history();
|
||||||
extern int write_history ();
|
extern int write_history();
|
||||||
extern int read_history ();
|
extern int read_history();
|
||||||
# endif /* defined(HAVE_READLINE_HISTORY_H) */
|
# endif /* defined(HAVE_READLINE_HISTORY_H) */
|
||||||
#else
|
#else
|
||||||
/* no history */
|
/* no history */
|
||||||
|
@ -83,16 +83,15 @@ void usage();
|
||||||
* TODO: add an option to read from a file
|
* TODO: add an option to read from a file
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "+m:r:s:C:t:LvhVlu"
|
#define SHORT_OPTIONS "+m:r:s:C:t:LvhVlu"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
{"rot-file", 1, 0, 'r'},
|
{"rot-file", 1, 0, 'r'},
|
||||||
{"serial-speed", 1, 0, 's'},
|
{"serial-speed", 1, 0, 's'},
|
||||||
{"send-cmd-term", 1, 0, 't'},
|
{"send-cmd-term", 1, 0, 't'},
|
||||||
{"list", 0, 0, 'l'},
|
{"list", 0, 0, 'l'},
|
||||||
{"set-conf", 1, 0, 'C'},
|
{"set-conf", 1, 0, 'C'},
|
||||||
{"show-conf",0, 0, 'L'},
|
{"show-conf", 0, 0, 'L'},
|
||||||
{"dump-caps",0, 0, 'u'},
|
{"dump-caps", 0, 0, 'u'},
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
{"read-history", 0, 0, 'i'},
|
{"read-history", 0, 0, 'i'},
|
||||||
{"save-history", 0, 0, 'I'},
|
{"save-history", 0, 0, 'I'},
|
||||||
|
@ -118,7 +117,8 @@ int prompt = 1; /* Print prompt in rotctl */
|
||||||
|
|
||||||
char send_cmd_term = '\r'; /* send_cmd termination char */
|
char send_cmd_term = '\r'; /* send_cmd termination char */
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ROT *my_rot; /* handle to rot (instance) */
|
ROT *my_rot; /* handle to rot (instance) */
|
||||||
rot_model_t my_model = ROT_MODEL_DUMMY;
|
rot_model_t my_model = ROT_MODEL_DUMMY;
|
||||||
|
@ -137,87 +137,114 @@ int main (int argc, char *argv[])
|
||||||
char *hist_path = NULL;
|
char *hist_path = NULL;
|
||||||
struct stat hist_dir_stat;
|
struct stat hist_dir_stat;
|
||||||
#endif
|
#endif
|
||||||
const char *rot_file=NULL;
|
const char *rot_file = NULL;
|
||||||
int serial_rate = 0;
|
int serial_rate = 0;
|
||||||
char conf_parms[MAXCONFLEN] = "";
|
char conf_parms[MAXCONFLEN] = "";
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long (argc, argv, SHORT_OPTIONS HST_SHRT_OPTS,
|
c = getopt_long(argc,
|
||||||
long_options, &option_index);
|
argv,
|
||||||
if (c == -1)
|
SHORT_OPTIONS HST_SHRT_OPTS,
|
||||||
break;
|
long_options,
|
||||||
|
&option_index);
|
||||||
|
|
||||||
switch(c) {
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_model = atoi(optarg);
|
my_model = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rot_file = optarg;
|
rot_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_rate = atoi(optarg);
|
serial_rate = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*conf_parms != '\0')
|
|
||||||
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN-strlen(conf_parms));
|
}
|
||||||
|
|
||||||
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
if (!optarg) {
|
if (!optarg) {
|
||||||
usage(); /* wrong arg count */
|
usage(); /* wrong arg count */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (strlen(optarg) > 1)
|
|
||||||
|
if (strlen(optarg) > 1) {
|
||||||
send_cmd_term = strtol(optarg, NULL, 0);
|
send_cmd_term = strtol(optarg, NULL, 0);
|
||||||
else
|
} else {
|
||||||
send_cmd_term = optarg[0];
|
send_cmd_term = optarg[0];
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
rd_hist++;
|
rd_hist++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
sv_hist++;
|
sv_hist++;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
show_conf++;
|
show_conf++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
rig_set_debug(0);
|
rig_set_debug(0);
|
||||||
list_models();
|
list_models();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
dump_caps_opt++;
|
dump_caps_opt++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -227,37 +254,43 @@ int main (int argc, char *argv[])
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rotctl, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rotctl, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* at least one command on command line,
|
* at least one command on command line,
|
||||||
* disable interactive mode
|
* disable interactive mode
|
||||||
*/
|
*/
|
||||||
if (optind < argc)
|
if (optind < argc) {
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
|
}
|
||||||
|
|
||||||
my_rot = rot_init(my_model);
|
my_rot = rot_init(my_model);
|
||||||
|
|
||||||
if (!my_rot) {
|
if (!my_rot) {
|
||||||
fprintf(stderr, "Unknown rot num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rot num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rot, conf_parms);
|
retcode = set_conf(my_rot, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rot_file)
|
if (rot_file) {
|
||||||
strncpy(my_rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
strncpy(my_rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
my_rot->state.rotport.parm.serial.rate = serial_rate;
|
my_rot->state.rotport.parm.serial.rate = serial_rate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out conf parameters
|
* print out conf parameters
|
||||||
|
@ -267,8 +300,8 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out capabilities, and exists immediately
|
* Print out capabilities, and exits immediately as we may be interested
|
||||||
* We may be interested only in caps, and rig_open may fail.
|
* only in caps, and rig_open may fail.
|
||||||
*/
|
*/
|
||||||
if (dump_caps_opt) {
|
if (dump_caps_opt) {
|
||||||
dumpcaps_rot(my_rot, stdout);
|
dumpcaps_rot(my_rot, stdout);
|
||||||
|
@ -277,68 +310,94 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rot_open(my_rot);
|
retcode = rot_open(my_rot);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr,"rot_open: error = %s \n", rigerror(retcode));
|
fprintf(stderr, "rot_open: error = %s \n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rot model %d, '%s'\n", my_rot->caps->rot_model,
|
printf("Opened rot model %d, '%s'\n",
|
||||||
|
my_rot->caps->rot_model,
|
||||||
my_rot->caps->model_name);
|
my_rot->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
my_rot->caps->version, rig_strstatus(my_rot->caps->status));
|
"Backend version: %s, Status: %s\n",
|
||||||
|
my_rot->caps->version,
|
||||||
|
rig_strstatus(my_rot->caps->status));
|
||||||
|
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
|
||||||
if (interactive && prompt && have_rl) {
|
if (interactive && prompt && have_rl) {
|
||||||
rl_readline_name = "rotctl";
|
rl_readline_name = "rotctl";
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
using_history(); /* Initialize Readline History */
|
using_history(); /* Initialize Readline History */
|
||||||
|
|
||||||
if (rd_hist || sv_hist) {
|
if (rd_hist || sv_hist) {
|
||||||
if (!(hist_dir = getenv("ROTCTL_HIST_DIR")))
|
if (!(hist_dir = getenv("ROTCTL_HIST_DIR"))) {
|
||||||
hist_dir = getenv("HOME");
|
hist_dir = getenv("HOME");
|
||||||
|
}
|
||||||
|
|
||||||
if (((stat(hist_dir, &hist_dir_stat) == -1) && (errno == ENOENT))
|
if (((stat(hist_dir, &hist_dir_stat) == -1) && (errno == ENOENT))
|
||||||
|| !(S_ISDIR(hist_dir_stat.st_mode))) {
|
|| !(S_ISDIR(hist_dir_stat.st_mode))) {
|
||||||
|
|
||||||
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
|
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
hist_path = (char *)calloc((sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1)), sizeof(char));
|
hist_path = (char *)calloc((sizeof(char)
|
||||||
|
* (strlen(hist_dir)
|
||||||
|
+ strlen(hist_file) + 1)),
|
||||||
|
sizeof(char));
|
||||||
|
|
||||||
strncpy(hist_path, hist_dir, strlen(hist_dir));
|
strncpy(hist_path, hist_dir, strlen(hist_dir));
|
||||||
strncat(hist_path, hist_file, strlen(hist_file));
|
strncat(hist_path, hist_file, strlen(hist_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rd_hist && hist_path)
|
if (rd_hist && hist_path) {
|
||||||
if (read_history(hist_path) == ENOENT)
|
if (read_history(hist_path) == ENOENT) {
|
||||||
fprintf(stderr, "Warning: Could not read history from %s\n", hist_path);
|
fprintf(stderr,
|
||||||
|
"Warning: Could not read history from %s\n",
|
||||||
|
hist_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LIBREADLINE */
|
#endif /* HAVE_LIBREADLINE */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
retcode = rotctl_parse(my_rot, stdin, stdout, argv, argc);
|
retcode = rotctl_parse(my_rot, stdin, stdout, argv, argc);
|
||||||
if (retcode == 2)
|
|
||||||
|
if (retcode == 2) {
|
||||||
exitcode = 2;
|
exitcode = 2;
|
||||||
}
|
}
|
||||||
while (retcode == 0 || retcode == 2);
|
} while (retcode == 0 || retcode == 2);
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
|
||||||
if (interactive && prompt && have_rl) {
|
if (interactive && prompt && have_rl) {
|
||||||
#ifdef HAVE_READLINE_HISTORY
|
#ifdef HAVE_READLINE_HISTORY
|
||||||
if (sv_hist && hist_path)
|
|
||||||
if (write_history(hist_path) == ENOENT)
|
if (sv_hist && hist_path) {
|
||||||
fprintf(stderr, "\nWarning: Could not write history to %s\n", hist_path);
|
if (write_history(hist_path) == ENOENT) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"\nWarning: Could not write history to %s\n",
|
||||||
|
hist_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((rd_hist || sv_hist) && hist_path) {
|
if ((rd_hist || sv_hist) && hist_path) {
|
||||||
free(hist_path);
|
free(hist_path);
|
||||||
hist_path = (char *)NULL;
|
hist_path = (char *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
rot_close(my_rot); /* close port */
|
rot_close(my_rot); /* close port */
|
||||||
rot_cleanup(my_rot); /* if you care about memory */
|
rot_cleanup(my_rot); /* if you care about memory */
|
||||||
|
@ -346,6 +405,7 @@ int main (int argc, char *argv[])
|
||||||
return exitcode;
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("Usage: rotctl [OPTION]... [COMMAND]...\n"
|
printf("Usage: rotctl [OPTION]... [COMMAND]...\n"
|
||||||
|
|
Plik diff jest za duży
Load Diff
|
@ -32,7 +32,7 @@
|
||||||
* external prototype
|
* external prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int dumpcaps_rot (ROT *, FILE *);
|
int dumpcaps_rot(ROT *, FILE *);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
144
tests/rotctld.c
144
tests/rotctld.c
|
@ -73,7 +73,7 @@ struct handle_data {
|
||||||
socklen_t clilen;
|
socklen_t clilen;
|
||||||
};
|
};
|
||||||
|
|
||||||
void *handle_socket(void *arg);
|
void * handle_socket(void *arg);
|
||||||
|
|
||||||
void usage();
|
void usage();
|
||||||
|
|
||||||
|
@ -120,14 +120,17 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
||||||
lpMsgBuf = (LPVOID)"Unknown error";
|
lpMsgBuf = (LPVOID)"Unknown error";
|
||||||
e = WSAGetLastError();
|
e = WSAGetLastError();
|
||||||
|
|
||||||
if (FormatMessage(
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
NULL,
|
||||||
NULL, e,
|
e,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
// Default language
|
// Default language
|
||||||
(LPTSTR)&lpMsgBuf, 0, NULL)) {
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR)&lpMsgBuf,
|
||||||
|
0,
|
||||||
|
NULL)) {
|
||||||
|
|
||||||
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, lpMsgBuf);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,6 +143,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ROT *my_rot; /* handle to rot (instance) */
|
ROT *my_rot; /* handle to rot (instance) */
|
||||||
|
@ -171,11 +175,11 @@ int main(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long(argc, argv, SHORT_OPTIONS,
|
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
|
||||||
long_options, &option_index);
|
|
||||||
|
|
||||||
if (c == -1)
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -219,8 +223,9 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*conf_parms != '\0')
|
if (*conf_parms != '\0') {
|
||||||
strcat(conf_parms, ",");
|
strcat(conf_parms, ",");
|
||||||
|
}
|
||||||
|
|
||||||
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||||
break;
|
break;
|
||||||
|
@ -268,14 +273,16 @@ int main(int argc, char *argv[])
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "rotctld, %s\n", hamlib_version);
|
rig_debug(RIG_DEBUG_VERBOSE, "rotctld, %s\n", hamlib_version);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||||
|
|
||||||
my_rot = rot_init(my_model);
|
my_rot = rot_init(my_model);
|
||||||
|
|
||||||
if (!my_rot) {
|
if (!my_rot) {
|
||||||
fprintf(stderr, "Unknown rot num %d, or initialization error.\n",
|
fprintf(stderr,
|
||||||
|
"Unknown rot num %d, or initialization error.\n",
|
||||||
my_model);
|
my_model);
|
||||||
|
|
||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -287,12 +294,14 @@ int main(int argc, char *argv[])
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rot_file)
|
if (rot_file) {
|
||||||
strncpy(my_rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
strncpy(my_rot->state.rotport.pathname, rot_file, FILPATHLEN - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: bound checking and port type == serial */
|
/* FIXME: bound checking and port type == serial */
|
||||||
if (serial_rate != 0)
|
if (serial_rate != 0) {
|
||||||
my_rot->state.rotport.parm.serial.rate = serial_rate;
|
my_rot->state.rotport.parm.serial.rate = serial_rate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out conf parameters
|
* print out conf parameters
|
||||||
|
@ -302,8 +311,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out conf parameters, and exits immediately
|
* Print out conf parameters, and exits immediately as we may be
|
||||||
* We may be interested only in only caps, and rig_open may fail.
|
* interested only in only caps, and rig_open may fail.
|
||||||
*/
|
*/
|
||||||
if (dump_caps_opt) {
|
if (dump_caps_opt) {
|
||||||
dumpcaps_rot(my_rot, stdout);
|
dumpcaps_rot(my_rot, stdout);
|
||||||
|
@ -318,12 +327,16 @@ int main(int argc, char *argv[])
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose > 0)
|
if (verbose > 0) {
|
||||||
printf("Opened rot model %d, '%s'\n", my_rot->caps->rot_model,
|
printf("Opened rot model %d, '%s'\n",
|
||||||
|
my_rot->caps->rot_model,
|
||||||
my_rot->caps->model_name);
|
my_rot->caps->model_name);
|
||||||
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
my_rot->caps->version, rig_strstatus(my_rot->caps->status));
|
"Backend version: %s, Status: %s\n",
|
||||||
|
my_rot->caps->version,
|
||||||
|
rig_strstatus(my_rot->caps->status));
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
# ifndef SO_OPENTYPE
|
# ifndef SO_OPENTYPE
|
||||||
|
@ -344,7 +357,11 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
sockopt = SO_SYNCHRONOUS_NONALERT;
|
sockopt = SO_SYNCHRONOUS_NONALERT;
|
||||||
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sockopt, sizeof(sockopt));
|
setsockopt(INVALID_SOCKET,
|
||||||
|
SOL_SOCKET,
|
||||||
|
SO_OPENTYPE,
|
||||||
|
(char *)&sockopt,
|
||||||
|
sizeof(sockopt));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -352,7 +369,7 @@ int main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||||
hints.ai_socktype = SOCK_STREAM;/* TCP socket */
|
hints.ai_socktype = SOCK_STREAM; /* TCP socket */
|
||||||
hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
|
hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
|
||||||
hints.ai_protocol = 0; /* Any protocol */
|
hints.ai_protocol = 0; /* Any protocol */
|
||||||
|
|
||||||
|
@ -366,7 +383,8 @@ int main(int argc, char *argv[])
|
||||||
saved_result = result;
|
saved_result = result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sock_listen = socket(result->ai_family, result->ai_socktype,
|
sock_listen = socket(result->ai_family,
|
||||||
|
result->ai_socktype,
|
||||||
result->ai_protocol);
|
result->ai_protocol);
|
||||||
|
|
||||||
if (sock_listen < 0) {
|
if (sock_listen < 0) {
|
||||||
|
@ -377,6 +395,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR,
|
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *)&reuseaddr, sizeof(reuseaddr)) < 0) {
|
(char *)&reuseaddr, sizeof(reuseaddr)) < 0) {
|
||||||
|
|
||||||
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
||||||
freeaddrinfo(result); /* No longer needed */
|
freeaddrinfo(result); /* No longer needed */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -389,8 +408,13 @@ int main(int argc, char *argv[])
|
||||||
to 1 i.e. disallowed */
|
to 1 i.e. disallowed */
|
||||||
sockopt = 0;
|
sockopt = 0;
|
||||||
|
|
||||||
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
|
if (setsockopt(sock_listen,
|
||||||
(char *)&sockopt, sizeof(sockopt)) < 0) {
|
IPPROTO_IPV6,
|
||||||
|
IPV6_V6ONLY,
|
||||||
|
(char *)&sockopt,
|
||||||
|
sizeof(sockopt))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
||||||
freeaddrinfo(saved_result); /* No longer needed */
|
freeaddrinfo(saved_result); /* No longer needed */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -429,15 +453,18 @@ int main(int argc, char *argv[])
|
||||||
inherit this disposition which is what we want. */
|
inherit this disposition which is what we want. */
|
||||||
#if HAVE_SIGACTION
|
#if HAVE_SIGACTION
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset (&act, 0, sizeof act);
|
memset(&act, 0, sizeof act);
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
act.sa_flags = SA_RESTART;
|
act.sa_flags = SA_RESTART;
|
||||||
if (sigaction (SIGPIPE, &act, NULL)) {
|
|
||||||
handle_error (RIG_DEBUG_ERR, "sigaction");
|
if (sigaction(SIGPIPE, &act, NULL)) {
|
||||||
|
handle_error(RIG_DEBUG_ERR, "sigaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_SIGNAL
|
#elif HAVE_SIGNAL
|
||||||
if (SIG_ERR == signal (SIGPIPE, SIG_IGN)))
|
|
||||||
handle_error (RIG_DEBUG_ERR, "signal");
|
if (SIG_ERR == signal(SIGPIPE, SIG_IGN)) {
|
||||||
|
handle_error(RIG_DEBUG_ERR, "signal");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -455,7 +482,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
arg->rot = my_rot;
|
arg->rot = my_rot;
|
||||||
arg->clilen = sizeof(arg->cli_addr);
|
arg->clilen = sizeof(arg->cli_addr);
|
||||||
arg->sock = accept(sock_listen, (struct sockaddr *) &arg->cli_addr,
|
arg->sock = accept(sock_listen,
|
||||||
|
(struct sockaddr *) &arg->cli_addr,
|
||||||
&arg->clilen);
|
&arg->clilen);
|
||||||
|
|
||||||
if (arg->sock < 0) {
|
if (arg->sock < 0) {
|
||||||
|
@ -463,14 +491,24 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retcode = getnameinfo((struct sockaddr const *)&arg->cli_addr, arg->clilen,
|
if ((retcode = getnameinfo((struct sockaddr const *)&arg->cli_addr,
|
||||||
host, sizeof(host), serv, sizeof(serv),
|
arg->clilen,
|
||||||
NI_NOFQDN)) < 0) {
|
host,
|
||||||
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
sizeof(host),
|
||||||
|
serv,
|
||||||
|
sizeof(serv),
|
||||||
|
NI_NOFQDN))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_WARN,
|
||||||
|
"Peer lookup error: %s",
|
||||||
|
gai_strerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Connection opened from %s:%s\n",
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
host, serv);
|
"Connection opened from %s:%s\n",
|
||||||
|
host,
|
||||||
|
serv);
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD
|
#ifdef HAVE_PTHREAD
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
|
@ -502,7 +540,7 @@ int main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* This is the function run by the threads
|
* This is the function run by the threads
|
||||||
*/
|
*/
|
||||||
void *handle_socket(void *arg)
|
void * handle_socket(void *arg)
|
||||||
{
|
{
|
||||||
struct handle_data *handle_data_arg = (struct handle_data *)arg;
|
struct handle_data *handle_data_arg = (struct handle_data *)arg;
|
||||||
FILE *fsockin;
|
FILE *fsockin;
|
||||||
|
@ -544,18 +582,29 @@ void *handle_socket(void *arg)
|
||||||
do {
|
do {
|
||||||
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
|
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
|
||||||
|
|
||||||
if (ferror(fsockin) || ferror(fsockout))
|
if (ferror(fsockin) || ferror(fsockout)) {
|
||||||
retcode = 1;
|
retcode = 1;
|
||||||
|
}
|
||||||
} while (retcode == 0 || retcode == 2);
|
} while (retcode == 0 || retcode == 2);
|
||||||
|
|
||||||
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
|
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
|
||||||
handle_data_arg->clilen, host, sizeof(host),
|
handle_data_arg->clilen,
|
||||||
serv, sizeof(serv), NI_NOFQDN)) < 0) {
|
host,
|
||||||
rig_debug(RIG_DEBUG_WARN, "Peer lookup error: %s", gai_strerror(retcode));
|
sizeof(host),
|
||||||
|
serv,
|
||||||
|
sizeof(serv),
|
||||||
|
NI_NOFQDN))
|
||||||
|
< 0) {
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_WARN,
|
||||||
|
"Peer lookup error: %s",
|
||||||
|
gai_strerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "Connection closed from %s:%s\n",
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
host, serv);
|
"Connection closed from %s:%s\n",
|
||||||
|
host,
|
||||||
|
serv);
|
||||||
|
|
||||||
fclose(fsockin);
|
fclose(fsockin);
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
|
@ -576,6 +625,7 @@ handle_exit:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("Usage: rotctld [OPTION]... [COMMAND]...\n"
|
printf("Usage: rotctld [OPTION]... [COMMAND]...\n"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -42,100 +42,150 @@
|
||||||
|
|
||||||
int sprintf_vfo(char *str, vfo_t vfo)
|
int sprintf_vfo(char *str, vfo_t vfo)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
const char *sv;
|
const char *sv;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (vfo == RIG_VFO_NONE)
|
|
||||||
return 0;
|
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_CURR);
|
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_MEM);
|
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_VFO);
|
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_MAIN);
|
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_SUB);
|
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
|
|
||||||
for (i=0; i<16; i++) {
|
if (vfo == RIG_VFO_NONE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sv = rig_strvfo(vfo & RIG_VFO_CURR);
|
||||||
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
sv = rig_strvfo(vfo & RIG_VFO_MEM);
|
||||||
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
sv = rig_strvfo(vfo & RIG_VFO_VFO);
|
||||||
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
sv = rig_strvfo(vfo & RIG_VFO_MAIN);
|
||||||
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
sv = rig_strvfo(vfo & RIG_VFO_SUB);
|
||||||
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
sv = rig_strvfo(vfo & RIG_VFO_N(i));
|
sv = rig_strvfo(vfo & RIG_VFO_N(i));
|
||||||
if (sv && sv[0]) len += sprintf(str+len, "%s ", sv);
|
|
||||||
|
if (sv && sv[0]) {
|
||||||
|
len += sprintf(str + len, "%s ", sv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_mode(char *str, rmode_t mode)
|
int sprintf_mode(char *str, rmode_t mode)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (mode == RIG_MODE_NONE)
|
|
||||||
|
if (mode == RIG_MODE_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 30; i++) {
|
for (i = 0; i < 30; i++) {
|
||||||
const char *ms = rig_strrmode(mode & (1UL<<i));
|
const char *ms = rig_strrmode(mode & (1UL << i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_func(char *str, setting_t func)
|
int sprintf_func(char *str, setting_t func)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (func == RIG_FUNC_NONE)
|
|
||||||
|
if (func == RIG_FUNC_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms = rig_strfunc(func & rig_idx2setting(i));
|
const char *ms = rig_strfunc(func & rig_idx2setting(i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_level(char *str, setting_t level)
|
int sprintf_level(char *str, setting_t level)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (level == RIG_LEVEL_NONE)
|
|
||||||
|
if (level == RIG_LEVEL_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms = rig_strlevel(level & rig_idx2setting(i));
|
const char *ms = rig_strlevel(level & rig_idx2setting(i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_level_ext(char *str, const struct confparams *extlevels)
|
int sprintf_level_ext(char *str, const struct confparams *extlevels)
|
||||||
{
|
{
|
||||||
int len=0;
|
int len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (!extlevels)
|
|
||||||
|
if (!extlevels) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (; extlevels->token != RIG_CONF_END; extlevels++) {
|
for (; extlevels->token != RIG_CONF_END; extlevels++) {
|
||||||
if (!extlevels->name)
|
if (!extlevels->name) {
|
||||||
continue; /* no name */
|
continue; /* no name */
|
||||||
|
}
|
||||||
|
|
||||||
switch (extlevels->type) {
|
switch (extlevels->type) {
|
||||||
case RIG_CONF_CHECKBUTTON:
|
case RIG_CONF_CHECKBUTTON:
|
||||||
case RIG_CONF_COMBO:
|
case RIG_CONF_COMBO:
|
||||||
|
@ -145,129 +195,186 @@ int sprintf_level_ext(char *str, const struct confparams *extlevels)
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(extlevels->name) + 1;
|
len += strlen(extlevels->name) + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_BUTTON:
|
case RIG_CONF_BUTTON:
|
||||||
/* ignore case RIG_CONF_BUTTON */
|
/* ignore case RIG_CONF_BUTTON */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_level_gran(char *str, setting_t level, const gran_t gran[])
|
int sprintf_level_gran(char *str, setting_t level, const gran_t gran[])
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (level == RIG_LEVEL_NONE)
|
|
||||||
|
if (level == RIG_LEVEL_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms;
|
const char *ms;
|
||||||
|
|
||||||
if (!(level & rig_idx2setting(i)))
|
if (!(level & rig_idx2setting(i))) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ms = rig_strlevel(level & rig_idx2setting(i));
|
ms = rig_strlevel(level & rig_idx2setting(i));
|
||||||
|
|
||||||
if (!ms || !ms[0]) {
|
if (!ms || !ms[0]) {
|
||||||
if (level != DUMMY_ALL && level != RIG_LEVEL_SET(DUMMY_ALL))
|
if (level != DUMMY_ALL && level != RIG_LEVEL_SET(DUMMY_ALL)) {
|
||||||
rig_debug(RIG_DEBUG_BUG, "unknown level idx %d\n", i);
|
rig_debug(RIG_DEBUG_BUG, "unknown level idx %d\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (RIG_LEVEL_IS_FLOAT(rig_idx2setting(i)))
|
|
||||||
len += sprintf(str+len, "%s(%g..%g/%g) ", ms,
|
if (RIG_LEVEL_IS_FLOAT(rig_idx2setting(i))) {
|
||||||
gran[i].min.f,gran[i].max.f,gran[i].step.f);
|
len += sprintf(str + len,
|
||||||
else
|
"%s(%g..%g/%g) ",
|
||||||
len += sprintf(str+len, "%s(%d..%d/%d) ", ms,
|
ms,
|
||||||
gran[i].min.i,gran[i].max.i,gran[i].step.i);
|
gran[i].min.f,
|
||||||
|
gran[i].max.f,
|
||||||
|
gran[i].step.f);
|
||||||
|
} else {
|
||||||
|
len += sprintf(str + len,
|
||||||
|
"%s(%d..%d/%d) ",
|
||||||
|
ms,
|
||||||
|
gran[i].min.i,
|
||||||
|
gran[i].max.i,
|
||||||
|
gran[i].step.i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_parm(char *str, setting_t parm)
|
int sprintf_parm(char *str, setting_t parm)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (parm == RIG_PARM_NONE)
|
|
||||||
|
if (parm == RIG_PARM_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms = rig_strparm(parm & rig_idx2setting(i));
|
const char *ms = rig_strparm(parm & rig_idx2setting(i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_parm_gran(char *str, setting_t parm, const gran_t gran[])
|
int sprintf_parm_gran(char *str, setting_t parm, const gran_t gran[])
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (parm == RIG_PARM_NONE)
|
|
||||||
|
if (parm == RIG_PARM_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
for (i = 0; i < RIG_SETTING_MAX; i++) {
|
||||||
const char *ms;
|
const char *ms;
|
||||||
if (!(parm & rig_idx2setting(i)))
|
|
||||||
|
if (!(parm & rig_idx2setting(i))) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ms = rig_strparm(parm & rig_idx2setting(i));
|
ms = rig_strparm(parm & rig_idx2setting(i));
|
||||||
|
|
||||||
if (!ms || !ms[0]) {
|
if (!ms || !ms[0]) {
|
||||||
if (parm != DUMMY_ALL && parm != RIG_PARM_SET(DUMMY_ALL))
|
if (parm != DUMMY_ALL && parm != RIG_PARM_SET(DUMMY_ALL)) {
|
||||||
rig_debug(RIG_DEBUG_BUG, "unknown parm idx %d\n", i);
|
rig_debug(RIG_DEBUG_BUG, "unknown parm idx %d\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (RIG_PARM_IS_FLOAT(rig_idx2setting(i)))
|
|
||||||
len += sprintf(str+len, "%s(%g..%g/%g) ", ms,
|
if (RIG_PARM_IS_FLOAT(rig_idx2setting(i))) {
|
||||||
gran[i].min.f,gran[i].max.f,gran[i].step.f);
|
len += sprintf(str + len,
|
||||||
else
|
"%s(%g..%g/%g) ",
|
||||||
len += sprintf(str+len, "%s(%d..%d/%d) ", ms,
|
ms,
|
||||||
gran[i].min.i,gran[i].max.i,gran[i].step.i);
|
gran[i].min.f,
|
||||||
|
gran[i].max.f,
|
||||||
|
gran[i].step.f);
|
||||||
|
} else {
|
||||||
|
len += sprintf(str + len,
|
||||||
|
"%s(%d..%d/%d) ",
|
||||||
|
ms,
|
||||||
|
gran[i].min.i,
|
||||||
|
gran[i].max.i,
|
||||||
|
gran[i].step.i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_vfop(char *str, vfo_op_t op)
|
int sprintf_vfop(char *str, vfo_op_t op)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (op == RIG_OP_NONE)
|
|
||||||
|
if (op == RIG_OP_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 30; i++) {
|
for (i = 0; i < 30; i++) {
|
||||||
const char *ms = rig_strvfop(op & (1UL<<i));
|
const char *ms = rig_strvfop(op & (1UL << i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sprintf_scan(char *str, scan_t rscan)
|
int sprintf_scan(char *str, scan_t rscan)
|
||||||
{
|
{
|
||||||
int i, len=0;
|
int i, len = 0;
|
||||||
|
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (rscan == RIG_SCAN_NONE)
|
|
||||||
|
if (rscan == RIG_SCAN_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 30; i++) {
|
for (i = 0; i < 30; i++) {
|
||||||
const char *ms = rig_strscan(rscan & (1UL<<i));
|
const char *ms = rig_strscan(rscan & (1UL << i));
|
||||||
if (!ms || !ms[0])
|
|
||||||
|
if (!ms || !ms[0]) {
|
||||||
continue; /* unknown, FIXME! */
|
continue; /* unknown, FIXME! */
|
||||||
|
}
|
||||||
|
|
||||||
strcat(str, ms);
|
strcat(str, ms);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
len += strlen(ms) + 1;
|
len += strlen(ms) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -15,40 +15,50 @@
|
||||||
|
|
||||||
#define MAXDIGITS 32
|
#define MAXDIGITS 32
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned char b[(MAXDIGITS+1)/2];
|
unsigned char b[(MAXDIGITS + 1) / 2];
|
||||||
freq_t f=0;
|
freq_t f = 0;
|
||||||
int digits = 10;
|
int digits = 10;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (argc != 2 && argc != 3) {
|
if (argc != 2 && argc != 3) {
|
||||||
fprintf(stderr,"Usage: %s <freq> [digits]\n",argv[0]);
|
fprintf(stderr, "Usage: %s <freq> [digits]\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
f = (freq_t)atoll(argv[1]);
|
f = (freq_t)atoll(argv[1]);
|
||||||
|
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
digits = atoi(argv[2]);
|
digits = atoi(argv[2]);
|
||||||
if (digits > MAXDIGITS)
|
|
||||||
|
if (digits > MAXDIGITS) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("Little Endian mode\n");
|
printf("Little Endian mode\n");
|
||||||
printf("Frequency: %"PRIfreq"\n",f);
|
printf("Frequency: %"PRIfreq"\n", f);
|
||||||
to_bcd(b, f, digits);
|
to_bcd(b, f, digits);
|
||||||
printf("BCD: %2.2x",b[0]);
|
printf("BCD: %2.2x", b[0]);
|
||||||
for (i = 1; i < (digits+1)/2; i++)
|
|
||||||
printf(",%2.2x",b[i]);
|
for (i = 1; i < (digits + 1) / 2; i++) {
|
||||||
|
printf(",%2.2x", b[i]);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\nResult after recoding: %"PRIll"\n", (int64_t)from_bcd(b, digits));
|
printf("\nResult after recoding: %"PRIll"\n", (int64_t)from_bcd(b, digits));
|
||||||
|
|
||||||
printf("\nBig Endian mode\n");
|
printf("\nBig Endian mode\n");
|
||||||
printf("Frequency: %"PRIfreq"\n",f);
|
printf("Frequency: %"PRIfreq"\n", f);
|
||||||
to_bcd_be(b, f, digits);
|
to_bcd_be(b, f, digits);
|
||||||
printf("BCD: %2.2x",b[0]);
|
printf("BCD: %2.2x", b[0]);
|
||||||
for (i = 1; i < (digits+1)/2; i++)
|
|
||||||
printf(",%2.2x",b[i]);
|
for (i = 1; i < (digits + 1) / 2; i++) {
|
||||||
printf("\nResult after recoding: %"PRIll"\n", (int64_t)from_bcd_be(b, digits));
|
printf(",%2.2x", b[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nResult after recoding: %"PRIll"\n",
|
||||||
|
(int64_t)from_bcd_be(b, digits));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -14,13 +14,14 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
freq_t f=0;
|
freq_t f = 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr,"Usage: %s <freq>\n",argv[0]);
|
fprintf(stderr, "Usage: %s <freq>\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,25 +17,29 @@
|
||||||
#include <hamlib/rotator.h>
|
#include <hamlib/rotator.h>
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
char recodedloc[13], *loc1, *loc2, sign;
|
char recodedloc[13], *loc1, *loc2, sign;
|
||||||
double lon1, lat1, lon2, lat2;
|
double lon1, lat1, lon2, lat2;
|
||||||
double distance, az, mmm, sec;
|
double distance, az, mmm, sec;
|
||||||
int deg, min, retcode, loc_len, nesw = 0;
|
int deg, min, retcode, loc_len, nesw = 0;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s <locator1> <precision> [<locator2>]\n", argv[0]);
|
fprintf(stderr,
|
||||||
|
"Usage: %s <locator1> <precision> [<locator2>]\n",
|
||||||
|
argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
loc1 = argv[1];
|
loc1 = argv[1];
|
||||||
loc_len = argc > 2 ? atoi(argv[2]) : strlen(loc1)/2;
|
loc_len = argc > 2 ? atoi(argv[2]) : strlen(loc1) / 2;
|
||||||
loc2 = argc > 3 ? argv[3] : NULL;
|
loc2 = argc > 3 ? argv[3] : NULL;
|
||||||
|
|
||||||
printf("Locator1:\t%s\n", loc1);
|
printf("Locator1:\t%s\n", loc1);
|
||||||
|
|
||||||
/* hamlib function to convert maidenhead to decimal degrees */
|
/* hamlib function to convert maidenhead to decimal degrees */
|
||||||
retcode = locator2longlat(&lon1, &lat1, loc1);
|
retcode = locator2longlat(&lon1, &lat1, loc1);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "locator2longlat() failed with malformed input.\n");
|
fprintf(stderr, "locator2longlat() failed with malformed input.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -43,14 +47,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg, min, sec */
|
/* hamlib function to convert decimal degrees to deg, min, sec */
|
||||||
retcode = dec2dms(lon1, °, &min, &sec, &nesw);
|
retcode = dec2dms(lon1, °, &min, &sec, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" Longitude:\t%f\t%c%d %d' %.2f\"\n", lon1, sign, deg, min, sec);
|
printf(" Longitude:\t%f\t%c%d %d' %.2f\"\n", lon1, sign, deg, min, sec);
|
||||||
|
|
||||||
/* hamlib function to convert deg, min, sec to decimal degrees */
|
/* hamlib function to convert deg, min, sec to decimal degrees */
|
||||||
|
@ -59,14 +67,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
||||||
retcode = dec2dmmm(lon1, °, &mmm, &nesw);
|
retcode = dec2dmmm(lon1, °, &mmm, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon1, sign, deg, mmm);
|
printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon1, sign, deg, mmm);
|
||||||
|
|
||||||
/* hamlib function to convert deg, decimal min to decimal degrees */
|
/* hamlib function to convert deg, decimal min to decimal degrees */
|
||||||
|
@ -75,14 +87,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg, min, sec */
|
/* hamlib function to convert decimal degrees to deg, min, sec */
|
||||||
retcode = dec2dms(lat1, °, &min, &sec, &nesw);
|
retcode = dec2dms(lat1, °, &min, &sec, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" Latitude:\t%f\t%c%d %d' %.2f\"\n", lat1, sign, deg, min, sec);
|
printf(" Latitude:\t%f\t%c%d %d' %.2f\"\n", lat1, sign, deg, min, sec);
|
||||||
|
|
||||||
/* hamlib function to convert deg, min, sec to decimal degrees */
|
/* hamlib function to convert deg, min, sec to decimal degrees */
|
||||||
|
@ -91,14 +107,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
||||||
retcode = dec2dmmm(lat1, °, &mmm, &nesw);
|
retcode = dec2dmmm(lat1, °, &mmm, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat1, sign, deg, mmm);
|
printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat1, sign, deg, mmm);
|
||||||
|
|
||||||
/* hamlib function to convert deg, decimal min to decimal degrees */
|
/* hamlib function to convert deg, decimal min to decimal degrees */
|
||||||
|
@ -107,19 +127,23 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to maidenhead */
|
/* hamlib function to convert decimal degrees to maidenhead */
|
||||||
retcode = longlat2locator(lon1, lat1, recodedloc, loc_len);
|
retcode = longlat2locator(lon1, lat1, recodedloc, loc_len);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "longlat2locator() failed, precision out of range.\n");
|
fprintf(stderr, "longlat2locator() failed, precision out of range.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Recoded:\t%s\n", recodedloc);
|
printf(" Recoded:\t%s\n", recodedloc);
|
||||||
|
|
||||||
if (loc2 == NULL)
|
if (loc2 == NULL) {
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Now work on the second locator */
|
/* Now work on the second locator */
|
||||||
printf("\nLocator2:\t%s\n", loc2);
|
printf("\nLocator2:\t%s\n", loc2);
|
||||||
|
|
||||||
retcode = locator2longlat(&lon2, &lat2, loc2);
|
retcode = locator2longlat(&lon2, &lat2, loc2);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "locator2longlat() failed with malformed input.\n");
|
fprintf(stderr, "locator2longlat() failed with malformed input.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -127,14 +151,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg, min, sec */
|
/* hamlib function to convert decimal degrees to deg, min, sec */
|
||||||
retcode = dec2dms(lon2, °, &min, &sec, &nesw);
|
retcode = dec2dms(lon2, °, &min, &sec, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" Longitude:\t%f\t%c%d %d' %.2f\"\n", lon2, sign, deg, min, sec);
|
printf(" Longitude:\t%f\t%c%d %d' %.2f\"\n", lon2, sign, deg, min, sec);
|
||||||
|
|
||||||
/* hamlib function to convert deg, min, sec to decimal degrees */
|
/* hamlib function to convert deg, min, sec to decimal degrees */
|
||||||
|
@ -143,14 +171,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
||||||
retcode = dec2dmmm(lon2, °, &mmm, &nesw);
|
retcode = dec2dmmm(lon2, °, &mmm, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon2, sign, deg, mmm);
|
printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon2, sign, deg, mmm);
|
||||||
|
|
||||||
/* hamlib function to convert deg, decimal min to decimal degrees */
|
/* hamlib function to convert deg, decimal min to decimal degrees */
|
||||||
|
@ -159,14 +191,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg, min, sec */
|
/* hamlib function to convert decimal degrees to deg, min, sec */
|
||||||
retcode = dec2dms(lat2, °, &min, &sec, &nesw);
|
retcode = dec2dms(lat2, °, &min, &sec, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dms() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" Latitude:\t%f\t%c%d %d' %.2f\"\n", lat2, sign, deg, min, sec);
|
printf(" Latitude:\t%f\t%c%d %d' %.2f\"\n", lat2, sign, deg, min, sec);
|
||||||
|
|
||||||
/* hamlib function to convert deg, min, sec to decimal degrees */
|
/* hamlib function to convert deg, min, sec to decimal degrees */
|
||||||
|
@ -175,14 +211,18 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
/* hamlib function to convert decimal degrees to deg decimal minutes */
|
||||||
retcode = dec2dmmm(lat2, °, &mmm, &nesw);
|
retcode = dec2dmmm(lat2, °, &mmm, &nesw);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
fprintf(stderr, "dec2dmmm() failed, invalid paramter address.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat2, sign, deg, mmm);
|
printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat2, sign, deg, mmm);
|
||||||
|
|
||||||
/* hamlib function to convert deg, decimal min to decimal degrees */
|
/* hamlib function to convert deg, decimal min to decimal degrees */
|
||||||
|
@ -191,13 +231,16 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
/* hamlib function to convert decimal degrees to maidenhead */
|
/* hamlib function to convert decimal degrees to maidenhead */
|
||||||
retcode = longlat2locator(lon2, lat2, recodedloc, loc_len);
|
retcode = longlat2locator(lon2, lat2, recodedloc, loc_len);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "longlat2locator() failed, precision out of range.\n");
|
fprintf(stderr, "longlat2locator() failed, precision out of range.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Recoded:\t%s\n", recodedloc);
|
printf(" Recoded:\t%s\n", recodedloc);
|
||||||
|
|
||||||
retcode = qrb(lon1, lat1, lon2, lat2, &distance, &az);
|
retcode = qrb(lon1, lat1, lon2, lat2, &distance, &az);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
fprintf(stderr, "QRB error: %d\n", retcode);
|
fprintf(stderr, "QRB error: %d\n", retcode);
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -205,10 +248,13 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
dec2dms(az, °, &min, &sec, &nesw);
|
dec2dms(az, °, &min, &sec, &nesw);
|
||||||
printf("\nDistance: %.6fkm\n", distance);
|
printf("\nDistance: %.6fkm\n", distance);
|
||||||
if (nesw == 1)
|
|
||||||
|
if (nesw == 1) {
|
||||||
sign = '-';
|
sign = '-';
|
||||||
else
|
} else {
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/* Beware printf() rounding error! */
|
/* Beware printf() rounding error! */
|
||||||
printf("Bearing: %.2f, %c%d %d' %.2f\"\n", az, sign, deg, min, sec);
|
printf("Bearing: %.2f, %c%d %d' %.2f\"\n", az, sign, deg, min, sec);
|
||||||
|
|
||||||
|
|
108
tests/testrig.c
108
tests/testrig.c
|
@ -10,7 +10,7 @@
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
||||||
|
@ -27,13 +27,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
|
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
|
||||||
#include "hl_sleep.h"
|
# include "hl_sleep.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define SERIAL_PORT "/dev/ttyS0"
|
#define SERIAL_PORT "/dev/ttyS0"
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig; /* handle to rig (nstance) */
|
RIG *my_rig; /* handle to rig (nstance) */
|
||||||
freq_t freq; /* frequency */
|
freq_t freq; /* frequency */
|
||||||
|
@ -77,14 +77,15 @@ int main (int argc, char *argv[])
|
||||||
my_rig = rig_init(myrig_model);
|
my_rig = rig_init(myrig_model);
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr,"Unknown rig num: %d\n", myrig_model);
|
fprintf(stderr, "Unknown rig num: %d\n", myrig_model);
|
||||||
fprintf(stderr,"Please check riglist.h\n");
|
fprintf(stderr, "Please check riglist.h\n");
|
||||||
exit(1); /* whoops! something went wrong (mem alloc?) */
|
exit(1); /* whoops! something went wrong (mem alloc?) */
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(my_rig->state.rigport.pathname,SERIAL_PORT,FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
retcode = rig_open(my_rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_open: error = %s\n", rigerror(retcode));
|
printf("rig_open: error = %s\n", rigerror(retcode));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -106,7 +107,7 @@ int main (int argc, char *argv[])
|
||||||
retcode = rig_set_vfo(my_rig, RIG_VFO_B);
|
retcode = rig_set_vfo(my_rig, RIG_VFO_B);
|
||||||
|
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_vfo: error = %s \n", rigerror(retcode));
|
printf("rig_set_vfo: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ int main (int argc, char *argv[])
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_FM,
|
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_FM,
|
||||||
rig_passband_narrow(my_rig, RIG_MODE_FM));
|
rig_passband_narrow(my_rig, RIG_MODE_FM));
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +134,10 @@ int main (int argc, char *argv[])
|
||||||
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
|
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
|
||||||
freq / 1000000, rig_strrmode(rmode), width / 1000.0);
|
freq / 1000000,
|
||||||
|
rig_strrmode(rmode),
|
||||||
|
width / 1000.0);
|
||||||
|
|
||||||
sleep(1); /* so you can see it -- FS */
|
sleep(1); /* so you can see it -- FS */
|
||||||
|
|
||||||
/* 15m USB */
|
/* 15m USB */
|
||||||
|
@ -141,10 +145,12 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting 15m USB...\n");
|
printf("Setting 15m USB...\n");
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 21235175); /* 15m */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 21235175); /* 15m */
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_USB,
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_USB,
|
||||||
rig_passband_normal(my_rig, RIG_MODE_USB));
|
rig_passband_normal(my_rig, RIG_MODE_USB));
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +166,12 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting 40m LSB...\n");
|
printf("Setting 40m LSB...\n");
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 7250100); /* 40m */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 7250100); /* 40m */
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL);
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_LSB,
|
||||||
|
RIG_PASSBAND_NORMAL);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,10 +187,12 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting 80m AM Narrow...\n");
|
printf("Setting 80m AM Narrow...\n");
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 3885000); /* 80m */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 3885000); /* 80m */
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM,
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_AM,
|
||||||
rig_passband_narrow(my_rig, RIG_MODE_AM));
|
rig_passband_narrow(my_rig, RIG_MODE_AM));
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +200,9 @@ int main (int argc, char *argv[])
|
||||||
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
|
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
|
||||||
freq / 1000000, rig_strrmode(rmode), width / 1000.0);
|
freq / 1000000,
|
||||||
|
rig_strrmode(rmode), width / 1000.0);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* 160m CW Normal */
|
/* 160m CW Normal */
|
||||||
|
@ -197,9 +210,12 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting 160m CW...\n");
|
printf("Setting 160m CW...\n");
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 1875000); /* 160m */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 1875000); /* 160m */
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW, RIG_PASSBAND_NORMAL);
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_CW,
|
||||||
|
RIG_PASSBAND_NORMAL);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,17 +223,21 @@ int main (int argc, char *argv[])
|
||||||
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
|
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
|
||||||
freq / 1000, rig_strrmode(rmode), width );
|
freq / 1000,
|
||||||
|
rig_strrmode(rmode), width);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* 160m CW Narrow -- The band is noisy tonight -- FS*/
|
/* 160m CW Narrow -- The band is noisy tonight -- FS*/
|
||||||
|
|
||||||
printf("Setting 160m CW Narrow...\n");
|
printf("Setting 160m CW Narrow...\n");
|
||||||
|
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW,
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_CW,
|
||||||
rig_passband_narrow(my_rig, RIG_MODE_CW));
|
rig_passband_narrow(my_rig, RIG_MODE_CW));
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +245,9 @@ int main (int argc, char *argv[])
|
||||||
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
|
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
|
||||||
freq / 1000, rig_strrmode(rmode), width);
|
freq / 1000,
|
||||||
|
rig_strrmode(rmode), width);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* AM Broadcast band */
|
/* AM Broadcast band */
|
||||||
|
@ -233,9 +255,12 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting Medium Wave AM...\n");
|
printf("Setting Medium Wave AM...\n");
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 770000); /* KAAM */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 770000); /* KAAM */
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM, RIG_PASSBAND_NORMAL);
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_AM,
|
||||||
|
RIG_PASSBAND_NORMAL);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +268,9 @@ int main (int argc, char *argv[])
|
||||||
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
printf(" Freq: %.3f kHz, Mode: %s, Passband: %.3f kHz\n\n",
|
printf(" Freq: %.3f kHz, Mode: %s, Passband: %.3f kHz\n\n",
|
||||||
freq / 1000, rig_strrmode(rmode), width / 1000.0);
|
freq / 1000,
|
||||||
|
rig_strrmode(rmode), width / 1000.0);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* 20m USB on VFO_A */
|
/* 20m USB on VFO_A */
|
||||||
|
@ -253,7 +280,7 @@ int main (int argc, char *argv[])
|
||||||
retcode = rig_set_vfo(my_rig, RIG_VFO_A);
|
retcode = rig_set_vfo(my_rig, RIG_VFO_A);
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 14250375); /* cq de vk3fcs */
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 14250375); /* cq de vk3fcs */
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +296,7 @@ int main (int argc, char *argv[])
|
||||||
printf("Setting 20m on VFO A with one function...\n");
|
printf("Setting 20m on VFO A with one function...\n");
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_A, 14295125); /* cq de vk3fcs */
|
retcode = rig_set_freq(my_rig, RIG_VFO_A, 14295125); /* cq de vk3fcs */
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,27 +316,30 @@ int main (int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("Setting rig Mode to LSB.\n");
|
printf("Setting rig Mode to LSB.\n");
|
||||||
retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL);
|
retcode = rig_set_mode(my_rig,
|
||||||
|
RIG_VFO_CURR,
|
||||||
|
RIG_MODE_LSB,
|
||||||
|
RIG_PASSBAND_NORMAL);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_mode: error = %s \n", rigerror(retcode));
|
printf("rig_set_mode: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
printf("Setting rig PTT ON.\n");
|
printf("Setting rig PTT ON.\n");
|
||||||
retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_ON ); /* stand back ! */
|
retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_ON); /* stand back ! */
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_ptt: error = %s \n", rigerror(retcode));
|
printf("rig_set_ptt: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
printf("Setting rig PTT OFF.\n");
|
printf("Setting rig PTT OFF.\n");
|
||||||
retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_OFF ); /* phew ! */
|
retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_OFF); /* phew ! */
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_ptt: error = %s \n", rigerror(retcode));
|
printf("rig_set_ptt: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +353,7 @@ int main (int argc, char *argv[])
|
||||||
printf("\nGet various raw rig values:\n");
|
printf("\nGet various raw rig values:\n");
|
||||||
retcode = rig_get_vfo(my_rig, &vfo); /* try to get vfo info */
|
retcode = rig_get_vfo(my_rig, &vfo); /* try to get vfo info */
|
||||||
|
|
||||||
if (retcode == RIG_OK ) {
|
if (retcode == RIG_OK) {
|
||||||
printf("rig_get_vfo: vfo = %i \n", vfo);
|
printf("rig_get_vfo: vfo = %i \n", vfo);
|
||||||
} else {
|
} else {
|
||||||
printf("rig_get_vfo: error = %s \n", rigerror(retcode));
|
printf("rig_get_vfo: error = %s \n", rigerror(retcode));
|
||||||
|
@ -331,7 +361,7 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
||||||
|
|
||||||
if (retcode == RIG_OK ) {
|
if (retcode == RIG_OK) {
|
||||||
printf("rig_get_freq: freq = %"PRIfreq"\n", freq);
|
printf("rig_get_freq: freq = %"PRIfreq"\n", freq);
|
||||||
} else {
|
} else {
|
||||||
printf("rig_get_freq: error = %s \n", rigerror(retcode));
|
printf("rig_get_freq: error = %s \n", rigerror(retcode));
|
||||||
|
@ -339,7 +369,7 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width);
|
||||||
|
|
||||||
if (retcode == RIG_OK ) {
|
if (retcode == RIG_OK) {
|
||||||
printf("rig_get_mode: mode = %i \n", rmode);
|
printf("rig_get_mode: mode = %i \n", rmode);
|
||||||
} else {
|
} else {
|
||||||
printf("rig_get_mode: error = %s \n", rigerror(retcode));
|
printf("rig_get_mode: error = %s \n", rigerror(retcode));
|
||||||
|
@ -347,7 +377,7 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
retcode = rig_get_strength(my_rig, RIG_VFO_CURR, &strength);
|
retcode = rig_get_strength(my_rig, RIG_VFO_CURR, &strength);
|
||||||
|
|
||||||
if (retcode == RIG_OK ) {
|
if (retcode == RIG_OK) {
|
||||||
printf("rig_get_strength: strength = %i \n", strength);
|
printf("rig_get_strength: strength = %i \n", strength);
|
||||||
} else {
|
} else {
|
||||||
printf("rig_get_strength: error = %s \n", rigerror(retcode));
|
printf("rig_get_strength: error = %s \n", rigerror(retcode));
|
||||||
|
@ -376,7 +406,7 @@ int main (int argc, char *argv[])
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
|
||||||
printf("port %s closed ok \n",SERIAL_PORT);
|
printf("port %s closed ok \n", SERIAL_PORT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
||||||
|
@ -27,12 +27,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
|
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
|
||||||
#include "hl_sleep.h"
|
# include "hl_sleep.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define SERIAL_PORT "/dev/ttyS0"
|
#define SERIAL_PORT "/dev/ttyS0"
|
||||||
|
|
||||||
|
|
||||||
int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
||||||
{
|
{
|
||||||
int *count_ptr = (int *) arg;
|
int *count_ptr = (int *) arg;
|
||||||
|
@ -44,14 +44,14 @@ int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RIG *my_rig; /* handle to rig (nstance) */
|
RIG *my_rig; /* handle to rig (nstance) */
|
||||||
int retcode; /* generic return code from functions */
|
int retcode; /* generic return code from functions */
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr,"%s <rig_num>\n", argv[0]);
|
fprintf(stderr, "%s <rig_num>\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,16 +62,18 @@ int main (int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
my_rig = rig_init(atoi(argv[1]));
|
my_rig = rig_init(atoi(argv[1]));
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr,"Unknown rig num: %d\n",atoi(argv[1]));
|
fprintf(stderr, "Unknown rig num: %d\n", atoi(argv[1]));
|
||||||
fprintf(stderr,"Please check riglist.h\n");
|
fprintf(stderr, "Please check riglist.h\n");
|
||||||
exit(1); /* whoops! something went wrong (mem alloc?) */
|
exit(1); /* whoops! something went wrong (mem alloc?) */
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1);
|
||||||
|
|
||||||
if (rig_open(my_rig))
|
if (rig_open(my_rig)) {
|
||||||
exit(2);
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Port %s opened ok\n", SERIAL_PORT);
|
printf("Port %s opened ok\n", SERIAL_PORT);
|
||||||
|
|
||||||
|
@ -81,10 +83,9 @@ int main (int argc, char *argv[])
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 439700000);
|
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 439700000);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +93,12 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
retcode = rig_set_trn(my_rig, RIG_TRN_RIG);
|
retcode = rig_set_trn(my_rig, RIG_TRN_RIG);
|
||||||
|
|
||||||
if (retcode != RIG_OK ) {
|
if (retcode != RIG_OK) {
|
||||||
printf("rig_set_trn: error = %s \n", rigerror(retcode));
|
printf("rig_set_trn: error = %s \n", rigerror(retcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i=0;i<12;i++)
|
for (i = 0; i < 12; i++) {
|
||||||
{
|
|
||||||
printf("Loop count: %d\n", i);
|
printf("Loop count: %d\n", i);
|
||||||
sleep(10); /* or anything smarter */
|
sleep(10); /* or anything smarter */
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ int main (int argc, char *argv[])
|
||||||
rig_close(my_rig); /* close port */
|
rig_close(my_rig); /* close port */
|
||||||
rig_cleanup(my_rig); /* if you care about memory */
|
rig_cleanup(my_rig); /* if you care about memory */
|
||||||
|
|
||||||
printf("port %s closed ok \n",SERIAL_PORT);
|
printf("port %s closed ok \n", SERIAL_PORT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue