#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
# include "hl_sleep.h"
#endif
#define SERIAL_PORT "/dev/ttyS0"
int main(int argc, char *argv[])
{
int strength;
int rit = 0;
int xit = 0;
int retcode;
printf("testrig: Hello, I am your main() !\n");
if (argc < 2)
{
strncpy(myport.
pathname, SERIAL_PORT, FILPATHLEN - 1);
rig_load_all_backends();
}
else
{
myrig_model = atoi(argv[1]);
}
if (!my_rig)
{
fprintf(stderr, "Unknown rig num: %d\n", myrig_model);
fprintf(stderr, "Please check riglist.h\n");
exit(1);
}
{
printf(
"rig_open: error = %s\n",
rigerror(retcode));
exit(2);
}
printf("Port %s opened ok\n", SERIAL_PORT);
{
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(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000000,
width / 1000.0);
sleep(1);
printf("Setting 15m USB...\n");
{
printf(
"rig_set_freq: error = %s \n",
rigerror(retcode));
}
printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
sleep(1);
printf("Setting 40m LSB...\n");
RIG_PASSBAND_NORMAL);
{
printf(
"rig_set_freq: 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(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n",
freq / 1000000,
width / 1000.0);
sleep(1);
printf("Setting 160m CW...\n");
RIG_PASSBAND_NORMAL);
{
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 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");
RIG_PASSBAND_NORMAL);
{
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_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");
RIG_PASSBAND_NORMAL);
{
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 = %i \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));
}
{
printf("rig_get_mode: mode = %i \n", rmode);
}
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));
}
{
printf("rig_set_func: Setting RIT ON\n");
}
{
printf("rig_get_func: RIT: %d\n", rit);
}
{
printf("rig_set_func: Setting XIT ON\n");
}
{
printf("rig_get_func: XIT: %d\n", xit);
}
printf("port %s closed ok \n", SERIAL_PORT);
return 0;
}