1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/* This program does a fast iteration of v f m t s
* By Michael Black W9MDB
* This allows testing of another program using rigctld
* to test changing vfo, freq, mode, PTT, or split and see the change immediately in this program.
* Used in testing caching effects that have been added
* To compile:
* gcc -I../src -I../include -g -o cachetest2 cachetest2.c -lhamlib
* To run:
* rigctld
* ./cachetest2
* Note: cachtest2 should show immediately when v f m t s are changed
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hamlib/rig.h>
#include <hamlib/riglist.h>
#include "sprintflst.h"
#include "misc.h"
int main(int argc, const char *argv[])
{
RIG *my_rig;
char *rig_file, *info_buf;
int retcode;
int model;
int cache_timeout = 0;
if (argc != 1)
{
fprintf(stderr, "Usage: %s\n", argv[0]);
exit(1);
}
model = 2;
rig_set_debug(RIG_DEBUG_NONE);
/* Instantiate a rig */
my_rig = rig_init(model); // your rig model.
/* Set up serial port, baud rate */
rig_file = "127.0.0.1:4532"; // your serial device
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
/* Open my rig */
retcode = rig_open(my_rig);
if (retcode != RIG_OK)
{
fprintf(stderr, "%s: rig_open failed %s\n", __func__,
rigerror(retcode));
return 1;
}
rig_set_cache_timeout_ms(my_rig, HAMLIB_CACHE_ALL, cache_timeout);
/* Give me ID info, e.g., firmware version. */
info_buf = (char *)rig_get_info(my_rig);
if (info_buf)
{
strtok(info_buf, "\r\n");
printf("Rig_info: '%s'\n", info_buf);
}
while (1)
{
static freq_t freq, freq_last = 0;
static rmode_t mode, mode_last = 0;
static pbwidth_t width, width_last = 0;
static vfo_t vfo, vfo_last = RIG_VFO_NONE;
static vfo_t txvfo, txvfo_last = RIG_VFO_NONE;
static ptt_t ptt, ptt_last = -1;
static split_t split, split_last = -1;
retcode = rig_get_vfo(my_rig, &vfo);
if (retcode != RIG_OK) { printf("Get vfo failed?? Err=%s\n", rigerror(retcode)); }
if (vfo != vfo_last)
{
printf("VFO = %s\n", rig_strvfo(vfo));
vfo_last = vfo;
}
retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
if (retcode != RIG_OK) { printf("Get freq failed?? Err=%s\n", rigerror(retcode)); }
if (freq != freq_last)
{
printf("VFO freq. = %.1f Hz\n", freq);
freq_last = freq;
}
retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width);
if (retcode != RIG_OK) { printf("Get mode failed?? Err=%s\n", rigerror(retcode)); }
if (mode != mode_last || width != width_last)
{
printf("Current mode = %s, width = %ld\n", rig_strrmode(mode), width);
mode_last = mode;
width_last = width;
}
retcode = rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt);
if (retcode != RIG_OK) { printf("Get ptt failed?? Err=%s\n", rigerror(retcode)); }
if (ptt != ptt_last)
{
printf("ptt=%d\n", ptt);
ptt_last = ptt;
}
retcode = rig_get_split_vfo(my_rig, RIG_VFO_CURR, &split, &txvfo);
if (retcode != RIG_OK) { printf("Get split_vfo failed?? Err=%s\n", rigerror(retcode)); }
if (split != split_last || txvfo != txvfo_last)
{
printf("split=%d, tx_vfo=%s\n", split,
rig_strvfo(vfo));
split_last = split;
txvfo_last = txvfo;
}
}
rig_close(my_rig);
return 0;
};
|