kopia lustrzana https://github.com/Hamlib/Hamlib
added a private data pointer argument to event callbacks
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@977 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.3
rodzic
00fa0a5dc3
commit
2fd1486135
|
@ -11,7 +11,7 @@
|
|||
* Hamlib C++ bindings - main file
|
||||
* Copyright (c) 2001 by Stephane Fillod
|
||||
*
|
||||
* $Id: rigclass.cc,v 1.7 2001-12-27 21:50:14 fillods Exp $
|
||||
* $Id: rigclass.cc,v 1.8 2002-02-27 23:25:42 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -39,19 +39,19 @@
|
|||
#define CHECK_RIG(cmd) { int _retval = cmd; if (_retval != RIG_OK) \
|
||||
THROW(new RigException (_retval)); }
|
||||
|
||||
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
||||
{
|
||||
if (!rig || !rig->state.obj)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
/* assert rig == ((Rig*)rig->state.obj).thRig */
|
||||
return ((Rig*)rig->state.obj)->FreqEvent(vfo, freq);
|
||||
/* assert rig == ((Rig*)rig->state.obj).theRig */
|
||||
return ((Rig*)rig->state.obj)->FreqEvent(vfo, freq, arg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib JRC backend - main file
|
||||
* Copyright (c) 2001,2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: jrc.c,v 1.4 2001-12-28 20:28:03 fillods Exp $
|
||||
* $Id: jrc.c,v 1.5 2002-02-27 23:25:41 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -856,12 +856,14 @@ int jrc_decode_event(RIG *rig)
|
|||
if (rig->callbacks.freq_event) {
|
||||
buf[14] = '\0'; /* side-effect: destroy AGC first digit! */
|
||||
sscanf(buf+4, "%lld", &freq);
|
||||
return rig->callbacks.freq_event(rig,RIG_VFO_CURR,freq);
|
||||
return rig->callbacks.freq_event(rig, RIG_VFO_CURR, freq,
|
||||
rig->callbacks.freq_arg);
|
||||
}
|
||||
|
||||
if (rig->callbacks.mode_event) {
|
||||
jrc2rig_mode(rig, buf[3], buf[2], &mode, &width);
|
||||
return rig->callbacks.mode_event(rig,RIG_VFO_CURR,mode,width);
|
||||
return rig->callbacks.mode_event(rig, RIG_VFO_CURR, mode, width,
|
||||
rig->callbacks.freq_arg);
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
|
14
kenwood/th.c
14
kenwood/th.c
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TH handheld primitives
|
||||
* Copyright (c) 2001 by Stephane Fillod
|
||||
*
|
||||
* $Id: th.c,v 1.4 2002-01-07 17:48:36 fgretief Exp $
|
||||
* $Id: th.c,v 1.5 2002-02-27 23:25:42 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -212,13 +212,14 @@ th_decode_event (RIG *rig)
|
|||
|
||||
/* Callback execution */
|
||||
if (rig->callbacks.vfo_event) {
|
||||
rig->callbacks.vfo_event(rig, vfo);
|
||||
rig->callbacks.vfo_event(rig, vfo, rig->callbacks.vfo_arg);
|
||||
}
|
||||
if (rig->callbacks.freq_event) {
|
||||
rig->callbacks.freq_event(rig, vfo, freq);
|
||||
rig->callbacks.freq_event(rig, vfo, freq, rig->callbacks.freq_arg);
|
||||
}
|
||||
if (rig->callbacks.mode_event) {
|
||||
rig->callbacks.mode_event(rig, vfo, mode, RIG_PASSBAND_NORMAL);
|
||||
rig->callbacks.mode_event(rig, vfo, mode, RIG_PASSBAND_NORMAL,
|
||||
rig->callbacks.mode_arg);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
@ -240,7 +241,8 @@ th_decode_event (RIG *rig)
|
|||
/* Callback execution */
|
||||
#if STILLHAVETOADDCALLBACK
|
||||
if (rig->callbacks.strength_event)
|
||||
rig->callbacks.strength_event(rig, vfo,(float)(lev / 5.0) );
|
||||
rig->callbacks.strength_event(rig, vfo,(float)(lev / 5.0),
|
||||
rig->callbacks.strength_arg);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
@ -273,7 +275,7 @@ th_decode_event (RIG *rig)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": VFO event - vfo = %d\n", vfo);
|
||||
if (rig->callbacks.vfo_event)
|
||||
rig->callbacks.vfo_event(rig, vfo);
|
||||
rig->callbacks.vfo_event(rig, vfo, rig->callbacks.vfo_arg);
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
#if 0
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
|
||||
#define SERIAL_PORT "/dev/ttyS0"
|
||||
|
||||
int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
||||
{
|
||||
printf("Rig changed freq to %lliHz\n",freq);
|
||||
int *count_ptr = (int *) arg;
|
||||
|
||||
printf("Rig changed freq to %lliHz\n", freq);
|
||||
*count_ptr += 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,7 +25,7 @@ int main (int argc, char *argv[])
|
|||
{
|
||||
RIG *my_rig; /* handle to rig (nstance) */
|
||||
int retcode; /* generic return code from functions */
|
||||
int i;
|
||||
int i, count = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,"%s <rig_num>\n", argv[0]);
|
||||
|
@ -61,7 +65,7 @@ int main (int argc, char *argv[])
|
|||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||
}
|
||||
|
||||
my_rig->callbacks.freq_event = myfreq_event;
|
||||
rig_set_freq_callback(my_rig, myfreq_event, (rig_ptr_t)&count);
|
||||
|
||||
retcode = rig_set_trn(my_rig, RIG_TRN_RIG);
|
||||
|
||||
|
@ -71,8 +75,9 @@ int main (int argc, char *argv[])
|
|||
|
||||
|
||||
for (i=0;i<12;i++)
|
||||
sleep(60); /* or anything smarter */
|
||||
sleep(10); /* or anything smarter */
|
||||
|
||||
printf("Frequency changed %d times\n", count);
|
||||
|
||||
rig_close(my_rig); /* close port */
|
||||
rig_cleanup(my_rig); /* if you care about memory */
|
||||
|
|
Ładowanie…
Reference in New Issue