Add GPIO and GPION options for DCD.

Also bump abi version since the config params struct needed resizing.
pull/38/head
Jeroen Vreeken 2018-03-29 23:55:25 +02:00
rodzic ca85f4740c
commit bfa948ebc5
7 zmienionych plików z 120 dodań i 12 usunięć

Wyświetl plik

@ -55,9 +55,9 @@ ROT_BACKEND_LIST="amsat ars celestron cnctrk easycomm ether6 fodtrack gs232a hea
dnl See README.release on setting these values
# Values given to -version-info when linking. See libtool documentation.
# Set them here to keep c++/Makefile and src/Makefile in sync.
ABI_VERSION=3
ABI_REVISION=3
ABI_AGE=1
ABI_VERSION=4
ABI_REVISION=0
ABI_AGE=0
AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version])
AC_DEFINE_UNQUOTED([ABI_REVISION], [$ABI_REVISION], [Frontend ABI revision])

Wyświetl plik

@ -431,7 +431,9 @@ typedef enum {
RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */
RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */
RIG_DCD_PARALLEL, /*!< DCD status from parallel port pin */
RIG_DCD_CM108 /*!< DCD status from CM108 vol dn pin */
RIG_DCD_CM108, /*!< DCD status from CM108 vol dn pin */
RIG_DCD_GPIO, /*!< DCD status from GPIO pin */
RIG_DCD_GPION, /*!< DCD status from inverted GPIO pin */
} dcd_type_t;
@ -571,7 +573,7 @@ enum rig_conf_e {
};
#define RIG_COMBO_MAX 8
#define RIG_COMBO_MAX 16
/**
* \brief Configuration parameter structure.

Wyświetl plik

@ -91,7 +91,7 @@ static const struct confparams frontend_cfg_params[] =
{
TOK_PTT_TYPE, "ptt_type", "PTT type",
"Push-To-Talk interface type override",
"RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DTR", "RTS", "Parallel", "CM108", "None", NULL }} }
"RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DTR", "RTS", "Parallel", "CM108", "GPIO", "GPION", "None", NULL }} }
},
{
TOK_PTT_PATHNAME, "ptt_pathname", "PTT path name",
@ -106,7 +106,7 @@ static const struct confparams frontend_cfg_params[] =
{
TOK_DCD_TYPE, "dcd_type", "DCD type",
"Data Carrier Detect (or squelch) interface type override",
"RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DSR", "CTS", "CD", "Parallel", "CM108", "None", NULL }} }
"RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DSR", "CTS", "CD", "Parallel", "CM108", "GPIO", "GPION", "None", NULL }} }
},
{
TOK_DCD_PATHNAME, "dcd_pathname", "DCD path name",
@ -422,6 +422,14 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
{
rs->pttport.type.ptt = RIG_PTT_CM108;
}
else if (!strcmp(val, "GPIO"))
{
rs->pttport.type.ptt = RIG_PTT_GPIO;
}
else if (!strcmp(val, "GPION"))
{
rs->pttport.type.ptt = RIG_PTT_GPION;
}
else if (!strcmp(val, "None"))
{
rs->pttport.type.ptt = RIG_PTT_NONE;
@ -471,6 +479,14 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
{
rs->dcdport.type.dcd = RIG_DCD_CM108;
}
else if (!strcmp(val, "GPIO"))
{
rs->dcdport.type.dcd = RIG_DCD_GPIO;
}
else if (!strcmp(val, "GPION"))
{
rs->dcdport.type.dcd = RIG_DCD_GPION;
}
else if (!strcmp(val, "None"))
{
rs->dcdport.type.dcd = RIG_DCD_NONE;
@ -720,6 +736,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val)
s = "CM108";
break;
case RIG_PTT_GPIO:
s = "GPIO";
break;
case RIG_PTT_GPION:
s = "GPION";
break;
case RIG_PTT_NONE:
s = "None";
break;
@ -766,6 +790,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val)
s = "CM108";
break;
case RIG_DCD_GPIO:
s = "GPIO";
break;
case RIG_DCD_GPION:
s = "GPION";
break;
case RIG_DCD_NONE:
s = "None";
break;

Wyświetl plik

@ -29,7 +29,7 @@
#include "gpio.h"
int gpio_open(hamlib_port_t *port, int on_value)
int gpio_open(hamlib_port_t *port, int output, int on_value)
{
char pathname[FILPATHLEN];
FILE *fexp, *fdir;
@ -69,7 +69,13 @@ int gpio_open(hamlib_port_t *port, int on_value)
return -RIG_EIO;
}
fprintf(fdir, "out\n");
if (output)
{
fprintf(fdir, "out\n");
} else
{
fprintf(fdir, "in\n");
}
fclose(fdir);
snprintf(pathname,
@ -134,3 +140,26 @@ int gpio_ptt_get(hamlib_port_t *port, ptt_t *pttx)
return RIG_PTT_OFF;
}
}
int gpio_dcd_get(hamlib_port_t *port, dcd_t *dcdx)
{
char val;
int port_value;
lseek(port->fd, 0, SEEK_SET);
if (read(port->fd, &val, sizeof(val)) <= 0)
{
return -RIG_EIO;
}
port_value = val - '0';
if (port_value == port->parm.gpio.on_value)
{
return RIG_DCD_ON;
} else
{
return RIG_DCD_OFF;
}
}

Wyświetl plik

@ -28,10 +28,11 @@
__BEGIN_DECLS
/* Hamlib internal use, see rig.c */
int gpio_open(hamlib_port_t *p, int on_value);
int gpio_open(hamlib_port_t *p, int output, int on_value);
int gpio_close(hamlib_port_t *p);
int gpio_ptt_set(hamlib_port_t *p, ptt_t pttx);
int gpio_ptt_get(hamlib_port_t *p, ptt_t *pttx);
int gpio_dcd_get(hamlib_port_t *p, dcd_t *dcdx);
__END_DECLS

Wyświetl plik

@ -688,7 +688,7 @@ int HAMLIB_API rig_open(RIG *rig)
break;
case RIG_PTT_GPIO:
rs->pttport.fd = gpio_open(&rs->pttport, 1);
rs->pttport.fd = gpio_open(&rs->pttport, 1, 1);
if (rs->pttport.fd < 0)
{
@ -706,7 +706,7 @@ int HAMLIB_API rig_open(RIG *rig)
break;
case RIG_PTT_GPION:
rs->pttport.fd = gpio_open(&rs->pttport, 0);
rs->pttport.fd = gpio_open(&rs->pttport, 1, 0);
if (rs->pttport.fd < 0)
{
@ -780,6 +780,34 @@ 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;
}
break;
case RIG_DCD_GPION:
rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 0);
if (rs->dcdport.fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: cannot open DCD device \"%s\"\n",
__func__,
rs->dcdport.pathname);
status = -RIG_EIO;
}
break;
default:
rig_debug(RIG_DEBUG_ERR,
"%s: unsupported DCD type %d\n",
@ -969,6 +997,10 @@ int HAMLIB_API rig_close(RIG *rig)
port_close(&rs->dcdport, RIG_PORT_PARALLEL);
break;
case RIG_DCD_GPIO:
case RIG_DCD_GPION:
port_close(&rs->dcdport, RIG_PORT_GPIO);
default:
rig_debug(RIG_DEBUG_ERR,
"%s: unsupported DCD type %d\n",
@ -2036,6 +2068,10 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
case RIG_DCD_PARALLEL:
return par_dcd_get(&rig->state.dcdport, dcd);
case RIG_DCD_GPIO:
case RIG_DCD_GPION:
return gpio_dcd_get(&rig->state.dcdport, dcd);
case RIG_DCD_NONE:
return -RIG_ENAVAIL; /* not available */

Wyświetl plik

@ -300,6 +300,14 @@ int main(int argc, char *argv[])
{
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;