From c7125fe21d3cde9266e94c26f61d9da7ecec130a Mon Sep 17 00:00:00 2001 From: Rob French Date: Sat, 29 Feb 2020 01:29:30 -0600 Subject: [PATCH] Added quisk_close_key to the list of publicly available functions, so I can close the existing key and open a new one if desired. Also added some debug updates to the GPIO keyer. --- gpiokeyer.c | 10 ++++++++++ quisk.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/gpiokeyer.c b/gpiokeyer.c index a501fff..88f867c 100644 --- a/gpiokeyer.c +++ b/gpiokeyer.c @@ -437,6 +437,10 @@ static void* keyer_thread(void *arg) { } } } + + #if defined(DEBUG) + fprintf(stdout, "[GPIO Keyer] thread should be ending now\n"); + #endif } int open_key_gpiokeyer(const char * name) @@ -494,10 +498,16 @@ int open_key_gpiokeyer(const char * name) void close_key_gpiokeyer(void) { + #if defined(DEBUG) + fprintf(stdout, "[GPIO Keyer] closing key\n"); + #endif running = 0; sem_post(&cw_event); pthread_join(keyer_thread_id, 0); sem_destroy(&cw_event); + #if defined(DEBUG) + fprintf(stdout, "[GPIO Keyer] keyer closed\n"); + #endif } int is_key_down_gpiokeyer(void) diff --git a/quisk.c b/quisk.c index 91705cc..f416024 100755 --- a/quisk.c +++ b/quisk.c @@ -3045,6 +3045,15 @@ static PyObject * open_key(PyObject * self, PyObject * args) return PyInt_FromLong(quisk_open_key(name)); } +static PyObject * close_key(PyObject * self, PyObject * args) +{ + if (!PyArg_ParseTuple (args, "")) + return NULL; + quisk_close_key(); + Py_INCREF (Py_None); + return Py_None; +} + static void close_udp(void) { short msg = 0x7373; // shutdown @@ -5332,6 +5341,7 @@ static PyMethodDef QuiskMethods[] = { {"start_sound", start_sound, METH_VARARGS, "Start the soundcard."}, {"mixer_set", mixer_set, METH_VARARGS, "Set microphone mixer parameters such as volume."}, {"open_key", open_key, METH_VARARGS, "Open access to the state of the key (CW or PTT)."}, + {"close_key", close_key, METH_VARARGS, "Close the currently selected key."}, {"open_rx_udp", open_rx_udp, METH_VARARGS, "Open a UDP port for capture."}, {"close_rx_udp", close_rx_udp, METH_VARARGS, "Close the UDP port used for capture."}, {"add_rx_samples", add_rx_samples, METH_VARARGS, "Record the Rx samples received by Python code."},