kopia lustrzana https://github.com/Hamlib/Hamlib
Add wait_morse command with generit wait_morse_ptt function
This should work for any send_morse with full breakin
https://github.com/Hamlib/Hamlib/issues/422
(cherry picked from commit 0443afc794
)
Hamlib-4.0
rodzic
b12758e92e
commit
000cf575eb
|
@ -1793,6 +1793,7 @@ struct rig_caps {
|
||||||
|
|
||||||
int (*send_morse)(RIG *rig, vfo_t vfo, const char *msg);
|
int (*send_morse)(RIG *rig, vfo_t vfo, const char *msg);
|
||||||
int (*stop_morse)(RIG *rig, vfo_t vfo);
|
int (*stop_morse)(RIG *rig, vfo_t vfo);
|
||||||
|
int (*wait_morse)(RIG *rig, vfo_t vfo);
|
||||||
|
|
||||||
int (*send_voice_mem)(RIG *rig, vfo_t vfo, int ch);
|
int (*send_voice_mem)(RIG *rig, vfo_t vfo, int ch);
|
||||||
|
|
||||||
|
@ -2511,6 +2512,10 @@ extern HAMLIB_EXPORT(int)
|
||||||
rig_stop_morse HAMLIB_PARAMS((RIG *rig,
|
rig_stop_morse HAMLIB_PARAMS((RIG *rig,
|
||||||
vfo_t vfo));
|
vfo_t vfo));
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(int)
|
||||||
|
rig_wait_morse HAMLIB_PARAMS((RIG *rig,
|
||||||
|
vfo_t vfo));
|
||||||
|
|
||||||
extern HAMLIB_EXPORT(int)
|
extern HAMLIB_EXPORT(int)
|
||||||
rig_send_voice_mem HAMLIB_PARAMS((RIG *rig,
|
rig_send_voice_mem HAMLIB_PARAMS((RIG *rig,
|
||||||
vfo_t vfo,
|
vfo_t vfo,
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BACKEND_VER "20201016"
|
#define BACKEND_VER "20201018"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* defines used by comp_cal_str in rig.c
|
* defines used by comp_cal_str in rig.c
|
||||||
|
|
92
src/rig.c
92
src/rig.c
|
@ -5120,6 +5120,98 @@ int HAMLIB_API rig_stop_morse(RIG *rig, vfo_t vfo)
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wait_morse_ptt
|
||||||
|
* generic routine to wait for ptt=0
|
||||||
|
* should work on any full breakin CW morse send
|
||||||
|
* Assumes rig!=NULL, msg!=NULL
|
||||||
|
*/
|
||||||
|
static int wait_morse_ptt(RIG *rig, vfo_t vfo)
|
||||||
|
{
|
||||||
|
ptt_t pttStatus = RIG_PTT_OFF;
|
||||||
|
int loops = 0;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s: loop#%d until ptt=0, ptt=%d\n", __func__, loops,
|
||||||
|
pttStatus);
|
||||||
|
retval = rig_get_ptt(rig, vfo, &pttStatus);
|
||||||
|
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
hl_usleep(50 * 1000);
|
||||||
|
++loops;
|
||||||
|
}
|
||||||
|
while (pttStatus == RIG_PTT_ON && loops <= 600);
|
||||||
|
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief wait morse code
|
||||||
|
* \param rig The rig handle
|
||||||
|
* \param vfo The target VFO
|
||||||
|
*
|
||||||
|
* waits for the end of the morse message to be sent.
|
||||||
|
*
|
||||||
|
* \return RIG_OK if the operation has been successful, otherwise
|
||||||
|
* a negative value if an error occurred (in which case, cause is
|
||||||
|
* set appropriately).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int HAMLIB_API rig_wait_morse(RIG *rig, vfo_t vfo)
|
||||||
|
{
|
||||||
|
const struct rig_caps *caps;
|
||||||
|
int retcode, rc2;
|
||||||
|
vfo_t curr_vfo;
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
caps = rig->caps;
|
||||||
|
|
||||||
|
if (caps->wait_morse == NULL)
|
||||||
|
{
|
||||||
|
return wait_morse_ptt(rig, vfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((caps->targetable_vfo & RIG_TARGETABLE_PURE)
|
||||||
|
|| vfo == RIG_VFO_CURR
|
||||||
|
|| vfo == rig->state.current_vfo)
|
||||||
|
{
|
||||||
|
return caps->wait_morse(rig, vfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!caps->set_vfo)
|
||||||
|
{
|
||||||
|
return -RIG_ENTARGET;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr_vfo = rig->state.current_vfo;
|
||||||
|
retcode = caps->set_vfo(rig, vfo);
|
||||||
|
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
retcode = caps->wait_morse(rig, vfo);
|
||||||
|
/* try and revert even if we had an error above */
|
||||||
|
rc2 = caps->set_vfo(rig, curr_vfo);
|
||||||
|
|
||||||
|
if (RIG_OK == retcode)
|
||||||
|
{
|
||||||
|
/* return the first error code */
|
||||||
|
retcode = rc2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief send voice memory content
|
* \brief send voice memory content
|
||||||
|
|
Ładowanie…
Reference in New Issue