Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Northern Voices listener #46

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/bindings/python/pycsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <csp/drivers/can_socketcan.h>
#include <csp/csp_endian.h>
#include <csp/interfaces/csp_if_sdr.h>
#include <sdr_rx_fwd.h>
#include <fec.h>

#include <sys/types.h>
Expand Down Expand Up @@ -878,6 +879,9 @@ static PyObject* pycsp_sband_init(PyObject *self, PyObject *args) {

}

// Used by sdr_rx_fwd_init
static sdr_interface_data_t *uhf_ifdata;

static PyObject* pycsp_uhf_init(PyObject *self, PyObject *args) {
char* device;
uint32_t uart_baudrate = 0;
Expand All @@ -889,15 +893,31 @@ static PyObject* pycsp_uhf_init(PyObject *self, PyObject *args) {
}

sdr_conf_t sdr_conf = {0};
csp_iface_t *uhf_iface;
sdr_conf.use_fec = use_fec;
sdr_conf.uhf_conf.uhf_baudrate = uhf_baudrate;
sdr_conf.uhf_conf.uart_baudrate = uart_baudrate;
sdr_conf.uhf_conf.device_file = device;
int res = csp_sdr_open_and_add_interface(&sdr_conf, if_name, NULL);
int res = csp_sdr_open_and_add_interface(&sdr_conf, if_name, &uhf_iface);
if (res != CSP_ERR_NONE) {
return PyErr_Error("csp_sdr_open_and_add_interface()", res);
}

uhf_ifdata = (sdr_interface_data_t *) uhf_iface->interface_data;

Py_RETURN_NONE;
}

static PyObject* pycsp_set_sdr_rx(PyObject *self, PyObject *args) {
/* The forwarder argument can be used (eventually) to exercise different
* forwarder apps.
*/
int forwarder = 0;
if (!PyArg_ParseTuple(args, "|I", &forwarder)) {
return NULL; // TypeError is thrown
}

sdr_rx_fwd_init(uhf_ifdata, NULL);
Py_RETURN_NONE;
}

Expand Down Expand Up @@ -1016,8 +1036,8 @@ static PyMethodDef methods[] = {
{"kiss_init", pycsp_kiss_init, METH_VARARGS, ""},
{"sdr_init", pycsp_sdr_init, METH_VARARGS, ""},
{"uhf_init", pycsp_uhf_init, METH_VARARGS, ""},
{"sband_init", pycsp_sband_init, METH_VARARGS, ""},

{"sband_init", pycsp_sband_init, METH_VARARGS, ""},
{"set_sdr_rx", pycsp_set_sdr_rx, METH_VARARGS, ""},

/* csp/drivers/can_socketcan.h */
{"can_socketcan_init", pycsp_can_socketcan_init, METH_VARARGS, ""},
Expand Down Expand Up @@ -1142,4 +1162,3 @@ PyMODINIT_FUNC PyInit_libcsp_py3(void) {

return m;
}

3 changes: 2 additions & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def configure(ctx):

# Setup CFLAGS
if (len(ctx.stack_path) <= 1) and (len(ctx.env.CFLAGS) == 0):
ctx.env.prepend_value('CFLAGS', ["-std=gnu99", "-g", "-Os", "-Wall", "-Wextra", "-Wshadow", "-Wcast-align",
ctx.env.prepend_value('CFLAGS', ["-std=gnu99", "-g", "-O3", "-Wall", "-Wextra", "-Wshadow", "-Wcast-align",
"-Wwrite-strings", "-Wno-unused-parameter", "-Werror", "-lstdc++", "-fPIC"])

# Setup default include path and any extra defined
Expand Down Expand Up @@ -167,6 +167,7 @@ def configure(ctx):
'ex2_sdr/lib/driver/fec.c',
'ex2_sdr/lib/driver/sdr_init.c',
'ex2_sdr/lib/driver/gnuradio.c',
'ex2_sdr/lib/driver/sdr_rx_fwd.c',
'ex2_sdr/lib/wrapper/MACWrapper.cpp',
'ex2_sdr/lib/error_control/error_correction.cpp',
'ex2_sdr/lib/error_control/ConvolutionalCodecHD.cpp',
Expand Down