From 13bad9faeebc235c5c72b91fba0539d361449869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Sun, 1 Oct 2000 12:53:01 +0000 Subject: [PATCH] Moved from ../common git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@174 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- tests/testrig.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 tests/testrig.c diff --git a/tests/testrig.c b/tests/testrig.c new file mode 100644 index 000000000..d8cc61248 --- /dev/null +++ b/tests/testrig.c @@ -0,0 +1,104 @@ +/* + * Hamlib sample program + */ + +#include +#include +#include + +#define SERIAL_PORT "/dev/ttyS0" + +int main () +{ + RIG *my_rig; /* handle to rig (nstance) */ + freq_t freq; /* frequency */ + rmode_t rmode; /* radio mode of operation */ + vfo_t vfo; /* vfo selection */ + int retcode; /* generic return code from functions */ + + + printf("testrig:hello, I am your main() !\n"); + + /* + * allocate memory, setup & open port + */ + + my_rig = rig_init(RIG_MODEL_IC706MKIIG); + if (!my_rig) + exit(1); /* whoops! something went wrong (mem alloc?) */ + + strncpy(my_rig->state.rig_path,SERIAL_PORT,FILPATHLEN); + + if (rig_open(my_rig)) + exit(2); + + printf("Port %s opened ok\n", SERIAL_PORT); + + /* + * Below are examples of set/get routines. + * Must add checking of functionality map prior to command execution -- FS + * + */ + + + /* + * Example of setting rig Main VFO to 439.700 Mhz FM -- FS + * and some error checking on the return code. + */ + + retcode = rig_set_vfo(my_rig, RIG_VFO_MAIN); + + if (retcode != RIG_OK ) { + printf("rig_set_vfo: error = %s \n", rigerror(retcode)); + } + + retcode = rig_set_freq(my_rig, 439700000); /* cq de vk3fcs */ + + if (retcode != RIG_OK ) { + printf("rig_set_freq: error = %s \n", rigerror(retcode)); + } + + retcode = rig_set_mode(my_rig, RIG_MODE_FM); + + if (retcode != RIG_OK ) { + printf("rig_set_mode: error = %s \n", rigerror(retcode)); + } + + /* + * Simple examples of getting rig information -- FS + * + */ + + retcode = rig_get_vfo(my_rig, &vfo); /* try to get vfo info */ + + if (retcode == RIG_OK ) { + printf("rig_get_vfo: vfo = %i \n", vfo); + } else { + printf("rig_get_vfo: error = %s \n", rigerror(retcode)); + } + + retcode = rig_get_freq(my_rig, &freq); + + if (retcode == RIG_OK ) { + printf("rig_get_freq: freq = %Li \n", freq); + } else { + printf("rig_get_freq: error = %s \n", rigerror(retcode)); + } + + retcode = rig_get_mode(my_rig, &rmode); + + if (retcode == RIG_OK ) { + printf("rig_get_mode: mode = %i \n", rmode); + } else { + printf("rig_get_mode: error = %s \n", rigerror(retcode)); + } + + rig_close(my_rig); /* close port */ + rig_cleanup(my_rig); /* if you care about memory */ + + printf("port %s closed ok \n",SERIAL_PORT); + + return 0; +} + +