#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "hamlib/config.h"
#define SERIAL_PORT "/dev/pts/2"
int main(int argc, const char *argv[])
{
int strength;
int rit = 0;
int xit = 0;
int retcode;
printf("testrig: Hello, I am your main() !\n");
if (argc < 2)
{
rig_load_all_backends();
}
else
{
myrig_model = atoi(argv[1]);
}
if (!my_rig)
{
fprintf(stderr, "Unknown rig num: %u\n", myrig_model);
fprintf(stderr, "Please check riglist.h\n");
exit(1);
}
{
printf(
"rig_open: error = %s\n",
rigerror(retcode));
exit(2);
}
RIG_CAPS_HAS_GET_LEVEL);
printf("HAS_GET_LEVEL=0x%8llx, SWR=%8llx,true=%d\n", (unsigned long long)levels,
char val[256];
sizeof(val));
{
}
printf("write_delay=%s\n", val);
{
printf(
"rig_set_vfo: error = %s \n",
rigerror(retcode));
}
printf("\nSetting 10m FM Narrow...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000000,
width / 1000.0);
if (freq != 29620000)
{
printf("rig_set_freq: error expect %.0f got %.0f\n", 296290000.0, freq);
}
{
printf("rig_set_mode: error expected FM/%d, got %s/%d\n",
}
sleep(1);
printf("Setting 15m USB...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
sleep(1);
printf("Setting 40m LSB...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000000,
width / 1000.0);
sleep(1);
printf("Setting 80m AM Narrow...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000000,
width / 1000.0);
sleep(1);
printf("Setting 160m CW...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
freq / 1000,
width);
sleep(1);
printf("Setting 160m CW Narrow...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n",
freq / 1000,
width);
sleep(1);
printf("Setting Medium Wave AM...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.3f kHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000,
width / 1000.0);
sleep(1);
printf("Setting 20m on VFO A with two functions...\n");
{
printf(
"rig_set_vfo: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
printf(
" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000,
rig_strvfo(vfo));
sleep(1);
printf("Setting 20m on VFO A with one function...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
printf(
" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000,
rig_strvfo(vfo));
sleep(1);
#if 0
sleep(2);
sleep(2);
#endif
printf("Setting rig Mode to LSB.\n");
{
printf(
"rig_set_mode: error = %s \n",
rigerror(retcode));
}
sleep(1);
printf("Setting rig PTT ON.\n");
{
printf(
"rig_set_ptt: error = %s \n",
rigerror(retcode));
}
sleep(1);
printf("Setting rig PTT OFF.\n");
{
printf(
"rig_set_ptt: error = %s \n",
rigerror(retcode));
}
sleep(1);
printf("\nGet various raw rig values:\n");
{
printf("rig_get_vfo: vfo = %u \n", vfo);
}
else
{
printf(
"rig_get_vfo: error = %s \n",
rigerror(retcode));
}
{
printf(
"rig_get_freq: freq = %"PRIfreq"\n", freq);
}
else
{
printf(
"rig_get_freq: error = %s \n",
rigerror(retcode));
}
{
}
else
{
printf(
"rig_get_mode: error = %s \n",
rigerror(retcode));
}
retcode = rig_get_strength(my_rig,
RIG_VFO_CURR, &strength);
{
printf("rig_get_strength: strength = %i \n", strength);
}
else
{
printf(
"rig_get_strength: error = %s \n",
rigerror(retcode));
}
{
if (retcode !=
RIG_OK) { printf(
"rig_set_func RIT error: %s\n",
rigerror(retcode)); }
printf("rig_set_func: Setting RIT ON\n");
}
{
if (retcode !=
RIG_OK) { printf(
"rig_get_func RIT error: %s\n",
rigerror(retcode)); }
printf("rig_get_func: RIT: %d\n", rit);
}
{
if (retcode !=
RIG_OK) { printf(
"rig_set_func XIT error: %s\n",
rigerror(retcode)); }
printf("rig_set_func: Setting XIT ON\n");
}
{
if (retcode !=
RIG_OK) { printf(
"rig_get_func XIT error: %s\n",
rigerror(retcode)); }
printf("rig_get_func: XIT: %d\n", xit);
}
printf("port %s closed ok \n", SERIAL_PORT);
for (unsigned long i = 1; i < 0x80000000; i = i << 1)
{
if (strlen(vfostr) > 0) { printf("0x%08lx=%s\n", i, vfostr); }
}
return 0;
}
struct hamlib_port hamlib_port_t
Port definition.
const char * rig_strvfo(vfo_t vfo)
Convert enum RIG_VFO_... to alpha string.
Definition misc.c:672
const char * rig_strrmode(rmode_t mode)
Convert enum RIG_MODE to alpha string.
Definition misc.c:542
int rig_set_vfo(RIG *rig, vfo_t vfo)
set the current VFO
Definition rig.c:3366
unsigned int vfo_t
VFO definition.
Definition rig.h:544
int rig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
get the mode of the target VFO
Definition rig.c:3035
#define PRIfreq
printf(3) format to be used for freq_t type
Definition rig.h:489
setting_t rig_has_set_func(RIG *rig, setting_t func)
check ability of radio functions
Definition settings.c:468
int rig_get_vfo(RIG *rig, vfo_t *vfo)
get the current VFO
Definition rig.c:3513
#define RIG_VFO_A
VFOA – VFO A
Definition rig.h:554
uint64_t rmode_t
Radio mode.
Definition rig.h:1392
shortfreq_t pbwidth_t
Definition rig.h:676
int rig_cleanup(RIG *rig)
release a rig handle and free associated memory
Definition rig.c:1920
int rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
get the frequency of the target VFO
Definition rig.c:2494
int rig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
activate/de-activate functions of radio
Definition settings.c:499
uint64_t rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps)
Function to return int value from rig->caps Does not support > 32-bit rig_caps values.
Definition misc.c:2645
setting_t rig_has_get_func(RIG *rig, setting_t func)
check ability of radio functions
Definition settings.c:438
int rig_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
get the status of functions of the radio
Definition settings.c:596
#define RIG_FUNC_XIT
Definition rig.h:1312
#define RIG_FUNC_RIT
Definition rig.h:1305
#define RIG_VFO_CURR
currVFO – current "tunable channel"/VFO
Definition rig.h:599
int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
set the frequency of the target VFO
Definition rig.c:2146
int rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
set PTT on/off
Definition rig.c:3617
#define RIG_MODE_AM
Definition rig.h:1395
double freq_t
Frequency type.
Definition rig.h:484
#define RIG_MODE_USB
Definition rig.h:1397
#define RIG_PASSBAND_NORMAL
Macro for bandpass to be set to normal.
Definition rig.h:665
RIG * rig_init(rig_model_t rig_model)
Allocate a new RIG handle.
Definition rig.c:616
int rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
set the mode of the target VFO
Definition rig.c:2834
#define RIG_MODE_CW
Definition rig.h:1396
#define RIG_MODE_LSB
Definition rig.h:1398
int rig_close(RIG *rig)
close the communication to the rig
Definition rig.c:1746
pbwidth_t rig_passband_narrow(RIG *rig, rmode_t mode)
get the narrow passband of a mode
Definition rig.c:3254
const char * rigerror(int errnum)
Add error message to debug output.
Definition rig.c:520
#define RIG_MODE_FM
Definition rig.h:1400
pbwidth_t rig_passband_normal(RIG *rig, rmode_t mode)
get the normal passband of a mode
Definition rig.c:3203
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:290
#define RIG_LEVEL_SWR
Definition rig.h:1113
int rig_open(RIG *rig)
open the communication to the rig
Definition rig.c:1039
hamlib_token_t rig_token_lookup(RIG *rig, const char *name)
lookup a token id
Definition conf.c:1466
#define RIG_VFO_B
VFOB – VFO B
Definition rig.h:557
int rig_set_conf(RIG *rig, hamlib_token_t token, const char *val)
set a radio configuration parameter
Definition conf.c:1497
void rig_debug(enum rig_debug_level_e debug_level, const char *fmt,...)
Print debugging messages through stderr by default.
Definition debug.c:205
rig_model_t rig_probe(hamlib_port_t *port)
try to guess a rig
Definition rig.c:7054
@ RIG_PARITY_NONE
Definition rig.h:360
@ RIG_OK
Definition rig.h:210
@ RIG_PTT_OFF
Definition rig.h:708
@ RIG_PTT_ON
Definition rig.h:709
@ RIG_PORT_SERIAL
Definition rig.h:340
@ RIG_HANDSHAKE_NONE
Definition rig.h:372
@ RIG_DEBUG_ERR
Definition rig.h:262
@ RIG_DEBUG_NONE
Definition rig.h:260
uint32_t rig_model_t
Definition riglist.h:1125
Hamlib rig data structures.
int data_bits
Definition port.h:81
int rate
Definition port.h:80
union hamlib_port::@010252341134000141374371065010022176366123126005 parm
enum serial_handshake_e handshake
Definition port.h:84
rig_port_t rig
Definition port.h:57
union hamlib_port::@223041142330367015014340333244362031135073274241 type
enum serial_parity_e parity
Definition port.h:83
struct hamlib_port::@010252341134000141374371065010022176366123126005::@107223103132214137304013246371124141205072105116 serial
int stop_bits
Definition port.h:82
rig_model_t rig_model
Definition rig.h:1947
struct rig_caps * caps
Definition rig.h:2680