kopia lustrzana https://github.com/Hamlib/Hamlib
Improved get PTT state handling in dummy backend
rodzic
be0f371bde
commit
caed2d73a1
|
@ -33,6 +33,8 @@
|
|||
#include "hamlib/rig.h"
|
||||
#include "serial.h"
|
||||
#include "parallel.h"
|
||||
#include "cm108.h"
|
||||
#include "gpio.h"
|
||||
#include "misc.h"
|
||||
#include "tones.h"
|
||||
#include "idx_builtin.h"
|
||||
|
@ -496,29 +498,57 @@ static int dummy_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
static int dummy_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||
{
|
||||
struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv;
|
||||
int rc;
|
||||
int status = 0;
|
||||
ptt_t par_status = RIG_PTT_OFF;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
*ptt = priv->ptt;
|
||||
|
||||
// sneak a look at the hardware PTT and OR that in with our result
|
||||
// as if it had keyed us
|
||||
switch (rig->state.pttport.type.ptt)
|
||||
{
|
||||
case RIG_PTT_SERIAL_DTR: if (rig->state.pttport.fd >= 0) ser_get_dtr(
|
||||
&rig->state.pttport, &status); break;
|
||||
case RIG_PTT_SERIAL_DTR:
|
||||
if (rig->state.pttport.fd >= 0)
|
||||
{
|
||||
if (RIG_OK != (rc = ser_get_dtr(&rig->state.pttport, &status))) return rc;
|
||||
*ptt = status ? RIG_PTT_ON : RIG_PTT_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case RIG_PTT_SERIAL_RTS: if (rig->state.pttport.fd >= 0) ser_get_rts(
|
||||
&rig->state.pttport, &status); break;
|
||||
case RIG_PTT_SERIAL_RTS:
|
||||
if (rig->state.pttport.fd >= 0)
|
||||
{
|
||||
if (RIG_OK != (rc = ser_get_rts(&rig->state.pttport, &status))) return rc;
|
||||
*ptt = status ? RIG_PTT_ON : RIG_PTT_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case RIG_PTT_PARALLEL: if (rig->state.pttport.fd >= 0) par_ptt_get(
|
||||
&rig->state.pttport, &par_status); break;
|
||||
case RIG_PTT_PARALLEL:
|
||||
if (rig->state.pttport.fd >= 0)
|
||||
{
|
||||
if (RIG_OK != (rc = par_ptt_get(&rig->state.pttport, ptt))) return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
case RIG_PTT_CM108:
|
||||
if (rig->state.pttport.fd >= 0)
|
||||
{
|
||||
if (RIG_OK != (rc = cm108_ptt_get(&rig->state.pttport, ptt))) return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
case RIG_PTT_GPIO:
|
||||
case RIG_PTT_GPION:
|
||||
if (rig->state.pttport.fd >= 0)
|
||||
{
|
||||
if (RIG_OK != (rc = gpio_ptt_get(&rig->state.pttport, ptt))) return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
*ptt = priv->ptt;
|
||||
break;
|
||||
}
|
||||
|
||||
*ptt = *ptt || status || RIG_PTT_ON == par_status;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue