pull/193/head
Michael Black 2020-01-27 17:12:03 -06:00
commit 87ff07d625
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6599353EC683404D
5 zmienionych plików z 81 dodań i 74 usunięć

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -53,6 +53,7 @@
#include "usb_port.h"
#include "network.h"
#include "cm108.h"
#include "gpio.h"
/**
* \brief Open a hamlib_port based on its rig port type
@ -184,8 +185,6 @@ int HAMLIB_API port_open(hamlib_port_t *p)
* \param p rig port descriptor
* \param port_type equivalent rig port type
* \return status
*
* This function may also be used with ptt and dcd ports.
*/
int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
{
@ -201,14 +200,6 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
ret = ser_close(p);
break;
case RIG_PORT_PARALLEL:
ret = par_close(p);
break;
case RIG_PORT_CM108:
ret = cm108_close(p);
break;
case RIG_PORT_USB:
ret = usb_port_close(p);
break;

Wyświetl plik

@ -690,31 +690,12 @@ int HAMLIB_API rig_open(RIG *rig)
break;
case RIG_PTT_GPIO:
rs->pttport.fd = gpio_open(&rs->pttport, 1, 1);
if (rs->pttport.fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: cannot open PTT device \"%s\"\n",
__func__,
rs->pttport.pathname);
status = -RIG_EIO;
}
else
{
gpio_ptt_set(&rs->pttport, RIG_PTT_OFF);
gpio_close(&rs->pttport);
}
break;
case RIG_PTT_GPION:
rs->pttport.fd = gpio_open(&rs->pttport, 1, 0);
rs->pttport.fd = gpio_open(&rs->pttport, 1, RIG_PTT_GPION == rs->pttport.type.ptt ? 0 : 1);
if (rs->pttport.fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: cannot open PTT device \"%s\"\n",
"%s: cannot open PTT device \"GPIO%s\"\n",
__func__,
rs->pttport.pathname);
status = -RIG_EIO;
@ -722,7 +703,6 @@ int HAMLIB_API rig_open(RIG *rig)
else
{
gpio_ptt_set(&rs->pttport, RIG_PTT_OFF);
gpio_close(&rs->pttport);
}
break;
@ -785,36 +765,16 @@ int HAMLIB_API rig_open(RIG *rig)
break;
case RIG_DCD_GPIO:
rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 1);
if (rs->dcdport.fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: cannot open DCD device \"%s\"\n",
__func__,
rs->dcdport.pathname);
status = -RIG_EIO;
}
else {
gpio_close(&rs->dcdport);
}
break;
case RIG_DCD_GPION:
rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 0);
rs->dcdport.fd = gpio_open(&rs->dcdport, 0, RIG_DCD_GPION == rs->dcdport.type.dcd ? 0 : 1);
if (rs->dcdport.fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: cannot open DCD device \"%s\"\n",
"%s: cannot open DCD device \"GPIO%s\"\n",
__func__,
rs->dcdport.pathname);
status = -RIG_EIO;
}
else {
gpio_close(&rs->dcdport);
}
break;
@ -969,18 +929,19 @@ int HAMLIB_API rig_close(RIG *rig)
case RIG_PTT_PARALLEL:
par_ptt_set(&rs->pttport, RIG_PTT_OFF);
port_close(&rs->pttport, RIG_PORT_PARALLEL);
par_close(&rs->pttport);
break;
case RIG_PTT_CM108:
cm108_ptt_set(&rs->pttport, RIG_PTT_OFF);
port_close(&rs->pttport, RIG_PORT_CM108);
cm108_close(&rs->pttport);
break;
case RIG_PTT_GPIO:
case RIG_PTT_GPION:
gpio_ptt_set(&rs->pttport, RIG_PTT_OFF);
port_close(&rs->pttport, RIG_PORT_GPIO);
gpio_close(&rs->pttport);
break;
default:
rig_debug(RIG_DEBUG_ERR,
@ -1006,12 +967,13 @@ int HAMLIB_API rig_close(RIG *rig)
break;
case RIG_DCD_PARALLEL:
port_close(&rs->dcdport, RIG_PORT_PARALLEL);
par_close(&rs->dcdport);
break;
case RIG_DCD_GPIO:
case RIG_DCD_GPION:
port_close(&rs->dcdport, RIG_PORT_GPIO);
gpio_close(&rs->dcdport);
break;
default:
rig_debug(RIG_DEBUG_ERR,

Wyświetl plik

@ -259,7 +259,8 @@ int main(int argc, char *argv[])
}
else
{
ptt_type = atoi(optarg);
puts("Unrecognised PTT type, using NONE");
ptt_type = RIG_PTT_NONE;
}
break;
@ -309,7 +310,8 @@ int main(int argc, char *argv[])
}
else
{
dcd_type = atoi(optarg);
puts("Unrecognised DCD type, using NONE");
dcd_type = RIG_DCD_NONE;
}
break;

Wyświetl plik

@ -352,13 +352,22 @@ int main(int argc, char *argv[])
{
ptt_type = RIG_PTT_CM108;
}
else if (!strcmp(optarg, "GPIO"))
{
ptt_type = RIG_PTT_GPIO;
}
else if (!strcmp(optarg, "GPION"))
{
ptt_type = RIG_PTT_GPION;
}
else if (!strcmp(optarg, "NONE"))
{
ptt_type = RIG_PTT_NONE;
}
else
{
ptt_type = atoi(optarg);
puts("Unrecognised PTT type, using NONE");
ptt_type = RIG_PTT_NONE;
}
break;
@ -390,13 +399,26 @@ int main(int argc, char *argv[])
{
dcd_type = RIG_DCD_PARALLEL;
}
else if (!strcmp(optarg, "CM108"))
{
dcd_type = RIG_DCD_CM108;
}
else if (!strcmp(optarg, "GPIO"))
{
dcd_type = RIG_DCD_GPIO;
}
else if (!strcmp(optarg, "GPION"))
{
dcd_type = RIG_DCD_GPION;
}
else if (!strcmp(optarg, "NONE"))
{
dcd_type = RIG_DCD_NONE;
}
else
{
dcd_type = atoi(optarg);
puts("Unrecognised DCD type, using NONE");
dcd_type = RIG_DCD_NONE;
}
break;