kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'master' of https://github.com/JeroenVreeken/Hamlib
commit
ac83428f7b
|
@ -55,9 +55,9 @@ ROT_BACKEND_LIST="amsat ars celestron cnctrk easycomm ether6 fodtrack gs232a hea
|
||||||
dnl See README.release on setting these values
|
dnl See README.release on setting these values
|
||||||
# Values given to -version-info when linking. See libtool documentation.
|
# Values given to -version-info when linking. See libtool documentation.
|
||||||
# Set them here to keep c++/Makefile and src/Makefile in sync.
|
# Set them here to keep c++/Makefile and src/Makefile in sync.
|
||||||
ABI_VERSION=3
|
ABI_VERSION=4
|
||||||
ABI_REVISION=3
|
ABI_REVISION=0
|
||||||
ABI_AGE=1
|
ABI_AGE=0
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version])
|
AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version])
|
||||||
AC_DEFINE_UNQUOTED([ABI_REVISION], [$ABI_REVISION], [Frontend ABI revision])
|
AC_DEFINE_UNQUOTED([ABI_REVISION], [$ABI_REVISION], [Frontend ABI revision])
|
||||||
|
|
|
@ -431,7 +431,9 @@ typedef enum {
|
||||||
RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */
|
RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */
|
||||||
RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */
|
RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */
|
||||||
RIG_DCD_PARALLEL, /*!< DCD status from parallel port pin */
|
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;
|
} 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.
|
* \brief Configuration parameter structure.
|
||||||
|
|
36
src/conf.c
36
src/conf.c
|
@ -91,7 +91,7 @@ static const struct confparams frontend_cfg_params[] =
|
||||||
{
|
{
|
||||||
TOK_PTT_TYPE, "ptt_type", "PTT type",
|
TOK_PTT_TYPE, "ptt_type", "PTT type",
|
||||||
"Push-To-Talk interface type override",
|
"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",
|
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",
|
TOK_DCD_TYPE, "dcd_type", "DCD type",
|
||||||
"Data Carrier Detect (or squelch) interface type override",
|
"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",
|
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;
|
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"))
|
else if (!strcmp(val, "None"))
|
||||||
{
|
{
|
||||||
rs->pttport.type.ptt = RIG_PTT_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;
|
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"))
|
else if (!strcmp(val, "None"))
|
||||||
{
|
{
|
||||||
rs->dcdport.type.dcd = RIG_DCD_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";
|
s = "CM108";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RIG_PTT_GPIO:
|
||||||
|
s = "GPIO";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_PTT_GPION:
|
||||||
|
s = "GPION";
|
||||||
|
break;
|
||||||
|
|
||||||
case RIG_PTT_NONE:
|
case RIG_PTT_NONE:
|
||||||
s = "None";
|
s = "None";
|
||||||
break;
|
break;
|
||||||
|
@ -766,6 +790,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val)
|
||||||
s = "CM108";
|
s = "CM108";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RIG_DCD_GPIO:
|
||||||
|
s = "GPIO";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_DCD_GPION:
|
||||||
|
s = "GPION";
|
||||||
|
break;
|
||||||
|
|
||||||
case RIG_DCD_NONE:
|
case RIG_DCD_NONE:
|
||||||
s = "None";
|
s = "None";
|
||||||
break;
|
break;
|
||||||
|
|
38
src/gpio.c
38
src/gpio.c
|
@ -29,7 +29,7 @@
|
||||||
#include "gpio.h"
|
#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*2];
|
char pathname[FILPATHLEN*2];
|
||||||
FILE *fexp, *fdir;
|
FILE *fexp, *fdir;
|
||||||
|
@ -69,14 +69,16 @@ int gpio_open(hamlib_port_t *port, int on_value)
|
||||||
return -RIG_EIO;
|
return -RIG_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fdir, "out\n");
|
char *dir = output ? "out" : "in";
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "Setting direction of GPIO%s to %s\n", port->pathname, dir);
|
||||||
|
fprintf(fdir, "%s\n", dir);
|
||||||
fclose(fdir);
|
fclose(fdir);
|
||||||
|
|
||||||
snprintf(pathname,
|
snprintf(pathname,
|
||||||
sizeof(pathname),
|
sizeof(pathname),
|
||||||
"/sys/class/gpio/gpio%s/value",
|
"/sys/class/gpio/gpio%s/value",
|
||||||
port->pathname);
|
port->pathname);
|
||||||
fd = open(pathname, O_WRONLY);
|
fd = open(pathname, O_RDWR);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -127,10 +129,36 @@ int gpio_ptt_get(hamlib_port_t *port, ptt_t *pttx)
|
||||||
{
|
{
|
||||||
if (port->parm.gpio.value)
|
if (port->parm.gpio.value)
|
||||||
{
|
{
|
||||||
return RIG_PTT_ON;
|
*pttx = RIG_PTT_ON;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return RIG_PTT_OFF;
|
*pttx = RIG_PTT_OFF;
|
||||||
}
|
}
|
||||||
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "DCD GPIO pin value: %c\n", val);
|
||||||
|
|
||||||
|
port_value = val - '0';
|
||||||
|
|
||||||
|
if (port_value == port->parm.gpio.on_value)
|
||||||
|
{
|
||||||
|
*dcdx = RIG_DCD_ON;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
*dcdx = RIG_DCD_OFF;
|
||||||
|
}
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/* Hamlib internal use, see rig.c */
|
/* 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_close(hamlib_port_t *p);
|
||||||
int gpio_ptt_set(hamlib_port_t *p, ptt_t pttx);
|
int gpio_ptt_set(hamlib_port_t *p, ptt_t pttx);
|
||||||
int gpio_ptt_get(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
|
__END_DECLS
|
||||||
|
|
||||||
|
|
40
src/rig.c
40
src/rig.c
|
@ -688,7 +688,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_GPIO:
|
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)
|
if (rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -706,7 +706,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_GPION:
|
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)
|
if (rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -780,6 +780,34 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
rig_debug(RIG_DEBUG_ERR,
|
rig_debug(RIG_DEBUG_ERR,
|
||||||
"%s: unsupported DCD type %d\n",
|
"%s: unsupported DCD type %d\n",
|
||||||
|
@ -969,6 +997,10 @@ int HAMLIB_API rig_close(RIG *rig)
|
||||||
port_close(&rs->dcdport, RIG_PORT_PARALLEL);
|
port_close(&rs->dcdport, RIG_PORT_PARALLEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RIG_DCD_GPIO:
|
||||||
|
case RIG_DCD_GPION:
|
||||||
|
port_close(&rs->dcdport, RIG_PORT_GPIO);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rig_debug(RIG_DEBUG_ERR,
|
rig_debug(RIG_DEBUG_ERR,
|
||||||
"%s: unsupported DCD type %d\n",
|
"%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:
|
case RIG_DCD_PARALLEL:
|
||||||
return par_dcd_get(&rig->state.dcdport, dcd);
|
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:
|
case RIG_DCD_NONE:
|
||||||
return -RIG_ENAVAIL; /* not available */
|
return -RIG_ENAVAIL; /* not available */
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,14 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
dcd_type = RIG_DCD_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"))
|
else if (!strcmp(optarg, "NONE"))
|
||||||
{
|
{
|
||||||
dcd_type = RIG_DCD_NONE;
|
dcd_type = RIG_DCD_NONE;
|
||||||
|
|
Ładowanie…
Reference in New Issue