summaryrefslogtreecommitdiff
path: root/usrp/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usrp/host/lib')
-rw-r--r--usrp/host/lib/Makefile.am153
-rw-r--r--usrp/host/lib/README_OSX (renamed from usrp/host/lib/legacy/README_OSX)0
-rw-r--r--usrp/host/lib/ad9862.h (renamed from usrp/host/lib/legacy/ad9862.h)0
-rwxr-xr-xusrp/host/lib/check_data.py (renamed from usrp/host/lib/legacy/check_data.py)0
-rw-r--r--usrp/host/lib/circular_buffer.h (renamed from usrp/host/lib/legacy/circular_buffer.h)0
-rw-r--r--usrp/host/lib/circular_linked_list.h (renamed from usrp/host/lib/legacy/circular_linked_list.h)0
-rw-r--r--usrp/host/lib/darwin_libusb.h (renamed from usrp/host/lib/legacy/darwin_libusb.h)0
-rw-r--r--usrp/host/lib/db_base.cc (renamed from usrp/host/lib/legacy/db_base.cc)4
-rw-r--r--usrp/host/lib/db_base_impl.h (renamed from usrp/host/lib/legacy/db_base_impl.h)8
-rw-r--r--usrp/host/lib/db_basic.cc (renamed from usrp/host/lib/legacy/db_basic.cc)5
-rw-r--r--usrp/host/lib/db_boards.cc (renamed from usrp/host/lib/legacy/db_boards.cc)21
-rw-r--r--usrp/host/lib/db_boards.h (renamed from usrp/host/lib/legacy/db_boards.h)4
-rw-r--r--usrp/host/lib/db_dbs_rx.cc (renamed from usrp/host/lib/legacy/db_dbs_rx.cc)2
-rw-r--r--usrp/host/lib/db_dtt754.cc (renamed from usrp/host/lib/legacy/db_dtt754.cc)2
-rw-r--r--usrp/host/lib/db_dtt768.cc (renamed from usrp/host/lib/legacy/db_dtt768.cc)2
-rw-r--r--usrp/host/lib/db_flexrf.cc (renamed from usrp/host/lib/legacy/db_flexrf.cc)2
-rw-r--r--usrp/host/lib/db_flexrf_mimo.cc (renamed from usrp/host/lib/legacy/db_flexrf_mimo.cc)6
-rw-r--r--usrp/host/lib/db_tv_rx.cc (renamed from usrp/host/lib/legacy/db_tv_rx.cc)2
-rw-r--r--usrp/host/lib/db_util.cc (renamed from usrp/host/lib/legacy/db_util.cc)0
-rw-r--r--usrp/host/lib/db_util.h (renamed from usrp/host/lib/legacy/db_util.h)0
-rw-r--r--usrp/host/lib/db_xcvr2450.cc (renamed from usrp/host/lib/legacy/db_xcvr2450.cc)2
-rwxr-xr-xusrp/host/lib/dump_data.py (renamed from usrp/host/lib/legacy/dump_data.py)0
-rw-r--r--usrp/host/lib/fusb.cc (renamed from usrp/host/lib/legacy/fusb.cc)0
-rw-r--r--usrp/host/lib/fusb.h (renamed from usrp/host/lib/legacy/fusb.h)0
-rw-r--r--usrp/host/lib/fusb_darwin.cc (renamed from usrp/host/lib/legacy/fusb_darwin.cc)0
-rw-r--r--usrp/host/lib/fusb_darwin.h (renamed from usrp/host/lib/legacy/fusb_darwin.h)0
-rw-r--r--usrp/host/lib/fusb_generic.cc (renamed from usrp/host/lib/legacy/fusb_generic.cc)0
-rw-r--r--usrp/host/lib/fusb_generic.h (renamed from usrp/host/lib/legacy/fusb_generic.h)0
-rw-r--r--usrp/host/lib/fusb_linux.cc (renamed from usrp/host/lib/legacy/fusb_linux.cc)0
-rw-r--r--usrp/host/lib/fusb_linux.h (renamed from usrp/host/lib/legacy/fusb_linux.h)0
-rw-r--r--usrp/host/lib/fusb_ra_wb.cc (renamed from usrp/host/lib/legacy/fusb_ra_wb.cc)0
-rw-r--r--usrp/host/lib/fusb_ra_wb.h (renamed from usrp/host/lib/legacy/fusb_ra_wb.h)0
-rw-r--r--usrp/host/lib/fusb_sysconfig_darwin.cc (renamed from usrp/host/lib/legacy/fusb_sysconfig_darwin.cc)0
-rw-r--r--usrp/host/lib/fusb_sysconfig_generic.cc (renamed from usrp/host/lib/legacy/fusb_sysconfig_generic.cc)0
-rw-r--r--usrp/host/lib/fusb_sysconfig_linux.cc (renamed from usrp/host/lib/legacy/fusb_sysconfig_linux.cc)0
-rw-r--r--usrp/host/lib/fusb_sysconfig_ra_wb.cc (renamed from usrp/host/lib/legacy/fusb_sysconfig_ra_wb.cc)0
-rw-r--r--usrp/host/lib/fusb_sysconfig_win32.cc (renamed from usrp/host/lib/legacy/fusb_sysconfig_win32.cc)0
-rw-r--r--usrp/host/lib/fusb_win32.cc (renamed from usrp/host/lib/legacy/fusb_win32.cc)0
-rw-r--r--usrp/host/lib/fusb_win32.h (renamed from usrp/host/lib/legacy/fusb_win32.h)0
-rwxr-xr-xusrp/host/lib/gen_usrp_dbid.py (renamed from usrp/host/lib/legacy/gen_usrp_dbid.py)6
-rw-r--r--usrp/host/lib/inband/Makefile.am114
-rwxr-xr-xusrp/host/lib/inband/dump_packets.py65
-rwxr-xr-xusrp/host/lib/inband/gen_test_packets.py88
-rw-r--r--usrp/host/lib/inband/qa_inband.cc35
-rw-r--r--usrp/host/lib/inband/qa_inband.h35
-rw-r--r--usrp/host/lib/inband/qa_inband_packet_prims.cc162
-rw-r--r--usrp/host/lib/inband/qa_inband_packet_prims.h41
-rw-r--r--usrp/host/lib/inband/qa_inband_usrp_server.cc1575
-rw-r--r--usrp/host/lib/inband/qa_inband_usrp_server.h50
-rw-r--r--usrp/host/lib/inband/symbols_usrp_channel.h40
-rw-r--r--usrp/host/lib/inband/symbols_usrp_interface_cs.h43
-rw-r--r--usrp/host/lib/inband/symbols_usrp_low_level_cs.h47
-rw-r--r--usrp/host/lib/inband/symbols_usrp_rx.h36
-rw-r--r--usrp/host/lib/inband/symbols_usrp_rx_cs.h32
-rw-r--r--usrp/host/lib/inband/symbols_usrp_server_cs.h47
-rw-r--r--usrp/host/lib/inband/symbols_usrp_tx.h32
-rw-r--r--usrp/host/lib/inband/symbols_usrp_tx_cs.h32
-rw-r--r--usrp/host/lib/inband/test_inband.cc36
-rw-r--r--usrp/host/lib/inband/usb_packet.py115
-rw-r--r--usrp/host/lib/inband/usrp_inband_usb_packet.cc793
-rw-r--r--usrp/host/lib/inband/usrp_inband_usb_packet.h240
-rw-r--r--usrp/host/lib/inband/usrp_interface.mbh88
-rw-r--r--usrp/host/lib/inband/usrp_rx.cc184
-rw-r--r--usrp/host/lib/inband/usrp_rx.h58
-rw-r--r--usrp/host/lib/inband/usrp_rx_stub.cc227
-rw-r--r--usrp/host/lib/inband/usrp_rx_stub.h79
-rw-r--r--usrp/host/lib/inband/usrp_server.cc1860
-rw-r--r--usrp/host/lib/inband/usrp_server.h131
-rw-r--r--usrp/host/lib/inband/usrp_server.mbh255
-rw-r--r--usrp/host/lib/inband/usrp_tx.cc150
-rw-r--r--usrp/host/lib/inband/usrp_tx.h52
-rw-r--r--usrp/host/lib/inband/usrp_tx_stub.cc344
-rw-r--r--usrp/host/lib/inband/usrp_tx_stub.h61
-rw-r--r--usrp/host/lib/inband/usrp_usb_interface.cc601
-rw-r--r--usrp/host/lib/inband/usrp_usb_interface.h78
-rw-r--r--usrp/host/lib/legacy/Makefile.am196
-rw-r--r--usrp/host/lib/legacy/db_base.h119
-rw-r--r--usrp/host/lib/legacy/db_base.i102
-rw-r--r--usrp/host/lib/legacy/db_basic.h99
-rw-r--r--usrp/host/lib/legacy/db_dbs_rx.h83
-rw-r--r--usrp/host/lib/legacy/db_dtt754.h57
-rw-r--r--usrp/host/lib/legacy/db_dtt768.h57
-rw-r--r--usrp/host/lib/legacy/db_flexrf.h355
-rw-r--r--usrp/host/lib/legacy/db_flexrf_mimo.h163
-rw-r--r--usrp/host/lib/legacy/db_tv_rx.h56
-rw-r--r--usrp/host/lib/legacy/db_xcvr2450.h92
-rw-r--r--usrp/host/lib/legacy/usrp_basic.h991
-rw-r--r--usrp/host/lib/legacy/usrp_bytesex.h108
-rw-r--r--usrp/host/lib/legacy/usrp_local_sighandler.h61
-rw-r--r--usrp/host/lib/legacy/usrp_prims.h294
-rw-r--r--usrp/host/lib/legacy/usrp_slots.h33
-rw-r--r--usrp/host/lib/legacy/usrp_standard.h452
-rw-r--r--usrp/host/lib/legacy/usrp_subdev_spec.h50
-rw-r--r--usrp/host/lib/legacy/usrp_tune_result.h44
-rw-r--r--usrp/host/lib/limbo/db_wbx.cc (renamed from usrp/host/lib/legacy/db_wbx.cc)0
-rw-r--r--usrp/host/lib/limbo/db_wbx.h (renamed from usrp/host/lib/legacy/db_wbx.h)0
-rw-r--r--usrp/host/lib/md5.c (renamed from usrp/host/lib/legacy/md5.c)0
-rw-r--r--usrp/host/lib/md5.h (renamed from usrp/host/lib/legacy/md5.h)0
-rw-r--r--usrp/host/lib/mld_threads.h (renamed from usrp/host/lib/legacy/mld_threads.h)0
-rw-r--r--usrp/host/lib/rate_to_regval.h (renamed from usrp/host/lib/legacy/rate_to_regval.h)0
-rw-r--r--usrp/host/lib/std_paths.h.in (renamed from usrp/host/lib/legacy/std_paths.h.in)0
-rw-r--r--usrp/host/lib/usrp_basic.cc (renamed from usrp/host/lib/legacy/usrp_basic.cc)6
-rw-r--r--usrp/host/lib/usrp_config.cc (renamed from usrp/host/lib/legacy/usrp_config.cc)0
-rw-r--r--usrp/host/lib/usrp_config.h (renamed from usrp/host/lib/legacy/usrp_config.h)0
-rw-r--r--usrp/host/lib/usrp_dbid.dat (renamed from usrp/host/lib/legacy/usrp_dbid.dat)0
-rw-r--r--usrp/host/lib/usrp_local_sighandler.cc (renamed from usrp/host/lib/legacy/usrp_local_sighandler.cc)4
-rw-r--r--usrp/host/lib/usrp_prims.cc (renamed from usrp/host/lib/legacy/usrp_prims.cc)4
-rw-r--r--usrp/host/lib/usrp_standard.cc (renamed from usrp/host/lib/legacy/usrp_standard.cc)6
108 files changed, 193 insertions, 11284 deletions
diff --git a/usrp/host/lib/Makefile.am b/usrp/host/lib/Makefile.am
index 2062bda62..8482485f5 100644
--- a/usrp/host/lib/Makefile.am
+++ b/usrp/host/lib/Makefile.am
@@ -1,7 +1,7 @@
#
# USRP - Universal Software Radio Peripheral
#
-# Copyright (C) 2003,2004,2006,2007 Free Software Foundation, Inc.
+# Copyright (C) 2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,5 +20,154 @@
include $(top_srcdir)/Makefile.common
-SUBDIRS = legacy inband
+common_INCLUDES = $(USRP_INCLUDES)
+lib_LTLIBRARIES = libusrp.la
+
+libusrp_la_common_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 $(BOOST_LDFLAGS)
+
+libusrp_la_common_LIBADD = \
+ $(USB_LIBS) \
+ $(BOOST_THREAD_LIB) \
+ ../misc/libmisc.la
+
+# darwin fusb requires omnithreads
+if FUSB_TECH_darwin
+AM_CPPFLAGS = $(common_INCLUDES) $(OMNITHREAD_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES)
+libusrp_la_LIBADD = $(libusrp_la_common_LIBADD) $(OMNITHREAD_LA)
+libusrp_la_LDFLAGS = $(libusrp_la_common_LDFLAGS) -framework CoreFoundation
+else
+AM_CPPFLAGS = $(common_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES)
+libusrp_la_LIBADD = $(libusrp_la_common_LIBADD)
+libusrp_la_LDFLAGS = $(libusrp_la_common_LDFLAGS)
+endif
+
+EXTRA_DIST = \
+ std_paths.h.in \
+ usrp_dbid.dat
+
+BUILT_SOURCES = \
+ $(abs_top_builddir)/usrp/host/include/usrp/usrp_dbid.h
+
+BUILT_SOURCES += usrp_dbid.cc \
+ usrp_dbid.py
+
+# ----------------------------------------------------------------
+# FUSB_TECH is set at configure time by way of
+# usrp/config/usrp_fusb_tech.m4.
+# It indicates which fast usb strategy we should be building.
+# We currently implement "generic", "darwin", "win32" and "linux"
+
+
+generic_CODE = \
+ fusb_generic.cc \
+ fusb_sysconfig_generic.cc
+
+darwin_CODE = \
+ fusb_darwin.cc \
+ fusb_sysconfig_darwin.cc \
+ README_OSX \
+ circular_buffer.h \
+ circular_linked_list.h \
+ darwin_libusb.h \
+ mld_threads.h
+
+win32_CODE = \
+ fusb_win32.cc \
+ fusb_sysconfig_win32.cc
+
+linux_CODE = \
+ fusb_linux.cc \
+ fusb_sysconfig_linux.cc
+
+ra_wb_CODE = \
+ fusb_ra_wb.cc \
+ fusb_sysconfig_ra_wb.cc
+
+
+#
+# include each <foo>_CODE entry here...
+#
+EXTRA_libusrp_la_SOURCES = \
+ $(generic_CODE) \
+ $(darwin_CODE) \
+ $(win32_CODE) \
+ $(linux_CODE) \
+ $(ra_wb_CODE)
+
+
+# work around automake deficiency
+libusrp_la_common_SOURCES = \
+ fusb.cc \
+ md5.c \
+ usrp_basic.cc \
+ usrp_config.cc \
+ usrp_dbid.cc \
+ usrp_local_sighandler.cc \
+ usrp_prims.cc \
+ usrp_standard.cc \
+ db_boards.cc \
+ db_base.cc \
+ db_basic.cc \
+ db_tv_rx.cc \
+ db_flexrf.cc \
+ db_flexrf_mimo.cc \
+ db_dbs_rx.cc \
+ db_xcvr2450.cc \
+ db_dtt754.cc \
+ db_dtt768.cc \
+ db_util.cc
+
+
+
+if FUSB_TECH_generic
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(generic_CODE)
+endif
+
+if FUSB_TECH_darwin
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(darwin_CODE)
+endif
+
+if FUSB_TECH_win32
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(win32_CODE)
+endif
+
+if FUSB_TECH_linux
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(linux_CODE)
+endif
+
+if FUSB_TECH_ra_wb
+libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(ra_wb_CODE)
+endif
+
+noinst_HEADERS = \
+ ad9862.h \
+ db_base_impl.h \
+ db_boards.h \
+ db_util.h \
+ fusb.h \
+ fusb_darwin.h \
+ fusb_generic.h \
+ fusb_linux.h \
+ fusb_ra_wb.h \
+ fusb_win32.h \
+ md5.h \
+ rate_to_regval.h \
+ usrp_config.h
+
+if PYTHON
+usrppython_PYTHON = \
+ usrp_dbid.py
+
+noinst_PYTHON = \
+ gen_usrp_dbid.py \
+ check_data.py \
+ dump_data.py
+endif
+
+# common way for generating sources from templates when using
+# BUILT_SOURCES, using parallel build protection.
+gen_sources = $(BUILT_SOURCES)
+gen_sources_deps = gen_usrp_dbid.py usrp_dbid.dat
+par_gen_command = PYTHONPATH=$(top_srcdir)/usrp/src srcdir=$(srcdir) $(PYTHON) $(srcdir)/gen_usrp_dbid.py $(srcdir)/usrp_dbid.dat
+include $(top_srcdir)/Makefile.par.gen
diff --git a/usrp/host/lib/legacy/README_OSX b/usrp/host/lib/README_OSX
index 37026f25a..37026f25a 100644
--- a/usrp/host/lib/legacy/README_OSX
+++ b/usrp/host/lib/README_OSX
diff --git a/usrp/host/lib/legacy/ad9862.h b/usrp/host/lib/ad9862.h
index 4375d93d8..4375d93d8 100644
--- a/usrp/host/lib/legacy/ad9862.h
+++ b/usrp/host/lib/ad9862.h
diff --git a/usrp/host/lib/legacy/check_data.py b/usrp/host/lib/check_data.py
index 100f0f6dd..100f0f6dd 100755
--- a/usrp/host/lib/legacy/check_data.py
+++ b/usrp/host/lib/check_data.py
diff --git a/usrp/host/lib/legacy/circular_buffer.h b/usrp/host/lib/circular_buffer.h
index 8898e4194..8898e4194 100644
--- a/usrp/host/lib/legacy/circular_buffer.h
+++ b/usrp/host/lib/circular_buffer.h
diff --git a/usrp/host/lib/legacy/circular_linked_list.h b/usrp/host/lib/circular_linked_list.h
index e495d609b..e495d609b 100644
--- a/usrp/host/lib/legacy/circular_linked_list.h
+++ b/usrp/host/lib/circular_linked_list.h
diff --git a/usrp/host/lib/legacy/darwin_libusb.h b/usrp/host/lib/darwin_libusb.h
index 063a2e9c6..063a2e9c6 100644
--- a/usrp/host/lib/legacy/darwin_libusb.h
+++ b/usrp/host/lib/darwin_libusb.h
diff --git a/usrp/host/lib/legacy/db_base.cc b/usrp/host/lib/db_base.cc
index 80c6d4665..102166a86 100644
--- a/usrp/host/lib/legacy/db_base.cc
+++ b/usrp/host/lib/db_base.cc
@@ -1,5 +1,5 @@
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
@@ -19,7 +19,7 @@
// Boston, MA 02110-1301, USA.
//
-#include <db_base.h>
+#include <usrp/db_base.h>
#include <db_base_impl.h>
#if 0
diff --git a/usrp/host/lib/legacy/db_base_impl.h b/usrp/host/lib/db_base_impl.h
index bb4d95d73..9d5ca4370 100644
--- a/usrp/host/lib/legacy/db_base_impl.h
+++ b/usrp/host/lib/db_base_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,12 +21,12 @@
#ifndef INCLUDED_DB_BASE_IMPL_H
#define INCLUDED_DB_BASE_IMPL_H
-#include <db_base.h>
+#include <usrp/db_base.h>
#include <db_util.h>
-#include <usrp_basic.h>
+#include <usrp/usrp_basic.h>
#include <fpga_regs_standard.h>
#include <fpga_regs_common.h>
-#include <usrp_prims.h>
+#include <usrp/usrp_prims.h>
#include <usrp_spi_defs.h>
#include <stdexcept>
diff --git a/usrp/host/lib/legacy/db_basic.cc b/usrp/host/lib/db_basic.cc
index 4bafc9396..0c6bedec4 100644
--- a/usrp/host/lib/legacy/db_basic.cc
+++ b/usrp/host/lib/db_basic.cc
@@ -1,5 +1,5 @@
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
@@ -18,10 +18,9 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_basic.h>
+#include <usrp/db_basic.h>
#include <db_base_impl.h>
-
db_basic_tx::db_basic_tx(boost::shared_ptr<usrp_basic> usrp, int which)
: db_base(usrp, which)
{
diff --git a/usrp/host/lib/legacy/db_boards.cc b/usrp/host/lib/db_boards.cc
index b537698be..070b8dd4e 100644
--- a/usrp/host/lib/legacy/db_boards.cc
+++ b/usrp/host/lib/db_boards.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
@@ -21,16 +21,15 @@
//
#include <db_boards.h>
-#include <usrp_dbid.h>
-#include <db_basic.h>
-#include <db_tv_rx.h>
-#include <db_dbs_rx.h>
-#include <db_flexrf.h>
-#include <db_flexrf_mimo.h>
-#include <db_xcvr2450.h>
-#include <db_wbx.h>
-#include <db_dtt754.h>
-#include <db_dtt768.h>
+#include <usrp/usrp_dbid.h>
+#include <usrp/db_basic.h>
+#include <usrp/db_tv_rx.h>
+#include <usrp/db_dbs_rx.h>
+#include <usrp/db_flexrf.h>
+#include <usrp/db_flexrf_mimo.h>
+#include <usrp/db_xcvr2450.h>
+#include <usrp/db_dtt754.h>
+#include <usrp/db_dtt768.h>
#include <cstdio>
std::vector<db_base_sptr>
diff --git a/usrp/host/lib/legacy/db_boards.h b/usrp/host/lib/db_boards.h
index 037c46037..136091c53 100644
--- a/usrp/host/lib/legacy/db_boards.h
+++ b/usrp/host/lib/db_boards.h
@@ -23,8 +23,8 @@
#ifndef DB_BOARDS_H
#define DB_BOARDS_H
-#include <db_base.h>
-#include <usrp_basic.h>
+#include <usrp/db_base.h>
+#include <usrp/usrp_basic.h>
std::vector<db_base_sptr> instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side);
diff --git a/usrp/host/lib/legacy/db_dbs_rx.cc b/usrp/host/lib/db_dbs_rx.cc
index 6094f9134..99f66c785 100644
--- a/usrp/host/lib/legacy/db_dbs_rx.cc
+++ b/usrp/host/lib/db_dbs_rx.cc
@@ -18,7 +18,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_dbs_rx.h>
+#include <usrp/db_dbs_rx.h>
#include <db_base_impl.h>
#include <cmath>
#include <cstdio>
diff --git a/usrp/host/lib/legacy/db_dtt754.cc b/usrp/host/lib/db_dtt754.cc
index 4a6a1a29b..d78c5b328 100644
--- a/usrp/host/lib/legacy/db_dtt754.cc
+++ b/usrp/host/lib/db_dtt754.cc
@@ -19,7 +19,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_dtt754.h>
+#include <usrp/db_dtt754.h>
#include <db_base_impl.h>
int
diff --git a/usrp/host/lib/legacy/db_dtt768.cc b/usrp/host/lib/db_dtt768.cc
index cae8b7347..a520fdc60 100644
--- a/usrp/host/lib/legacy/db_dtt768.cc
+++ b/usrp/host/lib/db_dtt768.cc
@@ -19,7 +19,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_dtt768.h>
+#include <usrp/db_dtt768.h>
#include <db_base_impl.h>
int
diff --git a/usrp/host/lib/legacy/db_flexrf.cc b/usrp/host/lib/db_flexrf.cc
index 662d9095c..a8f4684b5 100644
--- a/usrp/host/lib/legacy/db_flexrf.cc
+++ b/usrp/host/lib/db_flexrf.cc
@@ -18,7 +18,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_flexrf.h>
+#include <usrp/db_flexrf.h>
#include <db_base_impl.h>
// d'board i/o pin defs
diff --git a/usrp/host/lib/legacy/db_flexrf_mimo.cc b/usrp/host/lib/db_flexrf_mimo.cc
index fd996bfa9..e2db5cd10 100644
--- a/usrp/host/lib/legacy/db_flexrf_mimo.cc
+++ b/usrp/host/lib/db_flexrf_mimo.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,10 +19,10 @@
* Boston, MA 02110-1301, USA.
*/
-#include <db_flexrf_mimo.h>
+#include <usrp/db_flexrf_mimo.h>
#include <fpga_regs_standard.h>
#include <fpga_regs_common.h>
-#include <usrp_prims.h>
+#include <usrp/usrp_prims.h>
#include <usrp_spi_defs.h>
diff --git a/usrp/host/lib/legacy/db_tv_rx.cc b/usrp/host/lib/db_tv_rx.cc
index 803ebf86d..494ee7a1a 100644
--- a/usrp/host/lib/legacy/db_tv_rx.cc
+++ b/usrp/host/lib/db_tv_rx.cc
@@ -18,7 +18,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_tv_rx.h>
+#include <usrp/db_tv_rx.h>
#include <db_base_impl.h>
/*****************************************************************************/
diff --git a/usrp/host/lib/legacy/db_util.cc b/usrp/host/lib/db_util.cc
index 4b46383bb..4b46383bb 100644
--- a/usrp/host/lib/legacy/db_util.cc
+++ b/usrp/host/lib/db_util.cc
diff --git a/usrp/host/lib/legacy/db_util.h b/usrp/host/lib/db_util.h
index e07abb608..e07abb608 100644
--- a/usrp/host/lib/legacy/db_util.h
+++ b/usrp/host/lib/db_util.h
diff --git a/usrp/host/lib/legacy/db_xcvr2450.cc b/usrp/host/lib/db_xcvr2450.cc
index 9ce3168e2..408a05587 100644
--- a/usrp/host/lib/legacy/db_xcvr2450.cc
+++ b/usrp/host/lib/db_xcvr2450.cc
@@ -18,7 +18,7 @@
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
-#include <db_xcvr2450.h>
+#include <usrp/db_xcvr2450.h>
#include <db_base_impl.h>
#include <cmath>
#include <boost/thread.hpp>
diff --git a/usrp/host/lib/legacy/dump_data.py b/usrp/host/lib/dump_data.py
index 034586d8a..034586d8a 100755
--- a/usrp/host/lib/legacy/dump_data.py
+++ b/usrp/host/lib/dump_data.py
diff --git a/usrp/host/lib/legacy/fusb.cc b/usrp/host/lib/fusb.cc
index 6e4358f5f..6e4358f5f 100644
--- a/usrp/host/lib/legacy/fusb.cc
+++ b/usrp/host/lib/fusb.cc
diff --git a/usrp/host/lib/legacy/fusb.h b/usrp/host/lib/fusb.h
index 769e51cca..769e51cca 100644
--- a/usrp/host/lib/legacy/fusb.h
+++ b/usrp/host/lib/fusb.h
diff --git a/usrp/host/lib/legacy/fusb_darwin.cc b/usrp/host/lib/fusb_darwin.cc
index 737387b87..737387b87 100644
--- a/usrp/host/lib/legacy/fusb_darwin.cc
+++ b/usrp/host/lib/fusb_darwin.cc
diff --git a/usrp/host/lib/legacy/fusb_darwin.h b/usrp/host/lib/fusb_darwin.h
index bb717b58c..bb717b58c 100644
--- a/usrp/host/lib/legacy/fusb_darwin.h
+++ b/usrp/host/lib/fusb_darwin.h
diff --git a/usrp/host/lib/legacy/fusb_generic.cc b/usrp/host/lib/fusb_generic.cc
index 0958716d9..0958716d9 100644
--- a/usrp/host/lib/legacy/fusb_generic.cc
+++ b/usrp/host/lib/fusb_generic.cc
diff --git a/usrp/host/lib/legacy/fusb_generic.h b/usrp/host/lib/fusb_generic.h
index b9aef2737..b9aef2737 100644
--- a/usrp/host/lib/legacy/fusb_generic.h
+++ b/usrp/host/lib/fusb_generic.h
diff --git a/usrp/host/lib/legacy/fusb_linux.cc b/usrp/host/lib/fusb_linux.cc
index 6c484569f..6c484569f 100644
--- a/usrp/host/lib/legacy/fusb_linux.cc
+++ b/usrp/host/lib/fusb_linux.cc
diff --git a/usrp/host/lib/legacy/fusb_linux.h b/usrp/host/lib/fusb_linux.h
index 107e1af70..107e1af70 100644
--- a/usrp/host/lib/legacy/fusb_linux.h
+++ b/usrp/host/lib/fusb_linux.h
diff --git a/usrp/host/lib/legacy/fusb_ra_wb.cc b/usrp/host/lib/fusb_ra_wb.cc
index 699a34b39..699a34b39 100644
--- a/usrp/host/lib/legacy/fusb_ra_wb.cc
+++ b/usrp/host/lib/fusb_ra_wb.cc
diff --git a/usrp/host/lib/legacy/fusb_ra_wb.h b/usrp/host/lib/fusb_ra_wb.h
index 233976abe..233976abe 100644
--- a/usrp/host/lib/legacy/fusb_ra_wb.h
+++ b/usrp/host/lib/fusb_ra_wb.h
diff --git a/usrp/host/lib/legacy/fusb_sysconfig_darwin.cc b/usrp/host/lib/fusb_sysconfig_darwin.cc
index 4d19d1292..4d19d1292 100644
--- a/usrp/host/lib/legacy/fusb_sysconfig_darwin.cc
+++ b/usrp/host/lib/fusb_sysconfig_darwin.cc
diff --git a/usrp/host/lib/legacy/fusb_sysconfig_generic.cc b/usrp/host/lib/fusb_sysconfig_generic.cc
index 58baba5a5..58baba5a5 100644
--- a/usrp/host/lib/legacy/fusb_sysconfig_generic.cc
+++ b/usrp/host/lib/fusb_sysconfig_generic.cc
diff --git a/usrp/host/lib/legacy/fusb_sysconfig_linux.cc b/usrp/host/lib/fusb_sysconfig_linux.cc
index 3c2f59375..3c2f59375 100644
--- a/usrp/host/lib/legacy/fusb_sysconfig_linux.cc
+++ b/usrp/host/lib/fusb_sysconfig_linux.cc
diff --git a/usrp/host/lib/legacy/fusb_sysconfig_ra_wb.cc b/usrp/host/lib/fusb_sysconfig_ra_wb.cc
index 9da831fd5..9da831fd5 100644
--- a/usrp/host/lib/legacy/fusb_sysconfig_ra_wb.cc
+++ b/usrp/host/lib/fusb_sysconfig_ra_wb.cc
diff --git a/usrp/host/lib/legacy/fusb_sysconfig_win32.cc b/usrp/host/lib/fusb_sysconfig_win32.cc
index 16eaaa645..16eaaa645 100644
--- a/usrp/host/lib/legacy/fusb_sysconfig_win32.cc
+++ b/usrp/host/lib/fusb_sysconfig_win32.cc
diff --git a/usrp/host/lib/legacy/fusb_win32.cc b/usrp/host/lib/fusb_win32.cc
index 8900576d9..8900576d9 100644
--- a/usrp/host/lib/legacy/fusb_win32.cc
+++ b/usrp/host/lib/fusb_win32.cc
diff --git a/usrp/host/lib/legacy/fusb_win32.h b/usrp/host/lib/fusb_win32.h
index 3ad2132f4..3ad2132f4 100644
--- a/usrp/host/lib/legacy/fusb_win32.h
+++ b/usrp/host/lib/fusb_win32.h
diff --git a/usrp/host/lib/legacy/gen_usrp_dbid.py b/usrp/host/lib/gen_usrp_dbid.py
index bbfdc7503..c7d3770c1 100755
--- a/usrp/host/lib/legacy/gen_usrp_dbid.py
+++ b/usrp/host/lib/gen_usrp_dbid.py
@@ -25,7 +25,7 @@ def gen_dbid_py(r):
f.write('%-16s = %s\n' % (x[1], x[2]))
def gen_dbid_h(r):
- f = open('usrp_dbid.h', 'w')
+ f = open('../include/usrp/usrp_dbid.h', 'w')
comment_char = '//'
write_header(f, comment_char)
f.write(comment_char); f.write('\n')
@@ -64,8 +64,8 @@ def gen_dbid_cc(r):
* Boston, MA 02110-1301, USA.
*/
-#include <usrp_prims.h>
-#include <usrp_dbid.h>
+#include <usrp/usrp_prims.h>
+#include <usrp/usrp_dbid.h>
#include <stdio.h>
#define NELEM(x) sizeof(x)/sizeof(x[0])
diff --git a/usrp/host/lib/inband/Makefile.am b/usrp/host/lib/inband/Makefile.am
deleted file mode 100644
index 650a25ff9..000000000
--- a/usrp/host/lib/inband/Makefile.am
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-AM_CPPFLAGS = \
- $(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \
- $(USRP_INCLUDES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \
- -I$(srcdir)/../../apps-inband $(WITH_INCLUDES)
-
-TESTS = test_inband
-
-EXTRA_DIST = \
- usrp_server.mbh \
- usrp_interface.mbh
-
-lib_LTLIBRARIES = \
- libusrp-inband.la \
- libusrp-inband-qa.la
-
-# ------------------------------------------------------------------------
-# Build the inband library
-
-BUILT_SOURCES = \
- usrp_server_mbh.cc \
- usrp_interface_mbh.cc
-
-usrp_server_mbh.cc : usrp_server.mbh
- $(COMPILE_MBH) $(srcdir)/usrp_server.mbh usrp_server_mbh.cc
-
-usrp_interface_mbh.cc : usrp_interface.mbh
- $(COMPILE_MBH) $(srcdir)/usrp_interface.mbh usrp_interface_mbh.cc
-
-libusrp_inband_la_SOURCES = \
- $(BUILT_SOURCES) \
- $(srcdir)/../../apps-inband/ui_sincos.c \
- usrp_inband_usb_packet.cc \
- usrp_rx.cc \
- usrp_rx_stub.cc \
- usrp_server.cc \
- usrp_tx.cc \
- usrp_tx_stub.cc \
- usrp_usb_interface.cc
-
-libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
-
-libusrp_inband_la_LIBADD = \
- $(MBLOCK_LA) \
- $(USRP_LA) \
- -lstdc++
-
-include_HEADERS = \
- usrp_inband_usb_packet.h \
- usrp_rx.h \
- usrp_rx_stub.h \
- usrp_server.h \
- usrp_tx.h \
- usrp_tx_stub.h \
- usrp_usb_interface.h
-
-noinst_HEADERS = \
- qa_inband.h \
- qa_inband_packet_prims.h \
- qa_inband_usrp_server.h \
- symbols_usrp_channel.h \
- symbols_usrp_interface_cs.h \
- symbols_usrp_low_level_cs.h \
- symbols_usrp_rx.h \
- symbols_usrp_rx_cs.h \
- symbols_usrp_server_cs.h \
- symbols_usrp_tx.h \
- symbols_usrp_tx_cs.h
-
-# ------------------------------------------------------------------------
-# Build the qa code in its own library
-
-libusrp_inband_qa_la_SOURCES = \
- qa_inband.cc \
- qa_inband_packet_prims.cc \
- qa_inband_usrp_server.cc
-
-# magic flags
-libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version
-
-libusrp_inband_qa_la_LIBADD = \
- libusrp-inband.la \
- $(PMT_LA) \
- $(CPPUNIT_LIBS) \
- -lstdc++
-
-# ------------------------------------------------------------------------
-
-noinst_PROGRAMS = \
- test_inband
-
-test_inband_SOURCES = test_inband.cc
-test_inband_LDADD = libusrp-inband-qa.la
diff --git a/usrp/host/lib/inband/dump_packets.py b/usrp/host/lib/inband/dump_packets.py
deleted file mode 100755
index 237362406..000000000
--- a/usrp/host/lib/inband/dump_packets.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2007 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-import sys
-import struct
-from optparse import OptionParser
-
-from usb_packet import *
-
-def dump_packet(raw_pkt, outfile, dump_payload):
- pkt = usb_packet(raw_pkt)
- outfile.write(pkt.decoded_flags())
- outfile.write(' chan= %2d len= %3d timestamp= 0x%08x rssi= % 2d tag= %2d\n' % (
- pkt.chan(), pkt.payload_len(), pkt.timestamp(), pkt.rssi(), pkt.tag()))
- if dump_payload:
- assert pkt.payload_len() % 4 == 0
- shorts = struct.unpack('<%dh' % (pkt.payload_len() // 2), pkt.payload())
- for i in range(0, len(shorts), 2):
- outfile.write(' %6d, %6d\n' % (shorts[i], shorts[i+1]))
-
-
-def dump_packets(infile, outfile, dump_payload):
- raw_pkt = infile.read(512)
- while raw_pkt:
- if len(raw_pkt) != 512:
- sys.stderr.write("File length is not a multiple of 512 bytes")
- raise SystemExit, 1
-
- dump_packet(raw_pkt, outfile, dump_payload)
- raw_pkt = infile.read(512)
-
-
-def main():
- parser = OptionParser()
- parser.add_option('-p', '--dump-payload', action='store_true', default=False,
- help='dump payload in decimal and hex')
-
- (options, files) = parser.parse_args()
- if len(files) == 0:
- dump_packets(sys.stdin, sys.stdout, options.dump_payload)
- else:
- for f in files:
- dump_packets(open(f, "r"), sys.stdout, options.dump_payload)
-
-
-if __name__ == '__main__':
- main()
diff --git a/usrp/host/lib/inband/gen_test_packets.py b/usrp/host/lib/inband/gen_test_packets.py
deleted file mode 100755
index 2ee646384..000000000
--- a/usrp/host/lib/inband/gen_test_packets.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-
-import random
-import struct
-from pprint import pprint
-from usb_packet import *
-
-MAX_PAYLOAD = 504
-TIME_NOW = 0xffffffff
-
-
-class sequence_generator(object):
- def __init__(self):
- self.i = 0
-
- def __call__(self):
- t = self.i
- self.i += 1
- return t
-
-def gen_shuffled_lengths():
- valid_lengths = range(0, MAX_PAYLOAD+1, 4) # [0, 4, 8, ... 504]
- random.shuffle(valid_lengths)
- return valid_lengths
-
-
-class packet_sequence_generator(object):
- def __init__(self, channel, lengths):
- self.next = sequence_generator()
- self.channel = channel
- self.lengths = lengths
-
- def __call__(self, output_file):
- gen_packet(output_file, self.channel, self.next, self.lengths[0])
- del self.lengths[0]
-
-
-def gen_packet(output_file, channel, content_generator, payload_len):
- assert (payload_len % 4) == 0
- payload = []
- n_iq = payload_len // 4
- for n in range(n_iq):
- payload.append(content_generator()) # I
- payload.append(content_generator()) # Q
- for n in range(MAX_PAYLOAD // 4 - n_iq):
- payload.append(0x0000)
- payload.append(0xffff)
-
- assert (len(payload) == MAX_PAYLOAD // 2)
-
- #print "\npayload_len =", payload_len
- #pprint(payload)
-
- output_file.write(make_header(FL_START_OF_BURST|FL_END_OF_BURST,
- channel, payload_len, TIME_NOW))
- output_file.write(struct.pack('<252h', *payload))
-
-
-def gen_all_valid_packet_lengths_1_channel(output_file):
- lengths = gen_shuffled_lengths()
- npkts = len(lengths) # number of packets we'll generator on each stream
- pkt_gen_0 = packet_sequence_generator(0, lengths)
- for i in range(npkts):
- pkt_gen_0(output_file)
-
- assert pkt_gen_0.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127
-
-
-def gen_all_valid_packet_lengths_2_channels(output_file):
- lengths = gen_shuffled_lengths()
- npkts = len(lengths) # number of packets we'll generator on each stream
- pkt_gen_0 = packet_sequence_generator(0, lengths)
- pkt_gen_1 = packet_sequence_generator(0x1f, gen_shuffled_lengths())
- pkt_gen = (pkt_gen_0, pkt_gen_1)
-
- which_gen = (npkts * [0]) + (npkts * [1])
- random.shuffle(which_gen)
-
- for i in which_gen:
- pkt_gen[i](output_file)
-
- assert pkt_gen_0.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127
- assert pkt_gen_1.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127
-
-if __name__ == '__main__':
- random.seed(0)
- gen_all_valid_packet_lengths_1_channel(open("all_valid_packet_lengths_1_channel.dat", "w"))
- gen_all_valid_packet_lengths_2_channels(open("all_valid_packet_lengths_2_channels.dat", "w"))
diff --git a/usrp/host/lib/inband/qa_inband.cc b/usrp/host/lib/inband/qa_inband.cc
deleted file mode 100644
index 6f33a6ead..000000000
--- a/usrp/host/lib/inband/qa_inband.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <qa_inband.h>
-#include <qa_inband_packet_prims.h>
-#include <qa_inband_usrp_server.h>
-
-CppUnit::TestSuite *
-qa_inband::suite()
-{
- CppUnit::TestSuite *s = new CppUnit::TestSuite("inband");
-
- s->addTest (qa_inband_packet_prims::suite());
- s->addTest (qa_inband_usrp_server::suite());
-
- return s;
-}
diff --git a/usrp/host/lib/inband/qa_inband.h b/usrp/host/lib/inband/qa_inband.h
deleted file mode 100644
index ab8f7f250..000000000
--- a/usrp/host/lib/inband/qa_inband.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_QA_INBAND_H
-#define INCLUDED_QA_INBAND_H
-
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the user server
-
-class qa_inband {
- public:
- //! return suite of tests for all of usrp server
- static CppUnit::TestSuite *suite();
-};
-
-#endif /* INCLUDED_QA_INBAND_H */
diff --git a/usrp/host/lib/inband/qa_inband_packet_prims.cc b/usrp/host/lib/inband/qa_inband_packet_prims.cc
deleted file mode 100644
index d9bbbec22..000000000
--- a/usrp/host/lib/inband/qa_inband_packet_prims.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qa_inband_packet_prims.h>
-#include <cppunit/TestAssert.h>
-#include <stdio.h>
-#include <string.h>
-#include <usrp_inband_usb_packet.h> // will change on gigabit crossover
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-void
-qa_inband_packet_prims::test_flags()
-{
- transport_pkt pkt;
-
- // Test each one of the flags while ensuring no other fields become set in the process
- pkt.set_header(pkt.FL_START_OF_BURST,0,0,0);
- CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- pkt.set_header(pkt.FL_END_OF_BURST,0,0,0);
- CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- pkt.set_header(pkt.FL_OVERRUN,0,0,0);
- CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- pkt.set_header(pkt.FL_UNDERRUN,0,0,0);
- CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- pkt.set_header(pkt.FL_DROPPED,0,0,0);
- CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- // test of all fields set
- pkt.set_header(
- pkt.FL_START_OF_BURST |
- pkt.FL_END_OF_BURST |
- pkt.FL_UNDERRUN |
- pkt.FL_OVERRUN |
- pkt.FL_DROPPED
- ,0,0,0);
- CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
-
-}
-//////////////////////////////////////////////////////////////////////
-
-void
-qa_inband_packet_prims::test_fields()
-{
- transport_pkt pkt;
- void * payload;
-
- // test word0 field exclusiveness
- //
- // I want to test max values of each field to ensure field boundaries
- // but these max values could change based on technology? The
- // max payload is returned by a private method so the code is not
- // technology dependent
- pkt.set_header(0,16,0,0);
- CPPUNIT_ASSERT_EQUAL(16, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
-
- pkt.set_header(0,0,8,0);
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(8, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0,pkt.payload_len());
-
- pkt.set_header(0,0,0,pkt.max_payload());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(pkt.max_payload(), pkt.payload_len());
-
- // test timestamp, shouldn't have to test other fields since
- // setting the timestamp only has the ability to affect one word
- pkt.set_timestamp(54);
- CPPUNIT_ASSERT_EQUAL(uint32_t(54), pkt.timestamp());
-
- // test the payload, ensure no other fields overwritten
- //
- // is there a better test for this?
- pkt.set_header(0,0,0,0);
- payload = malloc(pkt.payload_len());
- memset(payload, 'f', pkt.payload_len());
- memcpy(pkt.payload(), payload, pkt.payload_len());
- CPPUNIT_ASSERT_EQUAL(0, memcmp(pkt.payload(), payload, pkt.payload_len()));
- CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
- CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
- CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
- CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
- CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
- CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
- free(payload);
-
-}
-//////////////////////////////////////////////////////////////////////
diff --git a/usrp/host/lib/inband/qa_inband_packet_prims.h b/usrp/host/lib/inband/qa_inband_packet_prims.h
deleted file mode 100644
index 71c0d737d..000000000
--- a/usrp/host/lib/inband/qa_inband_packet_prims.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef QA_INBAND_PACKET_PRIMS_H
-#define QA_INBAND_PACKET_PRIMS_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_inband_packet_prims : public CppUnit::TestCase {
-
- CPPUNIT_TEST_SUITE(qa_inband_packet_prims);
- CPPUNIT_TEST(test_flags);
- CPPUNIT_TEST(test_fields);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- void test_flags();
- void test_fields();
-
-};
-
-#endif /* INCLUDED_QA_INBAND_PACKET_PRIMS_H */
diff --git a/usrp/host/lib/inband/qa_inband_usrp_server.cc b/usrp/host/lib/inband/qa_inband_usrp_server.cc
deleted file mode 100644
index 6049a8a87..000000000
--- a/usrp/host/lib/inband/qa_inband_usrp_server.cc
+++ /dev/null
@@ -1,1575 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_inband_usb_packet.h>
-#include <qa_inband_usrp_server.h>
-#include <cppunit/TestAssert.h>
-#include <stdio.h>
-#include <usrp_server.h>
-#include <mblock/mblock.h>
-#include <mblock/runtime.h>
-#include <mblock/protocol_class.h>
-#include <mblock/class_registry.h>
-#include <vector>
-#include <iostream>
-#include <pmt.h>
-
-#include <symbols_usrp_server_cs.h>
-#include <symbols_usrp_tx.h>
-#include <symbols_usrp_rx.h>
-#include <symbols_usrp_channel.h>
-#include <symbols_usrp_low_level_cs.h>
-
-typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy
-
-static bool verbose = false;
-
-static pmt_t s_timeout = pmt_intern("%timeout");
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_alloc_top : public mb_mblock
-{
- mb_port_sptr d_tx;
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_nmsgs_to_recv;
- long d_nrecvd;
-
- long d_max_capacity;
- long d_ntx_chan, d_nrx_chan;
-
- long d_nstatus;
- long d_nstatus_to_recv;
-
- public:
- qa_alloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_alloc_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_message(mb_message_sptr msg);
- void run_tests();
-};
-
-qa_alloc_top::qa_alloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
- d_nrecvd=0;
- d_nmsgs_to_recv = 6;
- d_nstatus=0;
- d_nstatus_to_recv = 50;
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-
-}
-
-qa_alloc_top::~qa_alloc_top(){}
-
-void
-qa_alloc_top::initial_transition()
-{
- // Allocations should fail before open
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,
- s_err_usrp_not_opened),
- pmt_from_long(1)));
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,
- s_err_usrp_not_opened),
- pmt_from_long(1)));
-
- // Retrieve information about the USRP, then run tests
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open, PMT_T),
- pmt_from_long(0)));
-
- d_cs->send(s_cmd_max_capacity,
- pmt_list1(pmt_list2(s_response_max_capacity, PMT_T)));
-
- d_cs->send(s_cmd_ntx_chan,
- pmt_list1(pmt_list2(s_response_ntx_chan, PMT_T)));
-
- d_cs->send(s_cmd_nrx_chan,
- pmt_list1(pmt_list2(s_response_nrx_chan,PMT_T)));
-}
-
-void
-qa_alloc_top::run_tests()
-{
- if(verbose)
- std::cout << "[qa_alloc_top] Starting tests...\n";
-
- // should be able to allocate 1 byte
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(PMT_T, pmt_from_long(1)));
-
- // should not be able to allocate max capacity after 100 bytes were allocated
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(s_err_requested_capacity_unavailable,
- pmt_from_long(d_max_capacity)));
-
- // keep allocating a little more until all of the channels are used and test
- // the error response we start at 1 since we've already allocated 1 channel
- for(int i=1; i < d_ntx_chan; i++) {
-
- if(verbose)
- std::cout << "[qa_alloc_top] Sent allocation request...\n";
-
- d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
-
- d_nmsgs_to_recv++;
- }
-
- // No more channels after allocating all of them is expected
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(s_err_channel_unavailable,
- pmt_from_long(1)));
-
- // test out the same on the RX side
- d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(s_err_requested_capacity_unavailable,
- pmt_from_long(d_max_capacity)));
-
- for(int i=1; i < d_nrx_chan; i++) {
-
- d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
-
- d_nmsgs_to_recv++;
- }
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(s_err_channel_unavailable,
- pmt_from_long(1)));
-
- // when all is said and done, there should be d_ntx_chan+d_ntx_chan bytes
- // allocated
- d_cs->send(s_cmd_current_capacity_allocation,
- pmt_list1(pmt_from_long(d_ntx_chan+d_nrx_chan)));
-}
-
-void
-qa_alloc_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
-
- if ((pmt_eq(msg->port_id(), d_tx->port_symbol())
- || pmt_eq(msg->port_id(), d_rx->port_symbol()))
- && pmt_eq(msg->signal(), s_response_allocate_channel))
- check_message(msg);
-
- if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_max_capacity)) {
- d_max_capacity = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_alloc_top] USRP has max capacity of "
- << d_max_capacity << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
- d_ntx_chan = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_alloc_top] USRP tx channels: "
- << d_ntx_chan << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
- d_nrx_chan = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_alloc_top] USRP rx channels: "
- << d_nrx_chan << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
- check_message(msg);
- }
-
- d_nstatus++;
-
- check_message(msg);
-
- if(d_nstatus==d_nstatus_to_recv)
- run_tests();
- }
-}
-
-void
-qa_alloc_top::check_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- d_nrecvd++;
-
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- if(verbose)
- std::cout << "Got: " << status << " Expected: " << e_status << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- if(verbose)
- std::cout << "[qa_alloc_top] Received expected response for message "
- << d_nrecvd << " (" << event << ")\n";
- }
-
- if(d_nrecvd == d_nmsgs_to_recv)
- shutdown_all(PMT_T);
-}
-
-REGISTER_MBLOCK_CLASS(qa_alloc_top);
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_dealloc_top : public mb_mblock
-{
- mb_port_sptr d_tx;
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_max_capacity;
- long d_ntx_chan, d_nrx_chan;
-
- long d_nstatus;
- long d_nstatus_to_recv;
-
- long d_nalloc_to_recv;
- long d_nalloc_recvd;
-
- long d_ndealloc_to_recv;
- long d_ndealloc_recvd;
-
- std::vector<long> d_tx_chans;
- std::vector<long> d_rx_chans;
-
- public:
- qa_dealloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_dealloc_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_allocation(mb_message_sptr msg);
- void check_deallocation(mb_message_sptr msg);
- void allocate_max();
- void deallocate_all();
-};
-
-qa_dealloc_top::qa_dealloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
- d_ndealloc_recvd=0;
- d_ndealloc_to_recv = 0;
- d_nalloc_recvd=0;
- d_nalloc_to_recv = 0; // auto-set
- d_nstatus=0;
- d_nstatus_to_recv = 4;
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-}
-
-qa_dealloc_top::~qa_dealloc_top(){}
-
-void
-qa_dealloc_top::initial_transition()
-{
-
- if(verbose)
- std::cout << "[qa_dealloc_top] Initializing...\n";
-
- // Retrieve information about the USRP, then run tests
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,PMT_T),
- pmt_from_long(0)));
-
- d_cs->send(s_cmd_max_capacity,
- pmt_list1(pmt_list2(s_response_max_capacity,PMT_T)));
-
- d_cs->send(s_cmd_ntx_chan,
- pmt_list1(pmt_list2(s_response_ntx_chan,PMT_T)));
-
- d_cs->send(s_cmd_nrx_chan,
- pmt_list1(pmt_list2(s_response_nrx_chan,PMT_T)));
-}
-
-void
-qa_dealloc_top::allocate_max()
-{
-
- // Keep allocating until we hit the maximum number of channels
- for(int i=0; i < d_ntx_chan; i++) {
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T),
- pmt_from_long(1))); // 1 byte is good enough
-
- d_nalloc_to_recv++;
- }
-
- for(int i=0; i < d_nrx_chan; i++) {
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T),
- pmt_from_long(1)));
-
- d_nalloc_to_recv++;
- }
-
-}
-
-void
-qa_dealloc_top::deallocate_all() {
-
- // Deallocate all of the channels that were allocated from allocate_max()
- for(int i=0; i < (int)d_tx_chans.size(); i++) {
-
- if(verbose)
- std::cout << "[qa_dealloc_top] Trying to dealloc TX "
- << d_tx_chans[i] << std::endl;
-
- d_tx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,PMT_T),
- pmt_from_long(d_tx_chans[i])));
-
- d_ndealloc_to_recv++;
- }
-
- // Deallocate the RX side now
- for(int i=0; i < (int)d_rx_chans.size(); i++) {
-
- if(verbose)
- std::cout << "[qa_dealloc_top] Trying to dealloc RX "
- << d_tx_chans[i] << std::endl;
-
- d_rx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,PMT_T),
- pmt_from_long(d_rx_chans[i])));
-
- d_ndealloc_to_recv++;
- }
-
- // Should get permission denied errors trying to re-dealloc the channels, as
- // we no longer have permission to them after deallocating
- for(int i=0; i < (int)d_tx_chans.size(); i++) {
-
- d_tx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,
- s_err_channel_permission_denied),
- pmt_from_long(d_tx_chans[i])));
-
- d_ndealloc_to_recv++;
- }
-
- // Same for RX
- for(int i=0; i < (int)d_rx_chans.size(); i++) {
-
- d_rx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,
- s_err_channel_permission_denied),
- pmt_from_long(d_rx_chans[i])));
-
- d_ndealloc_to_recv++;
- }
-
- // Try to deallocate a channel that doesn't exist on both sides, the last
- // element in the vectors is the highest channel number, so we take that plus
- // 1
- d_ndealloc_to_recv+=2;
- d_tx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,
- s_err_channel_invalid),
- pmt_from_long(d_rx_chans.back()+1)));
-
- d_rx->send(s_cmd_deallocate_channel,
- pmt_list2(pmt_list2(s_response_deallocate_channel,
- s_err_channel_invalid),
- pmt_from_long(d_rx_chans.back()+1)));
-
-
- // The used capacity should be back to 0 now that we've deallocated everything
- d_cs->send(s_cmd_current_capacity_allocation,
- pmt_list1(pmt_list2(s_response_current_capacity_allocation,
- PMT_T)));
-}
-
-void
-qa_dealloc_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- if(pmt_eq(event, pmt_intern("%shutdown")))
- return;
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- if(verbose)
- std::cout << "Got: " << status << " Expected: " << e_status << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- if(verbose)
- std::cout << "[qa_alloc_top] Received expected response for message "
- << d_ndealloc_recvd
- << " (" << event << ")\n";
- }
-
- if (pmt_eq(msg->port_id(), d_tx->port_symbol())
- || pmt_eq(msg->port_id(), d_rx->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_allocate_channel)) {
- check_allocation(msg);
- }
-
- }
-
- if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_max_capacity)) {
- d_max_capacity = pmt_to_long(pmt_nth(2, data));
- }
- else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
- d_ntx_chan = pmt_to_long(pmt_nth(2, data));
- }
- else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
- d_nrx_chan = pmt_to_long(pmt_nth(2, data));
- }
- else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
- // the final command is a capacity check which should be 0, then we
- // shutdown
- pmt_t expected_result = pmt_from_long(0);
- pmt_t result = pmt_nth(2, data);
-
- if(pmt_eqv(expected_result, result)) {
- shutdown_all(PMT_T);
- return;
- } else {
- shutdown_all(PMT_F);
- return;
- }
- }
-
- d_nstatus++;
-
- if(d_nstatus==d_nstatus_to_recv)
- allocate_max();
- }
-}
-
-
-void
-qa_dealloc_top::check_allocation(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t channel = pmt_nth(2, data);
-
- d_nalloc_recvd++;
-
- if(!pmt_eqv(status, PMT_T)) {
- shutdown_all(PMT_F);
- return;
- } else {
- // store all of the allocate channel numbers
- if(pmt_eq(msg->port_id(), d_tx->port_symbol()))
- d_tx_chans.push_back(pmt_to_long(channel));
- if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
- d_rx_chans.push_back(pmt_to_long(channel));
- }
-
- if(d_nalloc_recvd == d_nalloc_to_recv) {
-
- if(verbose) {
- std::cout << "[qa_dealloc_top] Allocated TX channels: ";
- for(int i=0; i < (int)d_tx_chans.size(); i++)
- std::cout << d_tx_chans[i] << " ";
-
- std::cout << "\n[qa_dealloc_top] Allocated RX channels: ";
- for(int i=0; i < (int)d_rx_chans.size(); i++)
- std::cout << d_rx_chans[i] << " ";
- std::cout << "\n";
- }
-
- deallocate_all(); // once we've allocated all of our channels, try to
- // dealloc them
- }
-}
-
-REGISTER_MBLOCK_CLASS(qa_dealloc_top);
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_open_close_top : public mb_mblock
-{
- mb_port_sptr d_cs;
-
- long d_max_capacity;
-
- long d_nmsg_to_recv;
- long d_nmsg_recvd;
-
- public:
- qa_open_close_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_open_close_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_cs(mb_message_sptr msg);
- void run_tests();
-};
-
-qa_open_close_top::qa_open_close_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
-
- d_nmsg_to_recv=7;
- d_nmsg_recvd=0;
-
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "cs", "server", "cs");
-}
-
-qa_open_close_top::~qa_open_close_top(){}
-
-void
-qa_open_close_top::initial_transition()
-{
- run_tests();
-}
-
-void
-qa_open_close_top::run_tests()
-{
- // std::cout << "[qa_open_close_top] Starting tests\n";
-
- // A close before an open should fail
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,
- s_err_usrp_already_closed)));
-
- // Perform an open, and a second open which should fail
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,PMT_T),
- pmt_from_long(0)));
-
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,
- s_err_usrp_already_opened),
- pmt_from_long(0)));
-
- // A close should now be successful since the interface is open
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
-
- // But, a second close should fail
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,
- s_err_usrp_already_closed)));
-
- // Just to be thorough, try an open and close again
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,PMT_T),
- pmt_from_long(0)));
-
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
-
-}
-
-
-void
-qa_open_close_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
-
- if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
- check_cs(msg);
- }
-
- d_nmsg_recvd++;
-
- if(d_nmsg_to_recv == d_nmsg_recvd)
- shutdown_all(PMT_T);
-}
-
-void
-qa_open_close_top::check_cs(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
-
- if(verbose)
- std::cout << "[qa_open_close_top] FAILED check_cs... Got: " << status
- << " Expected: " << e_status
- << " for event " << event << "\n";
-
- shutdown_all(PMT_F);
- } else {
- if(verbose)
- std::cout << "[qa_open_close_top] Received expected CS response ("
- << event << ")\n";
- }
-
-}
-
-REGISTER_MBLOCK_CLASS(qa_open_close_top);
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_tx_top : public mb_mblock
-{
- mb_port_sptr d_tx;
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_max_capacity;
- long d_ntx_chan, d_nrx_chan;
-
- long d_tx_chan;
- long d_rx_chan;
-
- long d_nmsg_to_recv;
- long d_nmsg_recvd;
-
- public:
- qa_tx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_tx_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_allocation(mb_message_sptr msg);
- void check_deallocation(mb_message_sptr msg);
- void check_xmit(mb_message_sptr msg);
- void check_cs(mb_message_sptr msg);
- void run_tests();
-};
-
-qa_tx_top::qa_tx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
-
- d_nmsg_to_recv=10;
- d_nmsg_recvd=0;
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-}
-
-qa_tx_top::~qa_tx_top(){}
-
-void
-qa_tx_top::initial_transition()
-{
- run_tests();
-}
-
-void
-qa_tx_top::run_tests()
-{
- if(verbose)
- std::cout << "[qa_tx_top] Starting tests\n";
-
- // A transmit before an open should fail
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame,
- s_err_usrp_not_opened),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- // Now open
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,PMT_T),
- pmt_from_long(0)));
-
- // Try to transmit on a channel that we have no allocation for
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame,
- s_err_channel_permission_denied),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- // Get a channel allocation and send on it, we assume 0 (FIXME) until 'defer'
- // is implemented for simplicity
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame, PMT_T),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- // Close should be successful
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
-
- // After closing, a new transmit raw frame should fail again
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame,
- s_err_usrp_not_opened),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- // Reopen and retry before getting an allocation, the first xmit should fail,
- // after we allocate it should work again
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open, PMT_T),
- pmt_from_long(0)));
-
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame,
- s_err_channel_permission_denied),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame,PMT_T),
- pmt_from_long(0),
- pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
- pmt_from_long(0)));
-
- // A final close which should be successful
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
-
-}
-
-
-void
-qa_tx_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- if(pmt_eq(event, pmt_intern("%shutdown")))
- return;
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- if(verbose)
- std::cout << "[qa_xmit_top] Got: " << status
- << " Expected: " << e_status
- << "For signal: " << event << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- if(verbose)
- std::cout << "[qa_xmit_top] Received expected response for message "
- << d_nmsg_recvd
- << " (" << event << ")\n";
- }
-
- if (pmt_eq(msg->port_id(), d_tx->port_symbol())
- || pmt_eq(msg->port_id(), d_rx->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_allocate_channel))
- check_allocation(msg);
-
- }
-
- d_nmsg_recvd++;
-
- if(d_nmsg_to_recv == d_nmsg_recvd){
- shutdown_all(PMT_T);
- return;
- }
-}
-
-void
-qa_tx_top::check_allocation(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t channel = pmt_nth(2, data);
-
- if(pmt_eqv(status, PMT_T)) {
- // store all of the allocate channel numbers
- if(pmt_eq(msg->port_id(), d_tx->port_symbol()))
- d_tx_chan = pmt_to_long(channel);
- if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
- d_rx_chan = pmt_to_long(channel);
- }
-}
-
-REGISTER_MBLOCK_CLASS(qa_tx_top);
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_rx_top : public mb_mblock
-{
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_max_capacity;
- long d_ntx_chan, d_nrx_chan;
-
- long d_rx_chan;
-
- bool d_got_response_recv;
-
- mb_time d_t0;
- double d_delta_t;
-
- public:
- qa_rx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_rx_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_allocation(mb_message_sptr msg);
- void check_deallocation(mb_message_sptr msg);
- void check_xmit(mb_message_sptr msg);
- void check_cs(mb_message_sptr msg);
- void run_tests();
-};
-
-qa_rx_top::qa_rx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg),
- d_got_response_recv(false)
-{
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_dict = pmt_make_dict();
- // Set TX and RX interpolations
- pmt_dict_set(usrp_dict,
- pmt_intern("decim-rx"),
- pmt_from_long(128));
- pmt_dict_set(usrp_dict, pmt_intern("fake-usrp"), PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_dict);
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-}
-
-qa_rx_top::~qa_rx_top(){}
-
-void
-qa_rx_top::initial_transition()
-{
- run_tests();
-}
-
-void
-qa_rx_top::run_tests()
-{
- if(verbose)
- std::cout << "[qa_rx_top] Starting tests\n";
-
- d_cs->send(s_cmd_open, pmt_list2(pmt_list2(s_response_open,PMT_T), pmt_from_long(0)));
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T),
- pmt_from_long(1)));
-
- d_rx->send(s_cmd_start_recv_raw_samples,
- pmt_list2(PMT_NIL,
- pmt_from_long(0)));
-
- // Schedule a small timeout in which we expect to have received at least one
- // packet worth of samples from the stub
- d_t0 = mb_time::time();
- schedule_one_shot_timeout(d_t0 + 0.01, PMT_NIL);
-}
-
-
-void
-qa_rx_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- if(pmt_eq(event, pmt_intern("%shutdown")))
- return;
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- // If we get a timeout we shutdown
- if(pmt_eq(event, s_timeout)) {
- if(verbose)
- std::cout << "[qa_rx_top] Got timeout\n";
- d_rx->send(s_cmd_stop_recv_raw_samples,
- pmt_list2(PMT_NIL,
- pmt_from_long(0)));
-
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
- return;
- }
-
- // For testing RX, an invocation handle is not generated by the stub,
- // therefore the same approach for testing is not used. We simply
- // expect all responses to be true.
- if(pmt_eq(event, s_response_recv_raw_samples)) {
- if(pmt_eqv(status, PMT_T)) {
-
- if(verbose)
- std::cout << "[qa_rx_top] Received expected response for message "
- << " (" << event << ")\n";
-
- // All we want is 1 response receive! Can't guarantee exact numbers
- d_got_response_recv = true;
- }
- else {
- if(verbose)
- std::cout << "Got: " << status << " Expected: " << PMT_T << "\n";
- shutdown_all(PMT_F);
- }
- return;
- }
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- if(verbose)
- std::cout << "Got: " << status << " Expected: " << e_status << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- if(verbose)
- std::cout << "[qa_rx_top] Received expected response for message "
- << " (" << event << ")\n";
- }
-
- if (pmt_eq(msg->port_id(), d_rx->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_allocate_channel))
- check_allocation(msg);
-
- }
-
- // We stop when we get a close, we are successful if we
- // got a response from recv, fail if we never got a recv response
- if(pmt_eq(msg->signal(), s_response_close)) {
-
- if(d_got_response_recv) {
- shutdown_all(PMT_T);
- return;
- }
- else {
- shutdown_all(PMT_F);
- if(verbose)
- std::cout << "[qa_rx_top] No response message before close\n";
- return;
- }
- }
-}
-
-
-void
-qa_rx_top::check_allocation(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t channel = pmt_nth(2, data);
-
- if(pmt_eqv(status, PMT_T)) {
- // store all of the allocate channel numbers
- if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
- d_rx_chan = pmt_to_long(channel);
- }
-}
-
-REGISTER_MBLOCK_CLASS(qa_rx_top);
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_rid_top : public mb_mblock
-{
- mb_port_sptr d_tx;
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_npongs;
- long d_tcycles;
- long d_cycles;
- long d_max_rid;
-
- mb_time d_t0;
- double d_delta_t;
-
- public:
- qa_rid_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_rid_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void run_tests();
- void send_max_pings();
-};
-
-qa_rid_top::qa_rid_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
- d_npongs = 0;
- d_tcycles = 3;
- d_cycles = d_tcycles;
- d_max_rid = usrp_server::D_MAX_RID;
- d_delta_t = 0.1;
-
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-
-}
-
-qa_rid_top::~qa_rid_top(){}
-
-void
-qa_rid_top::initial_transition()
-{
- run_tests();
-}
-
-void
-qa_rid_top::run_tests()
-{
- if(verbose)
- std::cout << "[qa_rid_top] Starting tests...\n";
-
- // Retrieve information about the USRP, then run tests
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open, PMT_T),
- pmt_from_long(0)));
-
- // should be able to allocate 1 byte
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- // Need to start receiving to read from the USRP to get C/S responses
- d_rx->send(s_cmd_start_recv_raw_samples,
- pmt_list2(PMT_NIL,
- pmt_from_long(0)));
-
- // Build a subpacket of MAX_RID pings and wait a small amount for all of the
- // responses and fire off another MAX_RID. If MAX_RID*2 responses are
- // received, the RID recycling is working correctly.
- // Schedule a timer in which we expect to have received all of the responses,
- // which will send off another MAX_RID worth.
- send_max_pings();
- d_t0 = mb_time::time();
- schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL);
-}
-
-void
-qa_rid_top::send_max_pings()
-{
- pmt_t ping = pmt_list2(s_op_ping_fixed,
- pmt_list2(pmt_from_long(0),
- pmt_from_long(0)));
-
- pmt_t sub_packets = PMT_NIL;
-
- for(int i=0; i<d_max_rid; i++)
- sub_packets = pmt_list_add(sub_packets, ping);
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- sub_packets));
-}
-
-void
-qa_rid_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- // If we get a timeout we ensure we got a maximum RID number of responses.
- if(pmt_eq(event, s_timeout)) {
- if(verbose)
- std::cout << "[qa_rid_top] Got timeout, received so far: "
- << d_npongs << "\n";
-
- d_cycles--;
-
- if(d_cycles==0 && d_npongs == d_max_rid*d_tcycles) {
- shutdown_all(PMT_T);
- }
- else if(d_cycles==0) {
-
- std::cout << "[qa_rid_top] d_npongs: " << d_npongs
- << " expected: " << d_max_rid*d_tcycles
- << std::endl;
-
- shutdown_all(PMT_F);
- }
- else {
- send_max_pings();
- d_t0 = mb_time::time();
- schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL);
- }
-
- }
- else if(pmt_eq(event, s_response_from_control_channel))
- {
- d_npongs++;
- }
-
-}
-
-REGISTER_MBLOCK_CLASS(qa_rid_top);
-
-
-// ----------------------------------------------------------------------------------------------
-
-class qa_cs_top : public mb_mblock
-{
- mb_port_sptr d_tx;
- mb_port_sptr d_rx;
- mb_port_sptr d_cs;
-
- long d_nmsgs_to_recv;
- long d_nrecvd;
-
- long d_max_capacity;
- long d_ntx_chan, d_nrx_chan;
-
- long d_nstatus;
- long d_nstatus_to_recv;
-
- public:
- qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg);
- ~qa_cs_top();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- protected:
- void check_message(mb_message_sptr msg);
- void run_tests();
-};
-
-qa_cs_top::qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
-{
- d_nrecvd=0;
- d_nmsgs_to_recv = 8;
- d_nstatus=0;
- d_nstatus_to_recv = 50;
-
- d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
- d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
-
- // Use the stub with the usrp_server
- pmt_t usrp_server_dict = pmt_make_dict();
- pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
-
- // Test the TX side
- define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
- connect("self", "rx0", "server", "rx0");
- connect("self", "cs", "server", "cs");
-
-}
-
-qa_cs_top::~qa_cs_top(){}
-
-void
-qa_cs_top::initial_transition()
-{
- run_tests();
-}
-
-void
-qa_cs_top::run_tests()
-{
- if(verbose)
- std::cout << "[qa_cs_top] Starting tests...\n";
-
- // Retrieve information about the USRP, then run tests
- d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open, PMT_T),
- pmt_from_long(0)));
-
- // should be able to allocate 1 byte
- d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T),
- pmt_from_long(1)));
-
- // Need to start receiving to read from the USRP to get C/S responses
- d_rx->send(s_cmd_start_recv_raw_samples,
- pmt_list2(PMT_NIL,
- pmt_from_long(0)));
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- pmt_list1(
- pmt_list2(s_op_ping_fixed,
- pmt_list2(pmt_from_long(3),
- pmt_from_long(0))))));
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- pmt_list1(
- pmt_list2(s_op_write_reg,
- pmt_list2(
- pmt_from_long(0x3),
- pmt_from_long(0x4))))));
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- pmt_list1(
- pmt_list2(s_op_write_reg_masked,
- pmt_list3(
- pmt_from_long(0x3),
- pmt_from_long(0x4),
- pmt_from_long(0x5))))));
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- pmt_list1(
- pmt_list2(s_op_read_reg,
- pmt_list2(pmt_from_long(0),
- pmt_from_long(0x6))))));
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- pmt_list1(
- pmt_list2(s_op_delay,
- pmt_list1(pmt_from_long(0x7))))));
-
- pmt_t subpackets = pmt_list5(
- pmt_list2(s_op_ping_fixed, pmt_list2(pmt_from_long(0), pmt_from_long(0))),
- pmt_list2(s_op_delay, pmt_list1(pmt_from_long(0x7))),
- pmt_list2(s_op_write_reg_masked, pmt_list3(pmt_from_long(3),
- pmt_from_long(4),
- pmt_from_long(5))),
- pmt_list2(s_op_write_reg, pmt_list2(pmt_from_long(3),
- pmt_from_long(4))),
- pmt_list2(s_op_read_reg, pmt_list2(pmt_from_long(0),
- pmt_from_long(6)))
- );
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- subpackets));
-
- pmt_t i2c_data = pmt_make_u8vector(8, 0xff);
-
- subpackets = pmt_list2(
- pmt_list2(s_op_i2c_write,
- pmt_list2(pmt_from_long(8), i2c_data)),
- pmt_list2(s_op_i2c_read,
- pmt_list3(pmt_from_long(0), pmt_from_long(9), pmt_from_long(1)))
-
- );
-
- d_tx->send(s_cmd_to_control_channel,
- pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T),
- subpackets));
-
-}
-
-void
-qa_cs_top::handle_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
-
- if ((pmt_eq(msg->port_id(), d_tx->port_symbol())
- || pmt_eq(msg->port_id(), d_rx->port_symbol()))
- && pmt_eq(msg->signal(), s_response_allocate_channel))
- check_message(msg);
-
- if (pmt_eq(msg->port_id(), d_tx->port_symbol())
- && pmt_eq(msg->signal(), s_response_from_control_channel))
- check_message(msg);
-
- if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_max_capacity)) {
- d_max_capacity = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_cs_top] USRP has max capacity of "
- << d_max_capacity << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
- d_ntx_chan = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_cs_top] USRP tx channels: "
- << d_ntx_chan << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
- d_nrx_chan = pmt_to_long(pmt_nth(2, data));
- if(verbose)
- std::cout << "[qa_cs_top] USRP rx channels: "
- << d_nrx_chan << "\n";
- }
- else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
- check_message(msg);
- }
-
- d_nstatus++;
-
- check_message(msg);
-
- if(d_nstatus==d_nstatus_to_recv)
- run_tests();
- }
-}
-
-void
-qa_cs_top::check_message(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- d_nrecvd++;
-
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- if(verbose)
- std::cout << "[qa_cs_top] Got: " << status << " Expected: " << e_status << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- if(verbose)
- std::cout << "[qa_cs_top] Received expected response for message "
- << d_nrecvd << " (" << event << ")\n";
- }
-
- if(d_nrecvd == d_nmsgs_to_recv)
- shutdown_all(PMT_T);
-}
-
-REGISTER_MBLOCK_CLASS(qa_cs_top);
-
-// ----------------------------------------------------------------------------------------------
-
-void
-qa_inband_usrp_server::test_open_close()
-{
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n----------------------------\n";
- // std::cout << " RUNNING OPEN/CLOSE TESTS \n";
-
- rt->run("top", "qa_open_close_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_chan_allocation()
-{
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n----------------------------\n";
- // std::cout << " RUNNING ALLOCATION TESTS \n";
-
- rt->run("qa_alloc_top", "qa_alloc_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_chan_deallocation()
-{
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n----------------------------\n";
- // std::cout << " RUNNING DEALLOCATION TESTS \n";
-
- rt->run("qa_dealloc_top", "qa_dealloc_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_tx()
-{
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n-----------------\n";
- // std::cout << " RUNNING TX TESTS \n";
-
- rt->run("top", "qa_tx_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_rx()
-{
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n-----------------\n";
- // std::cout << " RUNNING RX TESTS \n";
-
- rt->run("top", "qa_rx_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_cs()
-{
- // FIXME This test is disabled because it hangs with the change to use usrp_standard_*_sptr's
- return;
-
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n-----------------\n";
- // std::cout << " RUNNING CS TESTS \n";
-
- rt->run("top", "qa_cs_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
-
-void
-qa_inband_usrp_server::test_rid()
-{
- // FIXME This test is disabled because it hangs with the change to use usrp_standard_*_sptr's
- return;
-
- mb_runtime_sptr rt = mb_make_runtime();
- pmt_t result = PMT_T;
-
- // std::cout << "\n\n-----------------\n";
- // std::cout << " RUNNING RID TESTS \n";
-
- rt->run("top", "qa_rid_top", PMT_F, &result);
-
- CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
-}
diff --git a/usrp/host/lib/inband/qa_inband_usrp_server.h b/usrp/host/lib/inband/qa_inband_usrp_server.h
deleted file mode 100644
index 52a4a0b06..000000000
--- a/usrp/host/lib/inband/qa_inband_usrp_server.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef QA_INBAND_USRP_SERVER_H
-#define QA_INBAND_USRP_SERVER_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_inband_usrp_server : public CppUnit::TestCase {
-
- CPPUNIT_TEST_SUITE(qa_inband_usrp_server);
- CPPUNIT_TEST(test_open_close);
- CPPUNIT_TEST(test_chan_allocation);
- CPPUNIT_TEST(test_chan_deallocation);
- CPPUNIT_TEST(test_tx);
- CPPUNIT_TEST(test_rx);
- CPPUNIT_TEST(test_cs);
- CPPUNIT_TEST(test_rid);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- void test_chan_allocation();
- void test_chan_deallocation();
- void test_open_close();
- void test_tx();
- void test_rx();
- void test_cs();
- void test_rid();
-};
-
-#endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_channel.h b/usrp/host/lib/inband/symbols_usrp_channel.h
deleted file mode 100644
index a0114cf3c..000000000
--- a/usrp/host/lib/inband/symbols_usrp_channel.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_CHANNEL_H
-#define INCLUDED_SYMBOLS_USRP_CHANNEL_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
-static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
-
-// Incoming
-static pmt_t s_response_allocate_channel = pmt_intern("response-allocate-channel");
-static pmt_t s_response_deallocate_channel = pmt_intern("response-deallocate-channel");
-
-// Errors
-static pmt_t s_err_requested_capacity_unavailable = pmt_intern("err-requested-capacity-unavailable");
-static pmt_t s_err_channel_unavailable = pmt_intern("err-channel-unavailable");
-static pmt_t s_err_channel_invalid = pmt_intern("err-channel-invalid");
-static pmt_t s_err_channel_permission_denied = pmt_intern("err-channel-permission-denied");
-
-#endif /* INCLUDED_SYMBOLS_USRP_CHANNEL_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_interface_cs.h b/usrp/host/lib/inband/symbols_usrp_interface_cs.h
deleted file mode 100644
index 72c8fcc91..000000000
--- a/usrp/host/lib/inband/symbols_usrp_interface_cs.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H
-#define INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
-static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close");
-static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan");
-static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan");
-static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write");
-static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading");
-static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading");
-
-// Incoming
-static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open");
-static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close");
-static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan");
-static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan");
-static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write");
-static pmt_t s_response_usrp_read = pmt_intern("response-usrp-read");
-
-#endif /* INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_low_level_cs.h b/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
deleted file mode 100644
index a7260603a..000000000
--- a/usrp/host/lib/inband/symbols_usrp_low_level_cs.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H
-#define INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
-
-// Incoming
-static pmt_t s_response_from_control_channel = pmt_intern("response-from-control-channel");
-
-// Subpackets
-static pmt_t s_op_ping_fixed = pmt_intern("op-ping-fixed");
-static pmt_t s_op_ping_fixed_reply = pmt_intern("op-ping-fixed-reply");
-static pmt_t s_op_write_reg = pmt_intern("op-write-reg");
-static pmt_t s_op_write_reg_masked = pmt_intern("op-write-reg-masked");
-static pmt_t s_op_read_reg = pmt_intern("op-read-reg");
-static pmt_t s_op_read_reg_reply = pmt_intern("op-read-reg-reply");
-static pmt_t s_op_i2c_write = pmt_intern("op-i2c-write");
-static pmt_t s_op_i2c_read = pmt_intern("op-i2c-read");
-static pmt_t s_op_i2c_read_reply = pmt_intern("op-i2c-read-reply");
-static pmt_t s_op_spi_write = pmt_intern("op-spi-write");
-static pmt_t s_op_spi_read = pmt_intern("op-spi-read");
-static pmt_t s_op_spi_read_reply = pmt_intern("op-spi-read-reply");
-static pmt_t s_op_delay = pmt_intern("op-delay");
-
-#endif /* INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_rx.h b/usrp/host/lib/inband/symbols_usrp_rx.h
deleted file mode 100644
index 07d58a3f5..000000000
--- a/usrp/host/lib/inband/symbols_usrp_rx.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_RX_H
-#define INCLUDED_SYMBOLS_USRP_RX_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_start_recv_raw_samples = pmt_intern("cmd-start-recv-raw-samples");
-static pmt_t s_cmd_stop_recv_raw_samples = pmt_intern("cmd-stop-recv-raw-samples");
-
-// Incoming
-static pmt_t s_response_recv_raw_samples = pmt_intern("response-recv-raw-samples");
-
-// Errors
-static pmt_t s_err_already_receiving = pmt_intern("err-already-receiving");
-
-#endif /* INCLUDED_SYMBOLS_USRP_RX_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_rx_cs.h b/usrp/host/lib/inband/symbols_usrp_rx_cs.h
deleted file mode 100644
index bf4f0338b..000000000
--- a/usrp/host/lib/inband/symbols_usrp_rx_cs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_RX_CS_H
-#define INCLUDED_SYMBOLS_USRP_RX_CS_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_usrp_rx_start_reading = pmt_intern("cmd-usrp-rx-start-reading");
-
-// Incoming
-static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
-
-#endif /* INCLUDED_SYMBOLS_USRP_RX_CS_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_server_cs.h b/usrp/host/lib/inband/symbols_usrp_server_cs.h
deleted file mode 100644
index e612e24ea..000000000
--- a/usrp/host/lib/inband/symbols_usrp_server_cs.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_SERVER_CS_H
-#define INCLUDED_SYMBOLS_USRP_SERVER_CS_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_open = pmt_intern("cmd-open");
-static pmt_t s_cmd_close = pmt_intern("cmd-close");
-static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity");
-static pmt_t s_cmd_ntx_chan = pmt_intern("cmd-ntx-chan");
-static pmt_t s_cmd_nrx_chan = pmt_intern("cmd-nrx-chan");
-static pmt_t s_cmd_current_capacity_allocation = pmt_intern("cmd-current-capacity-allocation");
-
-// Incoming
-static pmt_t s_response_open = pmt_intern("response-open");
-static pmt_t s_response_close = pmt_intern("response-close");
-static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
-static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
-static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
-static pmt_t s_response_current_capacity_allocation = pmt_intern("response-current-capacity-allocation");
-
-// Errors
-static pmt_t s_err_usrp_not_opened = pmt_intern("err-usrp-not-opened");
-static pmt_t s_err_usrp_already_opened = pmt_intern("err-usrp-already-opened");
-static pmt_t s_err_usrp_already_closed = pmt_intern("err-usrp-already-closed");
-
-#endif /* INCLUDED_SYMBOLS_USRP_SERVER_CS_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_tx.h b/usrp/host/lib/inband/symbols_usrp_tx.h
deleted file mode 100644
index 4e58e2cf9..000000000
--- a/usrp/host/lib/inband/symbols_usrp_tx.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_TX_H
-#define INCLUDED_SYMBOLS_USRP_TX_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_xmit_raw_frame = pmt_intern("cmd-xmit-raw-frame");
-
-// Incoming
-static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
-
-#endif /* INCLUDED_SYMBOLS_USRP_TX_H */
diff --git a/usrp/host/lib/inband/symbols_usrp_tx_cs.h b/usrp/host/lib/inband/symbols_usrp_tx_cs.h
deleted file mode 100644
index d02ef1d26..000000000
--- a/usrp/host/lib/inband/symbols_usrp_tx_cs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SYMBOLS_USRP_TX_CS_H
-#define INCLUDED_SYMBOLS_USRP_TX_CS_H
-
-#include <pmt.h>
-
-// Outgoing
-static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write");
-
-// Incoming
-static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write");
-
-#endif /* INCLUDED_SYMBOLS_USRP_TX_CS_H */
diff --git a/usrp/host/lib/inband/test_inband.cc b/usrp/host/lib/inband/test_inband.cc
deleted file mode 100644
index 77cdca556..000000000
--- a/usrp/host/lib/inband/test_inband.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <cppunit/TextTestRunner.h>
-#include <qa_inband.h>
-
-int
-main(int argc, char **argv)
-{
-
- CppUnit::TextTestRunner runner;
-
- runner.addTest(qa_inband::suite ());
-
- bool was_successful = runner.run("", false);
-
- return was_successful ? 0 : 1;
-}
diff --git a/usrp/host/lib/inband/usb_packet.py b/usrp/host/lib/inband/usb_packet.py
deleted file mode 100644
index 6dfcf8638..000000000
--- a/usrp/host/lib/inband/usb_packet.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# Copyright 2007 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-import struct
-
-
-FL_OVERRUN = 0x80000000
-FL_UNDERRUN = 0x40000000
-FL_DROPPED = 0x20000000
-FL_END_OF_BURST = 0x10000000
-FL_START_OF_BURST = 0x08000000
-
-FL_ALL_FLAGS = 0xf8000000
-
-FL_OVERRUN_SHIFT = 31
-FL_UNDERRUN_SHIFT = 30
-FL_DROPPED_SHIFT = 29
-FL_END_OF_BURST_SHIFT = 28
-FL_START_OF_BURST_SHIFT = 27
-
-RSSI_MASK = 0x3f
-RSSI_SHIFT = 21
-
-CHAN_MASK = 0x1f
-CHAN_SHIFT = 16
-
-TAG_MASK = 0xf
-TAG_SHIFT = 9
-
-PAYLOAD_LEN_MASK = 0x1ff
-PAYLOAD_LEN_SHIFT = 0
-
-def make_header(flags, chan, payload_len, timestamp, rssi=0, tag=0):
- word0 = ((flags & FL_ALL_FLAGS)
- | ((rssi & RSSI_MASK) << RSSI_SHIFT)
- | ((chan & CHAN_MASK) << CHAN_SHIFT)
- | ((tag & TAG_MASK) << TAG_SHIFT)
- | ((payload_len & PAYLOAD_LEN_MASK) << PAYLOAD_LEN_SHIFT))
- word1 = timestamp
- return struct.pack('<2I', word0, word1)
-
-
-def _decode(pred, indicator):
- if pred:
- return indicator
- else:
- return '-'
-
-
-class usb_packet(object):
- def __init__(self, raw_pkt):
- assert isinstance(raw_pkt, str) and len(raw_pkt) == 512
- self._raw_pkt = raw_pkt;
- (self._word0, self._word1) = struct.unpack('<2I', self._raw_pkt[0:8])
-
- def timestamp(self):
- return self._word1
-
- def rssi(self):
- return (self._word0 >> RSSI_SHIFT) & RSSI_MASK
-
- def chan(self):
- return (self._word0 >> CHAN_SHIFT) & CHAN_MASK
-
- def tag(self):
- return (self._word0 >> TAG_SHIFT) & TAG_MASK
-
- def payload_len(self):
- return (self._word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK
-
- def flags(self):
- return self._word0 & FL_ALL_FLAGS
-
- def overrun(self):
- return (self._word0 >> FL_OVERRUN_SHIFT) & 0x1
-
- def underrun(self):
- return (self._word0 >> FL_UNDERRUN_SHIFT) & 0x1
-
- def start_of_burst(self):
- return (self._word0 >> FL_START_OF_BURST_SHIFT) & 0x1
-
- def end_of_burst(self):
- return (self._word0 >> FL_END_OF_BURST_SHIFT) & 0x1
-
- def dropped(self):
- return (self._word0 >> FL_DROPPED_SHIFT) & 0x1
-
- def payload(self):
- return self._raw_pkt[8:8+self.payload_len()]
-
- def decoded_flags(self):
- s = (_decode(self.overrun(), 'O')
- + _decode(self.underrun(), 'U')
- + _decode(self.dropped(), 'D')
- + _decode(self.end_of_burst(), 'E')
- + _decode(self.start_of_burst(), 'S'))
- return s
diff --git a/usrp/host/lib/inband/usrp_inband_usb_packet.cc b/usrp/host/lib/inband/usrp_inband_usb_packet.cc
deleted file mode 100644
index 72bc45ccb..000000000
--- a/usrp/host/lib/inband/usrp_inband_usb_packet.cc
+++ /dev/null
@@ -1,793 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_inband_usb_packet.h>
-
-#include <usrp_bytesex.h>
-#include <iostream>
-#include <stdio.h>
-#include <string.h>
-
-/*!
- * \brief Aligns the packet payload on a 32 bit boundary. This is essential to
- * all control/status packets so that the inband FPGA code can parse them
- * easily.
- *
- * \returns true if successful or if the packet was already aligned; false if it
- * cannot be aligned.
- */
-bool usrp_inband_usb_packet::align32()
-{
- int p_len = payload_len();
-
- int bytes_needed = 4 - (p_len % 4);
-
- if(bytes_needed == 4)
- return true;
-
- // If the room left in the packet is less than the number of bytes
- // needed, return false to indicate no room to align
- if((MAX_PAYLOAD - p_len) < bytes_needed)
- return false;
-
- incr_header_len(bytes_needed);
-
- return true;
-}
-
-/*!
- * \brief Adds a ping command to the current control packet.
- *
- * The \p rid is the rid to be associated with the ping response and \p ping_val
- * is currently unused.
- *
- * \returns true if adding the ping command was successful, false otherwise
- * (i.e. no space in the current packet).
- */
-bool usrp_inband_usb_packet::cs_ping(long rid, long ping_val)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t ping = (
- ((OP_PING_FIXED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | (ping_val & CS_PINGVAL_MASK)
-
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(ping);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_PING_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a ping response to the packet. This is used by the fake USRP
- * code to generate fake responses for pings.
- *
- * The \p rid is the RID to be associated with the response and \p ping_val is
- * currently unused.
- *
- * \returns true if the ping reply was added successfully, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_ping_reply(long rid, long ping_val)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t ping = (
- ((OP_PING_FIXED_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | ((ping_val & CS_PINGVAL_MASK) << CS_PINGVAL_SHIFT)
-
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(ping);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_PING_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a write register command to the packet.
- *
- * The \p reg_num is the register number for which the value \p val will be
- * written to.
- *
- * \returns true if the command was added to the packet successfully, false
- * otherwise.
- */
-bool usrp_inband_usb_packet::cs_write_reg(long reg_num, long val)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_WRITEREG_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = 0;
-
- // Build the first word which includes the register number
- word0 = (
- ((OP_WRITE_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_WRITEREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // The second word is solely the register value to be written
- // FIXME: should this be unsigned?
- payload += 1;
- *payload = host_to_usrp_u32((uint32_t) val);
-
- // Rebuild the header to update the payload length
- incr_header_len(CS_FIXED_LEN + CS_WRITEREG_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a write register masked command to the packet.
- *
- * The \p reg_num is the register number for which the value \p val will be
- * written, masked by \p mask
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_write_reg_masked(long reg_num, long val, long mask)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_WRITEREGMASKED_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = 0;
-
- // Build the first word which includes the register number
- word0 = (
- ((OP_WRITE_REG_MASKED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_WRITEREGMASKED_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // Skip over the first word and write the register value
- payload += 1;
- *payload = host_to_usrp_u32((uint32_t) val);
-
- // Skip over the register value and write the mask
- payload += 1;
- *payload = host_to_usrp_u32((uint32_t) mask);
-
- // Rebuild the header to update the payload length
- incr_header_len(CS_FIXED_LEN + CS_WRITEREGMASKED_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a read register message to the packet.
- *
- * The \p rid will be the associated RID returned with the response, and \p
- * reg_num is the register to be read.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_read_reg(long rid, long reg_num)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_READREG_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t read_reg = (
- ((OP_READ_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_READREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
-
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(read_reg);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_READREG_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a read register reply response to the current packet. This is
- * used by the fake USRP code to generate fake register read responses for
- * testing.
- *
- * The \p rid is the associated RID to be included in the response, \p reg_num
- * is the register the read is coming from, and \p reg_val is the value of the
- * read.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_read_reg_reply(long rid, long reg_num, long reg_val)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_READREGREPLY_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = (
- ((OP_READ_REG_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_READREGREPLY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT)
-
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // Hop to the next word and write the reg value
- payload += 1;
- *payload = host_to_usrp_u32((uint32_t) reg_val);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_READREGREPLY_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds a delay command to the current packet.
- *
- * The \p ticks parameter is the number of clock ticks the FPGA should delay
- * parsing for, which is added to the packet.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_delay(long ticks)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_DELAY_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t delay = (
- ((OP_DELAY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_DELAY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((ticks & CS_DELAY_MASK) << CS_DELAY_SHIFT)
-
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(delay);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_DELAY_LEN);
-
- return true;
-}
-
-/*!
- * \brief
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_i2c_write(long i2c_addr, uint8_t *i2c_data, size_t data_len)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- int i2c_len = data_len + 2; // 2 bytes between mbz and addr
-
- if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = 0;
-
- word0 = (
- ((OP_I2C_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // Jump over the first word and write the data
- // FIXME: Should the data be changed to usrp byte order?
- payload += 1;
- memcpy(payload, i2c_data, data_len);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + i2c_len);
-
- return true;
-}
-
-/*!
- * \brief Adds an I2C read command to the current packet.
- *
- * The \p rid is the associated RID to return with the read response, \p
- * i2c_addr is the address to read from on the I2C bus, and \p n_bytes is the
- * number of bytes to be read from the bus.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_i2c_read(long rid, long i2c_addr, long n_bytes)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_I2CREAD_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = 0;
-
- word0 = (
- ((OP_I2C_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_I2CREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // Jump a word and write the number of bytes to read
- payload += 1;
- uint32_t word1 =
- (n_bytes & CS_I2CREADBYTES_MASK) << CS_I2CREADBYTES_SHIFT;
- *payload = host_to_usrp_u32(word1);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_I2CREAD_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds an I2C read reply response to the current packet. This is used
- * by the fake USRP code to generate fake I2C responses.
- *
- * The \p rid is the RID to be associated with the response, \p i2c_addr is the
- * address on the I2C bus that the \p i2c_data of \p i2c_data_len was read from.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_i2c_read_reply(long rid, long i2c_addr, uint8_t *i2c_data, long i2c_data_len)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- int i2c_len = i2c_data_len + 2;
-
- if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN))
- return false;
-
- uint32_t word0 = 0;
-
- word0 = (
- ((OP_I2C_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT)
- );
-
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word0);
-
- // Jump a word and write the actual data
- payload += 1;
- memcpy(payload, i2c_data, i2c_data_len);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + i2c_len);
-
- return true;
-}
-
-/*!
- * \brief Adds a SPI write command to the current packet.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_spi_write(long enables, long format, long opt_header_bytes, uint8_t *spi_data, long spi_data_len)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- int spi_len = spi_data_len + 6;
-
- if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN))
- return false;
-
- uint32_t word = 0;
-
- // First word contains the opcode and length, then mbz
- word = (
- ((OP_SPI_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT)
- );
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- payload += 1;
-
- // Second word contains the enables, format, and optional tx bytes
- word = 0;
- word = (
- ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT)
- | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT)
- | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT)
- );
- payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- payload += 1;
- memcpy(payload, spi_data, spi_data_len);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + spi_len);
-
- return true;
-}
-
-/*!
- * \brief Adds a SPI bus read command to the packet.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_spi_read(long rid, long enables, long format, long opt_header_bytes, long n_bytes)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- if((MAX_PAYLOAD - p_len) < (CS_SPIREAD_LEN + CS_FIXED_LEN))
- return false;
-
- uint32_t word = 0;
-
- // First word contains the opcode, length, and RID
- word = (
- ((OP_SPI_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((CS_SPIREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- );
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- payload += 1;
-
- // Second word contains the enables, format, and optional tx bytes
- word = 0;
- word = (
- ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT)
- | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT)
- | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT)
- );
- payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- payload += 1;
-
- // The third word contains the number of bytes
- word = 0;
- word = (
- ((n_bytes & CS_SPINBYTES_MASK) << CS_SPINBYTES_SHIFT)
- );
- payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + CS_SPIREAD_LEN);
-
- return true;
-}
-
-/*!
- * \brief Adds an SPI read reply to the current packet. This is used by the
- * fake USRP code to generate fake responses for SPI reads.
- *
- * \returns true if the command was added to the packet, false otherwise.
- */
-bool usrp_inband_usb_packet::cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len)
-{
- if(!align32())
- return false;
-
- int p_len = payload_len();
-
- int spi_len = spi_data_len + 2;
-
- if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN))
- return false;
-
- uint32_t word = 0;
-
- // First word contains the opcode, length, and RID
- word = (
- ((OP_SPI_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
- | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT)
- | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
- );
- uint32_t *payload = (uint32_t *) (d_payload + p_len);
- *payload = host_to_usrp_u32(word);
-
- // Jump a word and write the actual data
- payload += 1;
- memcpy(payload, spi_data, spi_data_len);
-
- // Update payload length
- incr_header_len(CS_FIXED_LEN + spi_len);
-
- return true;
-}
-
-/*!
- * \brief Since all control packets contain subpackets which have the length of
- * the subpacket at a uniform location in the subpacket, this will return the
- * subpacket length given a byte offset of the start of the subpacket from the beginning of the packet.
- *
- * \returns the length of the subpacket
- */
-int usrp_inband_usb_packet::cs_len(int payload_offset) {
- uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset)));
- return (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK;
-}
-
-/*!
- * \brief The following method takes an offset within the packet payload to
- * extract a control/status subpacket and constructs a pmt response which
- * includes the proper signal and arguments specified by usrp-low-level-cs. The
- * USRP server could therefore use this to read subpackets and pass them
- * responses back up to the application. It's arguable that only reply packets
- * should be parsed here, however we parse others for use in debugging or
- * failure reporting on the transmit side of packets.
- */
-pmt_t usrp_inband_usb_packet::read_subpacket(int payload_offset) {
-
- uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset)));
- uint32_t opcode = (subpkt >> CS_OPCODE_SHIFT) & CS_OPCODE_MASK;
- uint32_t len = (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK;
-
- switch(opcode) {
-
- case OP_PING_FIXED_REPLY:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & CS_PINGVAL_MASK);
- return pmt_list3(s_op_ping_fixed_reply, rid, pingval);
- }
-
- case OP_READ_REG_REPLY:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK);
-
- // To get the register value we just read the next 32 bits
- uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- pmt_t reg_val = pmt_from_long(val);
-
- return pmt_list4(s_op_read_reg_reply, rid, reg_num, reg_val);
- }
-
- case OP_I2C_READ_REPLY:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK);
-
- // Make a u8 vector to dump the data from the packet into
- size_t i2c_data_len;
- pmt_t i2c_data = pmt_make_u8vector(len - 2, 0); // skip rid+mbz+addr = 2 bytes
- uint8_t *w_data =
- (uint8_t *) pmt_u8vector_writable_elements(i2c_data, i2c_data_len);
-
- memcpy(w_data, d_payload + payload_offset + 4, i2c_data_len); // skip first word
-
- return pmt_list4(s_op_i2c_read_reply, rid, i2c_addr, i2c_data);
- }
-
- case OP_SPI_READ_REPLY:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
-
- // Make a u8 vector to dump the data from the packet into
- size_t spi_data_len;
- pmt_t spi_data = pmt_make_u8vector(len - 2, 0); // skip rid+mbz+addr = 2 bytes
- uint8_t *w_data =
- (uint8_t *) pmt_u8vector_writable_elements(spi_data, spi_data_len);
-
- memcpy(w_data, d_payload + payload_offset + 4, spi_data_len); // skip first word
-
- return pmt_list3(s_op_spi_read_reply, rid, spi_data);
- }
-
- case OP_PING_FIXED:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & CS_PINGVAL_MASK);
- return pmt_list3(s_op_ping_fixed, rid, pingval);
- }
-
- case OP_WRITE_REG:
- {
- pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK);
-
- // To get the register value we just read the next 32 bits
- uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- pmt_t reg_val = pmt_from_long(val);
-
- return pmt_list3(s_op_write_reg, reg_num, reg_val);
- }
-
- case OP_WRITE_REG_MASKED:
- {
- pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK);
-
- // To get the register value we just read the next 32 bits
- uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- pmt_t reg_val = pmt_from_long(val);
-
- // The mask is the next 32 bits
- uint32_t mask = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 8)));
- pmt_t reg_mask = pmt_from_long(mask);
-
- return pmt_list4(s_op_write_reg_masked, reg_num, reg_val, reg_mask);
- }
-
- case OP_READ_REG:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK);
-
- return pmt_list3(s_op_read_reg, rid, reg_num);
- }
-
- case OP_I2C_WRITE:
- {
- pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK);
-
- // The length includes an extra 2 bytes for storing the mbz and addr
- pmt_t i2c_data = pmt_make_u8vector(len-2, 0);
-
- // Get a writable address to copy the data from the packet
- size_t ignore;
- uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(i2c_data, ignore);
- memcpy(w_data, d_payload + payload_offset + 4, len-2);
-
-
- return pmt_list3(s_op_i2c_write, i2c_addr, i2c_data);
- }
-
- case OP_I2C_READ:
- {
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
- pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK);
-
- // The number of bytes is in the next word
- uint32_t bytes = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- bytes = (bytes >> CS_I2CREADBYTES_SHIFT) & CS_I2CREADBYTES_MASK;
- pmt_t i2c_bytes = pmt_from_long(bytes);
-
- return pmt_list4(s_op_i2c_read, rid, i2c_addr, i2c_bytes);
- }
-
- case OP_SPI_WRITE:
- {
- // Nothing interesting in the first word, skip to the next
- uint32_t word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- pmt_t enables = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & CS_SPIENABLES_MASK);
- pmt_t format = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & CS_SPIFORMAT_MASK);
- pmt_t opt = pmt_from_long((word >> CS_SPIOPT_SHIFT) & CS_SPIOPT_MASK);
-
- // From the next word and on is data
- size_t spi_data_len;
- pmt_t spi_data = pmt_make_u8vector(len - 6, 0); // skip rid+mbz+addr = 2 bytes
- uint8_t *w_data =
- (uint8_t *) pmt_u8vector_writable_elements(spi_data, spi_data_len);
-
- memcpy(w_data, d_payload + payload_offset + 8, spi_data_len); // skip first 2 words
-
- return pmt_list5(s_op_spi_write, enables, format, opt, spi_data);
- }
-
- case OP_SPI_READ:
- {
- // Read the RID from the first word, the rest is mbz
- pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);
-
- // Continue at the next word...
- uint32_t word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4)));
- pmt_t enables = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & CS_SPIENABLES_MASK);
- pmt_t format = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & CS_SPIFORMAT_MASK);
- pmt_t opt = pmt_from_long((word >> CS_SPIOPT_SHIFT) & CS_SPIOPT_MASK);
-
- // The number of bytes is the only thing to read in the next word
- word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 8)));
- pmt_t n_bytes = pmt_from_long((word >> CS_SPINBYTES_SHIFT) & CS_SPINBYTES_MASK);
-
- return pmt_list6(s_op_spi_read, rid, enables, format, opt, n_bytes);
- }
-
- case OP_DELAY:
- {
- pmt_t ticks = pmt_from_long((subpkt >> CS_DELAY_SHIFT) & CS_DELAY_MASK);
-
- return pmt_list2(s_op_delay, ticks);
- }
-
- default:
- return PMT_NIL;
-
- }
-}
-
diff --git a/usrp/host/lib/inband/usrp_inband_usb_packet.h b/usrp/host/lib/inband/usrp_inband_usb_packet.h
deleted file mode 100644
index 6f1a3feb3..000000000
--- a/usrp/host/lib/inband/usrp_inband_usb_packet.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_USRP_INBAND_USB_PACKET_H_
-#define INCLUDED_USRP_INBAND_USB_PACKET_H_
-
-#include <usrp_bytesex.h>
-#include <mblock/mblock.h>
-#include <pmt.h>
-#include <iostream>
-
-#include <symbols_usrp_low_level_cs.h>
-
-static const int USB_PKT_SIZE = 512; // bytes
-static const int MAX_PAYLOAD = USB_PKT_SIZE-2*sizeof(uint32_t);
-static const int CONTROL_CHAN = 0x1f;
-
-class usrp_inband_usb_packet {
- //
- // keep raw packet in USRP-endian order
- //
- uint32_t d_word0;
- uint32_t d_timestamp;
- unsigned char d_payload[MAX_PAYLOAD];
-
-public:
-
- enum opcodes {
- OP_PING_FIXED = 0x00,
- OP_PING_FIXED_REPLY = 0x01,
- OP_WRITE_REG = 0x02,
- OP_WRITE_REG_MASKED = 0x03,
- OP_READ_REG = 0x04,
- OP_READ_REG_REPLY = 0x05,
- OP_I2C_WRITE = 0x06,
- OP_I2C_READ = 0x07,
- OP_I2C_READ_REPLY = 0x08,
- OP_SPI_WRITE = 0x09,
- OP_SPI_READ = 0x0a,
- OP_SPI_READ_REPLY = 0x0b,
- OP_DELAY = 0x0c
- };
-
- enum flags {
- FL_OVERRUN = 0x80000000,
- FL_UNDERRUN = 0x40000000,
- FL_DROPPED = 0x20000000,
- FL_START_OF_BURST = 0x10000000,
- FL_END_OF_BURST = 0x08000000,
- FL_CARRIER_SENSE = 0x04000000,
-
- FL_ALL_FLAGS = 0xfc000000
- };
-
- static const int FL_OVERRUN_SHIFT = 31;
- static const int FL_UNDERRUN_SHIFT = 30;
- static const int FL_DROPPED_SHIFT = 29;
- static const int FL_END_OF_BURST_SHIFT = 27;
- static const int FL_START_OF_BURST_SHIFT = 28;
-
- static const int RSSI_MASK = 0x3f;
- static const int RSSI_SHIFT = 21;
-
- static const int CHAN_MASK = 0x1f;
- static const int CHAN_SHIFT = 16;
-
- static const int TAG_MASK = 0xf;
- static const int TAG_SHIFT = 9;
-
- static const int PAYLOAD_LEN_MASK = 0x1ff;
- static const int PAYLOAD_LEN_SHIFT = 0;
-
- // Fixed size for opcode and length fields
- static const int CS_FIXED_LEN = 2;
-
- static const int CS_OPCODE_MASK = 0xff;
- static const int CS_OPCODE_SHIFT = 24;
-
- static const int CS_LEN_MASK = 0xff;
- static const int CS_LEN_SHIFT = 16;
-
- static const int CS_RID_MASK = 0x3f;
- static const int CS_RID_SHIFT = 10;
-
- static const int CS_PING_LEN = 2;
- static const int CS_PINGVAL_MASK = 0x3ff;
- static const int CS_PINGVAL_SHIFT = 0;
-
- static const int CS_WRITEREG_LEN = 6;
- static const int CS_WRITEREGMASKED_LEN = 10;
- static const int CS_READREG_LEN = 2;
- static const int CS_READREGREPLY_LEN = 6;
- static const int CS_REGNUM_MASK = 0x3ff;
- static const int CS_REGNUM_SHIFT = 0;
-
- static const int CS_DELAY_LEN = 2;
- static const int CS_DELAY_MASK = 0xffff;
- static const int CS_DELAY_SHIFT = 0;
-
- static const int CS_I2CADDR_MASK = 0x7f;
- static const int CS_I2CADDR_SHIFT = 0;
-
- static const int CS_I2CREAD_LEN = 3;
- static const int CS_I2CREADBYTES_MASK = 0x7f;
- static const int CS_I2CREADBYTES_SHIFT = 24;
-
- static const int CS_SPIOPT_MASK = 0xffff;
- static const int CS_SPIOPT_SHIFT = 0;
- static const int CS_SPIFORMAT_MASK = 0xff;
- static const int CS_SPIFORMAT_SHIFT = 16;
- static const int CS_SPIENABLES_MASK = 0xff;
- static const int CS_SPIENABLES_SHIFT = 24;
- static const int CS_SPIREAD_LEN = 7;
- static const int CS_SPINBYTES_MASK = 0xff;
- static const int CS_SPINBYTES_SHIFT = 24;
-
-public:
-
- void set_timestamp(uint32_t timestamp){
- d_timestamp = host_to_usrp_u32(timestamp);
- }
-
- void set_end_of_burst() {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- word0 |= 1<<FL_END_OF_BURST_SHIFT;
- d_word0 = host_to_usrp_u32(word0);
- }
-
- void set_header(int flags, int chan, int tag, int payload_len){
- uint32_t word0 = ((flags & FL_ALL_FLAGS)
- | ((chan & CHAN_MASK) << CHAN_SHIFT)
- | ((tag & TAG_MASK) << TAG_SHIFT)
- | ((payload_len & PAYLOAD_LEN_MASK) << PAYLOAD_LEN_SHIFT));
- d_word0 = host_to_usrp_u32(word0);
- }
-
- void incr_header_len(int val) {
- set_header(flags(), chan(), tag(), payload_len() + val);
- }
-
- uint32_t timestamp() const {
- return usrp_to_host_u32(d_timestamp);
- }
-
- int rssi() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> RSSI_SHIFT) & RSSI_MASK;
- }
-
- int chan() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> CHAN_SHIFT) & CHAN_MASK;
- }
-
- int tag() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> TAG_SHIFT) & TAG_MASK;
- }
-
- int payload_len() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK;
- }
-
- int flags() const {
- return usrp_to_host_u32(d_word0) & FL_ALL_FLAGS;
- }
-
- int overrun() const {
- return (usrp_to_host_u32(d_word0) & FL_OVERRUN) >> FL_OVERRUN_SHIFT;
- }
-
-
- int underrun() const {
- return (usrp_to_host_u32(d_word0) & FL_UNDERRUN) >> FL_UNDERRUN_SHIFT;
- }
-
-
- int start_of_burst() const {
- return (usrp_to_host_u32(d_word0) & FL_START_OF_BURST) >> FL_START_OF_BURST_SHIFT;
- }
-
- int end_of_burst() const {
- return (usrp_to_host_u32(d_word0) & FL_END_OF_BURST) >> FL_END_OF_BURST_SHIFT;
- }
-
- int dropped() const {
- return (usrp_to_host_u32(d_word0) & FL_DROPPED) >> FL_DROPPED_SHIFT;
- }
-
- unsigned char *payload() {
- return d_payload;
- }
-
- static int max_payload() {
- return MAX_PAYLOAD;
- }
-
- static int max_pkt_size() {
- return USB_PKT_SIZE;
- }
-
- // C/S methods
- bool align32();
- bool cs_ping(long rid, long ping_val);
- bool cs_ping_reply(long rid, long ping_val);
- bool cs_write_reg(long reg_num, long val);
- bool cs_write_reg_masked(long reg_num, long val, long mask);
- bool cs_read_reg(long rid, long reg_num);
- bool cs_read_reg_reply(long rid, long reg_num, long reg_val);
- bool cs_delay(long ticks);
- bool cs_i2c_write(long i2c_addr, uint8_t *i2c_data, size_t data_len);
- bool cs_i2c_read(long rid, long i2c_addr, long n_bytes);
- bool cs_i2c_read_reply(long rid, long i2c_addr, uint8_t *i2c_data, long i2c_data_len);
- bool cs_spi_write(long enables, long format, long opt_header_bytes, uint8_t *spi_data, long spi_data_len);
- bool cs_spi_read(long rid, long enables, long format, long opt_header_bytes, long n_bytes);
- bool cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len);
- int cs_len(int payload_offset);
- pmt_t read_subpacket(int payload_offset);
-};
-
-#endif
diff --git a/usrp/host/lib/inband/usrp_interface.mbh b/usrp/host/lib/inband/usrp_interface.mbh
deleted file mode 100644
index ad0f78b4e..000000000
--- a/usrp/host/lib/inband/usrp_interface.mbh
+++ /dev/null
@@ -1,88 +0,0 @@
-;; -*- scheme -*- ; not really, but tells emacs how to format this
-;;
-;; Copyright 2007 Free Software Foundation, Inc.
-;;
-;; This file is part of GNU Radio
-;;
-;; GNU Radio is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-;;
-;; GNU Radio is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License along
-;; with this program; if not, write to the Free Software Foundation, Inc.,
-;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-;;
-
-;; ----------------------------------------------------------------
-;; This is an mblock header file
-;;
-;; The format is very much a work-in-progress.
-;; It'll be compiled to C++.
-;; ----------------------------------------------------------------
-
-;; ----------------------------------------------------------------
-;; usrp-interface-cs
-;;
-;; Handles interaction between the usrp_sever and the USB interface
-
-(define-protocol-class usrp-interface-cs
-
- (:outgoing
- (cmd-usrp-open invocation-handle which-usrp)
- (cmd-usrp-close invocation-handle)
- (cmd-usrp-ntx-chan invocation-handle)
- (cmd-usrp-nrx-chan invocation-handle)
- (cmd-usrp-write invocation-handle channel data)
- (cmd-usrp-start-reading invocation-handle channel)
- )
-
- (:incoming
- (response-usrp-open invocation-handle status)
- (response-usrp-close invocation-handle status)
- (response-usrp-ntx-chan invocation-handle ntx-chan)
- (response-usrp-nrx-chan invocation-handle nrx-chan)
- (response-usrp-write invocation-handle status channel)
- (response-usrp-read invocation-handle status data)
- )
- )
-
-;; ----------------------------------------------------------------
-;; usrp-tx-cs
-;;
-;; Handles interaction between the USB interface and TX interface
-
-(define-protocol-class usrp-tx-cs
-
- (:outgoing
- (cmd-usrp-tx-write invocation-handle channel data tx-handle)
- )
-
- (:incoming
- (response-usrp-tx-write invocation-handle status channel)
- )
- )
-
-;; ----------------------------------------------------------------
-;; usrp-rx-cs
-;;
-;; Handles interaction between the USB interface and RX interface
-
-(define-protocol-class usrp-rx-cs
-
- (:outgoing
- (cmd-usrp-rx-start-reading invocation-handle rx-handle)
- (cmd-usrp-rx-stop-reading invocation-handle)
- )
-
- (:incoming
- (response-usrp-rx-read invocation-handle status data)
-
- ;; There is currently no response to a stop reading
- )
- )
diff --git a/usrp/host/lib/inband/usrp_rx.cc b/usrp/host/lib/inband/usrp_rx.cc
deleted file mode 100644
index fe9486cf6..000000000
--- a/usrp/host/lib/inband/usrp_rx.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_rx.h>
-
-#include <usrp_standard.h>
-#include <iostream>
-#include <vector>
-#include <usb.h>
-#include <mblock/class_registry.h>
-#include <usrp_inband_usb_packet.h>
-#include <fpga_regs_common.h>
-#include <stdio.h>
-
-#include <symbols_usrp_rx_cs.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-static const bool verbose = false;
-
-bool usrp_rx_stop;
-
-usrp_rx::usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_disk_write(false),
- d_disk_write_pkt(false) // if true, writes full packet, else just the payload
-{
- d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL);
-
- if(d_disk_write) {
- d_ofile0.open("rx_data_chan0.dat",std::ios::binary|std::ios::out);
- d_ofile1.open("rx_data_chan1.dat",std::ios::binary|std::ios::out);
- d_cs_ofile.open("rx_cs.dat",std::ios::binary|std::ios::out);
- }
-
- usrp_rx_stop = false;
-
-}
-
-usrp_rx::~usrp_rx()
-{
- if(d_disk_write) {
- d_ofile0.close();
- d_ofile1.close();
- d_cs_ofile.close();
- }
-}
-
-void
-usrp_rx::initial_transition()
-{
-
-}
-
-/*!
- * \brief Handles incoming signals to to the m-block, wihch should only ever be
- * a single message: cmd-usrrp-rx-start-reading. There is no signal to stop
- * reading as the m-block goes in to a forever loop to read inband packets from
- * the bus.
- */
-void
-usrp_rx::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal();
- pmt_t port_id = msg->port_id();
- pmt_t data = msg->data();
-
- // Theoretically only have 1 message to ever expect, but
- // want to make sure its at least what we want
- if(pmt_eq(port_id, d_cs->port_symbol())) {
-
- if(pmt_eqv(event, s_cmd_usrp_rx_start_reading))
- read_and_respond(data);
- }
-}
-
-/*!
- * \brief Performs the actual reading of data from the USB bus, called by
- * handle_message() when a cmd-usrp-rx-start-reading signal is received.
- *
- * The method enters a forever loop where it continues to read data from the bus
- * and generate read responses to the higher layer. Currently, shared memory is
- * used to exit this loop.
- *
- * The \p data parameter is a PMT list which contains only a single element, an
- * invocation handle which will be returned with all read respones.
- */
-void
-usrp_rx::read_and_respond(pmt_t data)
-{
- size_t ignore;
- bool underrun;
- unsigned int n_read;
- unsigned int pkt_size = sizeof(transport_pkt);
-
- pmt_t invocation_handle = pmt_nth(0, data);
-
- // Need the handle to the RX port to send responses, this is passed
- // by the USRP interface m-block
- pmt_t handle = pmt_nth(1, data);
- d_urx =
- boost::any_cast<usrp_standard_rx_sptr>(pmt_any_ref(handle));
-
- if(verbose)
- std::cout << "[usrp_rx] Waiting for packets..\n";
-
- // Read by 512 which is packet size and send them back up
- while(!usrp_rx_stop) {
-
- pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
- transport_pkt *pkt =
- (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore);
-
- n_read = d_urx->read(pkt, pkt_size, &underrun);
-
- if(n_read != pkt_size) {
- std::cerr << "[usrp_rx] Error reading packet, shutting down\n";
- d_cs->send(s_response_usrp_rx_read,
- pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
- return;
- }
-
- if(underrun && verbose && 0)
- std::cout << "[usrp_rx] Underrun\n";
-
- d_cs->send(s_response_usrp_rx_read,
- pmt_list3(PMT_NIL, PMT_T, v_pkt));
- if(verbose && 0)
- std::cout << "[usrp_rx] Read 1 packet\n";
-
- if(d_disk_write) {
- if(pkt->chan() == CONTROL_CHAN)
- d_cs_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
- else {
- if(d_disk_write_pkt) {
- if(pkt->chan() == 0)
- d_ofile0.write((const char *)pkt, transport_pkt::max_pkt_size());
- else if(pkt->chan() == 1)
- d_ofile1.write((const char *)pkt, transport_pkt::max_pkt_size());
- } else {
- if(pkt->chan() == 0)
- d_ofile0.write((const char *)pkt->payload(), transport_pkt::max_payload());
- else if(pkt->chan() == 1)
- d_ofile1.write((const char *)pkt->payload(), transport_pkt::max_payload());
- }
- }
-
- d_cs_ofile.flush();
- d_ofile0.flush();
- d_ofile1.flush();
- }
- }
-
- usrp_rx_stop = false;
-
- if(verbose) {
- std::cout << "[USRP_RX] Stopping...\n";
- fflush(stdout);
- }
-}
-
-REGISTER_MBLOCK_CLASS(usrp_rx);
diff --git a/usrp/host/lib/inband/usrp_rx.h b/usrp/host/lib/inband/usrp_rx.h
deleted file mode 100644
index 1006235bf..000000000
--- a/usrp/host/lib/inband/usrp_rx.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_RX_H
-#define INCLUDED_USRP_RX_H
-
-#include <mblock/mblock.h>
-#include <fstream>
-#include "usrp_standard.h"
-
-extern bool usrp_rx_stop; // used to communicate a 'stop' to the RX stub
-
-/*!
- * \brief Implements the low level usb interface to the USRP
- */
-class usrp_rx : public mb_mblock
-{
- mb_port_sptr d_cs;
- usrp_standard_rx_sptr d_urx;
-
- bool d_disk_write;
- bool d_disk_write_pkt;
- std::ofstream d_ofile0;
- std::ofstream d_ofile1;
- std::ofstream d_cs_ofile;
-
- public:
- usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_rx();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- private:
- void read_and_respond(pmt_t data);
- void read_data();
-
-};
-
-
-#endif /* INCLUDED_USRP_RX_H */
-
diff --git a/usrp/host/lib/inband/usrp_rx_stub.cc b/usrp/host/lib/inband/usrp_rx_stub.cc
deleted file mode 100644
index e5c454d24..000000000
--- a/usrp/host/lib/inband/usrp_rx_stub.cc
+++ /dev/null
@@ -1,227 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_rx_stub.h>
-
-#include <iostream>
-#include <vector>
-#include <usb.h>
-#include <mblock/class_registry.h>
-#include <usrp_inband_usb_packet.h>
-#include <fpga_regs_common.h>
-#include "usrp_standard.h"
-#include <stdio.h>
-#include <string.h>
-#include <ui_nco.h>
-#include <fstream>
-
-#include <symbols_usrp_rx_cs.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-static const bool verbose = false;
-
-bool usrp_rx_stop_stub;
-
-// Used for the fake control packet response code to send the responses back up
-// the RX. The TX stub dumps responses in to this queue.
-std::queue<pmt_t> d_cs_queue;
-
-usrp_rx_stub::usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_samples_per_frame((long)(126)),
- d_decim_rx(128),
- d_amplitude(16384),
- d_disk_write(false)
-{
-
- // Information about the rates are passed all the way from the app in the form
- // of a dictionary. We use this to read the RX decimation rate and compute
- // the approximate number of MS/s as a form of flow control for the stub.
- pmt_t usrp_dict = user_arg;
-
- if (pmt_is_dict(usrp_dict)) {
- // Read the RX decimation rate
- if(pmt_t decim_rx = pmt_dict_ref(usrp_dict,
- pmt_intern("decim-rx"),
- PMT_NIL)) {
- if(!pmt_eqv(decim_rx, PMT_NIL))
- d_decim_rx = pmt_to_long(decim_rx);
- }
- }
-
- d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL);
-
- // initialize NCO
- double freq = 100e3;
- int interp = 32; // 32 -> 4MS/s
- double sample_rate = 64e6 / interp;
- d_nco.set_freq(2*M_PI * freq/sample_rate);
-
- //d_disk_write = true;
-
- if(d_disk_write)
- d_ofile.open("raw_rx.dat",std::ios::binary|std::ios::out);
-
- usrp_rx_stop_stub = false;
-}
-
-usrp_rx_stub::~usrp_rx_stub()
-{
- if(d_disk_write)
- d_ofile.close();
-}
-
-void
-usrp_rx_stub::initial_transition()
-{
-}
-
-void
-usrp_rx_stub::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal();
- pmt_t port_id = msg->port_id();
- pmt_t data = msg->data();
-
- if (pmt_eq(msg->signal(), s_timeout)
- && !pmt_eq(msg->data(), s_done)) {
-
- if(!usrp_rx_stop_stub)
- read_and_respond();
- else { // requested to stop
- cancel_timeout(msg->metadata());
- usrp_rx_stop_stub=false;
- if(verbose)
- std::cout << "[USRP_RX_STUB] Stopping RX stub\n";
- }
-
- }
-
- // Theoretically only have 1 message to ever expect, but
- // want to make sure its at least what we want
- if(pmt_eq(port_id, d_cs->port_symbol())
- && pmt_eqv(event, s_cmd_usrp_rx_start_reading)) {
-
- if(verbose)
- std::cout << "[USRP_RX_STUB] Starting with decim @ "
- << d_decim_rx << std::endl;
-
- start_packet_timer();
- }
-}
-
-// Setup a periodic timer which will drive packet generation
-void
-usrp_rx_stub::start_packet_timer()
-{
- d_t0 = mb_time::time(); // current time
-
- // Calculate the inter-packet arrival time.
- double samples_per_sec = (64.0/(double)d_decim_rx)*1000000.0;
- double frames_per_sec = samples_per_sec / (double)d_samples_per_frame;
- double frame_rate = 1.0 / frames_per_sec;
-
- if(verbose) {
- std::cout << "[USRP_RX_STUB] Scheduling periodic packet generator\n";
- std::cout << "\tsamples_per_sec: " << samples_per_sec << std::endl;
- std::cout << "\tframes_per_sec: " << frames_per_sec << std::endl;
- std::cout << "\tframe_rate: " << frame_rate << std::endl;
- }
-
- schedule_periodic_timeout(d_t0 + frame_rate, mb_time(frame_rate), PMT_T);
-}
-
-void
-usrp_rx_stub::read_and_respond()
-{
-
- long nsamples_this_frame = d_samples_per_frame;
-
- size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q
- long channel = 0;
- long n_bytes = nshorts*2;
- pmt_t uvec = pmt_make_s16vector(nshorts, 0);
- size_t ignore;
- int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore);
-
- // fill in the complex sinusoid
-
- for (int i = 0; i < nsamples_this_frame; i++){
-
- if (1){
- gr_complex s;
- d_nco.sincos(&s, 1, d_amplitude);
- // write 16-bit i & q
- samples[2*i] = (int16_t) s.real();
- samples[2*i+1] = (int16_t) s.imag();
- }
- else {
- gr_complex s(d_amplitude, d_amplitude);
-
- // write 16-bit i & q
- samples[2*i] = (int16_t) s.real();
- samples[2*i+1] = (int16_t) s.imag();
- }
- }
-
- if(d_disk_write)
- d_ofile.write((const char *)samples, n_bytes);
-
- pmt_t v_pkt = pmt_make_u8vector(sizeof(transport_pkt), 0);
- transport_pkt *pkt =
- (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore);
-
- pkt->set_header(0, channel, 0, n_bytes);
- pkt->set_timestamp(0xffffffff);
- memcpy(pkt->payload(), samples, n_bytes);
-
- d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
-
- // Now lets check the shared CS queue between the TX and RX stub. Each
- // element in a queue is a list where the first element is an invocation
- // handle and the second element is a PMT u8 vect representation of the
- // CS packet response which can just be passed transparently.
- while(!d_cs_queue.empty()) {
-
- pmt_t cs_pkt = d_cs_queue.front();
- d_cs_queue.pop();
-
- pmt_t invocation_handle = pmt_nth(0, cs_pkt);
- pmt_t v_pkt = pmt_nth(1, cs_pkt);
-
- d_cs->send(s_response_usrp_rx_read,
- pmt_list3(invocation_handle,
- PMT_T,
- v_pkt)); // Take the front CS pkt
-
-
- if(verbose)
- std::cout << "[USRP_RX_STUB] Received CS response from TX stub\n";
- }
-
-}
-
-REGISTER_MBLOCK_CLASS(usrp_rx_stub);
diff --git a/usrp/host/lib/inband/usrp_rx_stub.h b/usrp/host/lib/inband/usrp_rx_stub.h
deleted file mode 100644
index 238b4568f..000000000
--- a/usrp/host/lib/inband/usrp_rx_stub.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_RX_STUB_H
-#define INCLUDED_USRP_RX_STUB_H
-
-#include <mblock/mblock.h>
-#include <vector>
-#include "usrp_standard.h"
-#include <ui_nco.h>
-#include <fstream>
-#include <queue>
-#include <usrp_inband_usb_packet.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-extern bool usrp_rx_stop_stub; // used to communicate a 'stop' to the RX stub
-extern std::queue<pmt_t> d_cs_queue;
-
-static pmt_t s_timeout = pmt_intern("%timeout");
-static pmt_t s_done = pmt_intern("done");
-
-/*!
- * \brief Implements the low level usb interface to the USRP
- */
-class usrp_rx_stub : public mb_mblock
-{
- public:
-
- mb_port_sptr d_cs;
- usrp_standard_rx* d_urx;
-
- long d_samples_per_frame;
- long d_decim_rx;
-
- mb_time d_t0;
- double d_delta_t;
-
- // for generating sine wave output
- ui_nco<float,float> d_nco;
- double d_amplitude;
-
- bool d_disk_write;
-
- std::ofstream d_ofile;
-
- public:
- usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_rx_stub();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- private:
- void read_and_respond();
- void read_data();
- void start_packet_timer();
-
-};
-
-
-#endif /* INCLUDED_USRP_RX_H */
-
diff --git a/usrp/host/lib/inband/usrp_server.cc b/usrp/host/lib/inband/usrp_server.cc
deleted file mode 100644
index ac2636308..000000000
--- a/usrp/host/lib/inband/usrp_server.cc
+++ /dev/null
@@ -1,1860 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <usrp_server.h>
-#include <iostream>
-#include <usrp_inband_usb_packet.h>
-#include <mblock/class_registry.h>
-#include <vector>
-#include <usrp_usb_interface.h>
-#include <string.h>
-#include <fpga_regs_common.h>
-#include <fpga_regs_standard.h>
-
-#include <symbols_usrp_server_cs.h>
-#include <symbols_usrp_channel.h>
-#include <symbols_usrp_tx.h>
-#include <symbols_usrp_rx.h>
-#include <symbols_usrp_low_level_cs.h>
-#include <symbols_usrp_interface_cs.h>
-
-static pmt_t s_shutdown = pmt_intern("%shutdown");
-
-typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy
-
-const static bool verbose = false;
-
-static std::string
-str(long x)
-{
- std::ostringstream s;
- s << x;
- return s.str();
-}
-
-usrp_server::usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_fpga_debug(false),
- d_interp_tx(128), // these should match the lower level defaults (rx also)
- d_decim_rx(128),
- d_fake_rx(false)
-{
- if(verbose)
- std::cout << "[USRP_SERVER] Initializing...\n";
-
- // Dictionary for arguments to all of the components
- d_usrp_dict = user_arg;
-
- if (pmt_is_dict(d_usrp_dict)) {
-
- if(pmt_t fpga_debug = pmt_dict_ref(d_usrp_dict,
- pmt_intern("fpga-debug"),
- PMT_NIL)) {
- if(pmt_eqv(fpga_debug, PMT_T))
- d_fpga_debug=true;
- }
-
- // Read the TX interpolations
- if(pmt_t interp_tx = pmt_dict_ref(d_usrp_dict,
- pmt_intern("interp-tx"),
- PMT_NIL)) {
- if(!pmt_eqv(interp_tx, PMT_NIL))
- d_interp_tx = pmt_to_long(interp_tx);
- }
-
- // Read the RX decimation rate
- if(pmt_t decim_rx = pmt_dict_ref(d_usrp_dict,
- pmt_intern("decim-rx"),
- PMT_NIL)) {
- if(!pmt_eqv(decim_rx, PMT_NIL))
- d_decim_rx = pmt_to_long(decim_rx);
- }
- }
-
- // control & status port
- d_cs = define_port("cs", "usrp-server-cs", true, mb_port::EXTERNAL);
- d_cs_usrp = define_port("cs_usrp", "usrp-interface-cs", false, mb_port::INTERNAL);
-
- // ports
- //
- // (if/when we do replicated ports, these will be replaced by a
- // single replicated port)
- for(int port=0; port < N_PORTS; port++) {
-
- d_tx.push_back(define_port("tx"+str(port),
- "usrp-tx",
- true,
- mb_port::EXTERNAL));
-
- d_rx.push_back(define_port("rx"+str(port),
- "usrp-rx",
- true,
- mb_port::EXTERNAL));
- }
-
- define_component("usrp", "usrp_usb_interface", d_usrp_dict);
- connect("self", "cs_usrp", "usrp", "cs");
-
- d_defer=false;
- d_opened=false;
-
- // FIXME: needs to be returned from open, if we want to use this
- d_nrx_chan = 2;
- d_ntx_chan = 2;
-
- // Initialize capacity on each channel to 0 and to no owner
- // Also initialize the USRP standard tx/rx pointers to NULL
- for(int chan=0; chan < d_ntx_chan; chan++)
- d_chaninfo_tx.push_back(channel_info());
-
- for(int chan=0; chan < d_nrx_chan; chan++)
- d_chaninfo_rx.push_back(channel_info());
-
- d_rx_chan_mask = 0;
-
- for(int i=0; i < D_MAX_RID; i++)
- d_rids.push_back(rid_info());
-
- //d_fake_rx=true;
-}
-
-/*!
- * \brief resets the assigned capacity and owners of each RX and TX channel from
- * allocations.
- */
-void
-usrp_server::reset_channels()
-{
-
- for(int chan=0; chan < d_ntx_chan; chan++) {
- d_chaninfo_tx[chan].assigned_capacity = 0;
- d_chaninfo_tx[chan].owner = PMT_NIL;
- }
-
- for(int chan=0; chan < d_nrx_chan; chan++) {
- d_chaninfo_rx[chan].assigned_capacity = 0;
- d_chaninfo_rx[chan].owner = PMT_NIL;
- }
-
- d_rx_chan_mask = 0;
-}
-
-usrp_server::~usrp_server()
-{
-}
-
-
-void
-usrp_server::initial_transition()
-{
- // the initial transition
-}
-
-/*!
- * \brief Reads all incoming messages to USRP server from the TX, RX, and the CS
- * ports. This drives the state of USRP server and dispatches based on the
- * message.
- */
-void
-usrp_server::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal(); // the "name" of the message
- pmt_t port_id = msg->port_id(); // which port it came in on
- pmt_t data = msg->data();
- pmt_t invocation_handle;
- pmt_t metadata = msg->metadata();
- pmt_t status;
-
- long port;
-
- if (pmt_eq(event, s_shutdown)) // ignore (for now)
- return;
-
- invocation_handle = pmt_nth(0, data);
-
- if (0){
- std::cout << "[USRP_SERVER] event: " << event << std::endl;
- std::cout << "[USRP_SERVER] port_id: " << port_id << std::endl;
- }
-
- // It would be nice if this were all table driven, and we could compute our
- // state transition as f(current_state, port_id, signal)
-
- // A message from the USRP CS, which should *only* be responses
- //
- // It is important that this set come before checking messages of any other
- // components. This is since we always want to listen to the low level USRP
- // server, even if we aren't initialized we are waiting for responses to
- // become initialized. Likewise, after the usrp_server is "closed", we still
- // want to pass responses back from the low level.
-
- //---------------- USRP RESPONSE ---------------//
- if (pmt_eq(port_id, d_cs_usrp->port_symbol())) {
-
- //-------------- USRP OPEN ------------------//
- if(pmt_eq(event, s_response_usrp_open)) {
- // pass the response back over the regular CS port
- pmt_t status = pmt_nth(1, data);
- d_cs->send(s_response_open, pmt_list2(invocation_handle, status));
-
- //reset_all_registers();
- //initialize_registers();
-
- if(pmt_eqv(status,PMT_T)) {
- d_opened = true;
- d_defer = false;
- recall_defer_queue();
- }
-
- return;
- }
- //------------- USRP CLOSE -------------------//
- else if (pmt_eq(event, s_response_usrp_close)) {
- pmt_t status = pmt_nth(1, data);
- d_cs->send(s_response_close, pmt_list2(invocation_handle, status));
-
- if(pmt_eqv(status,PMT_T)) {
- d_opened = false;
- d_defer = false;
- reset_channels();
- recall_defer_queue();
- }
-
- return;
- }
- //--------------- USRP WRITE --------------//
- else if (pmt_eq(event, s_response_usrp_write)) {
-
- pmt_t status = pmt_nth(1, data);
- long channel = pmt_to_long(pmt_nth(2, data));
- long port;
-
- // Do not report back responses if they were generated from a
- // command packet
- if(channel == CONTROL_CHAN)
- return;
-
- // Find the port through the owner of the channel
- if((port = tx_port_index(d_chaninfo_tx[channel].owner)) !=-1 )
- d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle, status));
- return;
- }
- //--------------- USRP READ ---------------//
- else if (pmt_eq(event, s_response_usrp_read)) {
-
- pmt_t status = pmt_nth(1, data);
-
- if(!pmt_eqv(status, PMT_T)) {
- std::cerr << "[USRP_SERVER] Error receiving packet\n";
- return;
- }
- else {
- handle_response_usrp_read(data);
- return;
- }
- }
-
- goto unhandled;
- }
-
- // Checking for defer on all other messages
- if(d_defer) {
- if (verbose)
- std::cout << "[USRP_SERVER] Received msg while deferring ("
- << msg->signal() << ")\n";
- d_defer_queue.push(msg);
- return;
- }
-
- //--------- CONTROL / STATUS ------------//
- if (pmt_eq(port_id, d_cs->port_symbol())){
-
- //----------- OPEN -----------//
- if (pmt_eq(event, s_cmd_open)){
-
- // Reject if already open
- if(d_opened) {
- d_cs->send(s_response_open, pmt_list2(invocation_handle, s_err_usrp_already_opened));
- return;
- }
-
- // the parameters are the same to the low level interface, so we just pass 'data' along
- d_cs_usrp->send(s_cmd_usrp_open, data);
-
- d_defer = true;
-
- return;
- }
- //---------- CLOSE -----------//
- else if (pmt_eq(event, s_cmd_close)){
-
- if(!d_opened) {
- d_cs->send(s_response_close, pmt_list2(invocation_handle, s_err_usrp_already_closed));
- return;
- }
-
- d_defer = true;
- d_cs_usrp->send(s_cmd_usrp_close, pmt_list1(invocation_handle));
-
- return;
- }
- //---------- MAX CAPACITY ----------//
- else if (pmt_eq(event, s_cmd_max_capacity)) {
-
- if(!d_opened) {
- d_cs->send(s_response_max_capacity,
- pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0)));
- return;
- }
-
- d_cs->send(s_response_max_capacity,
- pmt_list3(invocation_handle,
- PMT_T,
- pmt_from_long(max_capacity())));
- return;
- }
- //---------- NTX CHAN --------------//
- else if (pmt_eq(event, s_cmd_ntx_chan)) {
-
- if(!d_opened) {
- d_cs->send(s_response_ntx_chan,
- pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0)));
- return;
- }
-
- d_cs->send(s_response_ntx_chan,
- pmt_list3(invocation_handle,
- PMT_T,
- pmt_from_long(d_ntx_chan)));
- return;
- }
- //---------- NRX CHAN -----------//
- else if (pmt_eq(event, s_cmd_nrx_chan)) {
-
- if(!d_opened) {
- d_cs->send(s_response_nrx_chan,
- pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0)));
- return;
- }
-
- d_cs->send(s_response_nrx_chan,
- pmt_list3(invocation_handle,
- PMT_T,
- pmt_from_long(d_nrx_chan)));
- return;
- }
- //--------- ALLOCATION? -----------//
- else if (pmt_eq(event, s_cmd_current_capacity_allocation)) {
-
- if(!d_opened) {
- d_cs->send(s_response_current_capacity_allocation,
- pmt_list3(invocation_handle,
- s_err_usrp_not_opened,
- pmt_from_long(0)));
- return;
- }
-
- d_cs->send(s_response_current_capacity_allocation,
- pmt_list3(invocation_handle,
- PMT_T,
- pmt_from_long(current_capacity_allocation())));
- return;
- }
- goto unhandled;
- }
-
- //-------------- TX ---------------//
- if ((port = tx_port_index(port_id)) != -1) {
-
- //------------ ALLOCATE (TX) ----------------//
- if (pmt_eq(event, s_cmd_allocate_channel)){
-
- if(!d_opened) {
- d_tx[port]->send(s_response_allocate_channel,
- pmt_list3(invocation_handle,
- s_err_usrp_not_opened,
- pmt_from_long(0)));
- return;
- }
-
- handle_cmd_allocate_channel(d_tx[port], d_chaninfo_tx, data);
- return;
- }
-
- //----------- DEALLOCATE (TX) ---------------//
- if (pmt_eq(event, s_cmd_deallocate_channel)) {
-
- if(!d_opened) {
- d_tx[port]->send(s_response_deallocate_channel,
- pmt_list3(invocation_handle,
- s_err_usrp_not_opened,
- pmt_from_long(0)));
- return;
- }
-
- handle_cmd_deallocate_channel(d_tx[port], d_chaninfo_tx, data);
- return;
- }
-
- //-------------- XMIT RAW FRAME -----------------/
- if (pmt_eq(event, s_cmd_xmit_raw_frame)){
-
- if(!d_opened) {
- d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle, s_err_usrp_not_opened));
- return;
- }
-
- handle_cmd_xmit_raw_frame(d_tx[port], d_chaninfo_tx, data);
- return;
- }
-
- //-------------- CONTROL PACKET -----------------/
- if (pmt_eq(event, s_cmd_to_control_channel)) {
-
- if(!d_opened) {
- d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle, s_err_usrp_not_opened));
- return;
- }
-
- handle_cmd_to_control_channel(d_tx[port], d_chaninfo_tx, data);
- return;
-
- }
-
- goto unhandled;
- }
-
- //-------------- RX ---------------//
- if ((port = rx_port_index(port_id)) != -1) {
-
- //------------ ALLOCATE (RX) ----------------//
- if (pmt_eq(event, s_cmd_allocate_channel)) {
-
- if(!d_opened) {
- d_rx[port]->send(s_response_allocate_channel,
- pmt_list3(invocation_handle,
- s_err_usrp_not_opened,
- pmt_from_long(0)));
- return;
- }
-
- handle_cmd_allocate_channel(d_rx[port], d_chaninfo_rx, data);
- return;
- }
-
- //----------- DEALLOCATE (RX) ---------------//
- if (pmt_eq(event, s_cmd_deallocate_channel)) {
-
- if(!d_opened) {
- d_rx[port]->send(s_response_deallocate_channel,
- pmt_list3(invocation_handle,
- s_err_usrp_not_opened,
- pmt_from_long(0)));
- return;
- }
-
- handle_cmd_deallocate_channel(d_rx[port], d_chaninfo_rx, data);
- return;
- }
-
- //-------------- START RECV ----------------//
- if (pmt_eq(event, s_cmd_start_recv_raw_samples)) {
-
- if(!d_opened) {
- d_rx[port]->send(s_response_recv_raw_samples,
- pmt_list2(invocation_handle, s_err_usrp_not_opened));
- return;
- }
-
- handle_cmd_start_recv_raw_samples(d_rx[port], d_chaninfo_rx, data);
- return;
- }
-
- //-------------- STOP RECV ----------------//
- if (pmt_eq(event, s_cmd_stop_recv_raw_samples)) {
-
- if(!d_opened)
- return;
-
- // FIX ME : no response for stopping? even if error? (permissions)
- handle_cmd_stop_recv_raw_samples(d_rx[port], d_chaninfo_rx, data);
-
- return;
- }
-
- goto unhandled;
- }
-
- unhandled:
- std::cout << "[USRP_SERVER] unhandled msg: " << msg << std::endl;
-}
-
-/*!
- * \brief Takes a port_symbol() as parameter \p port_id and is used to determine
- * if the port is a TX port, or to find an index in the d_tx vector which stores
- * the port.
- *
- * \returns -1 if \p port_id is not in the d_tx vector (i.e., it's not a TX
- * port), otherwise returns an index in the d_tx vector which stores the port.
- */
-int usrp_server::tx_port_index(pmt_t port_id) {
-
- for(int i=0; i < (int) d_tx.size(); i++)
- if(pmt_eq(d_tx[i]->port_symbol(), port_id))
- return i;
-
- return -1;
-}
-
-/*!
- * \brief Takes a port_symbol() as parameter \p port_id and is used to determine
- * if the port is an RX port, or to find an index in the d_rx vector which
- * stores the port.
- *
- * \returns -1 if \p port_id is not in the d_rx vector (i.e., it's not an RX
- * port), otherwise returns an index in the d_rx vector which stores the port.
- */
-int usrp_server::rx_port_index(pmt_t port_id) {
-
- for(int i=0; i < (int) d_rx.size(); i++)
- if(pmt_eq(d_rx[i]->port_symbol(), port_id))
- return i;
-
- return -1;
-}
-
-/*!
- * \brief Determines the current total capacity allocated by all RX and TX
- * channels.
- *
- * \returns the total allocated capacity
- */
-long usrp_server::current_capacity_allocation() {
- long capacity = 0;
-
- for(int chan=0; chan < d_ntx_chan; chan++)
- capacity += d_chaninfo_tx[chan].assigned_capacity;
-
- for(int chan=0; chan < d_nrx_chan; chan++)
- capacity += d_chaninfo_rx[chan].assigned_capacity;
-
- return capacity;
-}
-
-
-/*!
- * \brief Called by the handle_message() method if the incoming message to
- * usrp_server is to allocate a channel (cmd-allocate-channel). The method
- * checks if the requested capacity exists and if so it will reserve it for the
- * caller on the channel that is returned via a response-allocate-channel
- * signal.
- */
-void
-usrp_server::handle_cmd_allocate_channel(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- long rqstd_capacity = pmt_to_long(pmt_nth(1, data));
- long chan;
-
- // Check capacity exists
- if((D_USB_CAPACITY - current_capacity_allocation()) < rqstd_capacity) {
-
- // no capacity available
- port->send(s_response_allocate_channel,
- pmt_list3(invocation_handle,
- s_err_requested_capacity_unavailable,
- PMT_NIL));
- return;
- }
-
- // Find a free channel, assign the capacity and respond
- for(chan=0; chan < (long)chan_info.size(); chan++) {
-
- if(verbose)
- std::cout << "[USRP_SERVER] Checking chan: " << chan
- << " owner " << chan_info[chan].owner
- << " size " << chan_info.size()
- << std::endl;
-
- if(chan_info[chan].owner == PMT_NIL) {
-
- chan_info[chan].owner = port->port_symbol();
- chan_info[chan].assigned_capacity = rqstd_capacity;
-
- port->send(s_response_allocate_channel,
- pmt_list3(invocation_handle,
- PMT_T,
- pmt_from_long(chan)));
-
- if(verbose)
- std::cout << "[USRP_SERVER] Assigning channel: " << chan
- << " to " << chan_info[chan].owner
- << std::endl;
- return;
- }
-
- }
-
- if (verbose)
- std::cout << "[USRP_SERVER] Couldnt find a TX chan\n";
-
- // no free TX chan found
- port->send(s_response_allocate_channel,
- pmt_list3(invocation_handle,
- s_err_channel_unavailable,
- PMT_NIL));
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method if the incoming message to
- * usrp_server is to deallocate a channel (cmd-deallocate-channel). The method
- * ensures that the sender of the signal owns the channel and that the channel
- * number is valid. A response-deallocate-channel signal is sent back with the
- * result of the deallocation.
- */
-void
-usrp_server::handle_cmd_deallocate_channel(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
-
- pmt_t invocation_handle = pmt_nth(0, data);
- long channel = pmt_to_long(pmt_nth(1, data));
-
- // Ensure the channel is valid and the caller owns the port
- if(!check_valid(port, channel, chan_info,
- pmt_list2(s_response_deallocate_channel, invocation_handle)))
- return;
-
- chan_info[channel].assigned_capacity = 0;
- chan_info[channel].owner = PMT_NIL;
-
- port->send(s_response_deallocate_channel,
- pmt_list2(invocation_handle,
- PMT_T));
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method if the incoming message to
- * usrp_server is to transmit a frame (cmd-xmit-raw-frame). The method
- * allocates enough memory to support a burst of packets which contain the frame
- * over the bus of the frame, sets the packet headers, and sends a signal to the
- * lower block for the data (packets) to be written to the bus.
- *
- * The \p port the command was sent on and the channel info (\p chan_info) of
- * the channel the frame is to be transmitted on are passed to ensure that the
- * caller owns the channel.
- *
- * The \p data parameter is in the format of a cmd-xmit-raw-frame signal.
- *
- * The properties
- */
-void usrp_server::handle_cmd_xmit_raw_frame(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
- size_t n_bytes, psize;
- long max_payload_len = transport_pkt::max_payload();
-
- pmt_t invocation_handle = pmt_nth(0, data);
- long channel = pmt_to_long(pmt_nth(1, data));
- const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes);
- long timestamp = pmt_to_long(pmt_nth(3, data));
- pmt_t properties = pmt_nth(4, data);
-
- // Ensure the channel is valid and the caller owns the port
- if(!check_valid(port, channel, chan_info,
- pmt_list2(s_response_xmit_raw_frame, invocation_handle)))
- return;
-
- // Read information from the properties of the packet
- bool carrier_sense = false;
- if(pmt_is_dict(properties)) {
-
- // Check if carrier sense is enabled for the frame
- if(pmt_t p_carrier_sense = pmt_dict_ref(properties,
- pmt_intern("carrier-sense"),
- PMT_NIL)) {
- if(pmt_eqv(p_carrier_sense, PMT_T))
- carrier_sense = true;
- }
- }
-
-
- // Determine the number of packets to allocate contiguous memory for
- // bursting over the USB and get a pointer to the memory to be used in
- // building the packets
- long n_packets =
- static_cast<long>(std::ceil(n_bytes / (double)max_payload_len));
-
- pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0);
-
- transport_pkt *pkts =
- (transport_pkt *) pmt_u8vector_writable_elements(v_packets, psize);
-
- for(int n=0; n < n_packets; n++) {
-
- long payload_len =
- std::min((long)(n_bytes-(n*max_payload_len)), (long)max_payload_len);
-
- if(n == 0) { // first packet gets start of burst flag and timestamp
-
- if(carrier_sense)
- pkts[n].set_header(pkts[n].FL_START_OF_BURST
- | pkts[n].FL_CARRIER_SENSE,
- channel, 0, payload_len);
- else
- pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
-
- pkts[n].set_timestamp(timestamp);
-
- } else {
- pkts[n].set_header(0, channel, 0, payload_len);
- pkts[n].set_timestamp(0xffffffff);
- }
-
- memcpy(pkts[n].payload(),
- (uint8_t *)samples+(max_payload_len * n),
- payload_len);
-
- }
-
-
- pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst
-
- if (verbose && 0)
- std::cout << "[USRP_SERVER] Received raw frame invocation: "
- << invocation_handle << std::endl;
-
- // The actual response to the write will be generated by a
- // s_response_usrp_write since we cannot determine whether to transmit was
- // successful until we hear from the lower layers.
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packets));
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method to parse incoming control/status
- * signals (cmd-to-control-channel).
- *
- * The \p port the command was sent on and the channel info (\p chan_info) of
- * the channel are passed to ensure that the caller owns the channel.
- *
- * The \p data parameter is in the format of a PMT list, where each element
- * follows the format of a control/status signal (i.e. op-ping-fixed).
- *
- * The method will parse all of the C/S commands included in \p data and place
- * the commands in to a lower level packet sent to the control channel. The
- * method will pack as many commands as possible in t oa single packet, and once
- * it is fill generate as many lower level packets as needed.
- *
- * Anything that needs to be returned to the sender of the signal (i.e. the
- * value of a register) will be generated by the parse_control_pkt() method as
- * the responses to the commands are read back from the USRP.
- */
-void usrp_server::handle_cmd_to_control_channel(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
-
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t subpackets = pmt_nth(1, data);
-
- long n_subpkts = pmt_length(subpackets);
- long curr_subpkt = 0;
-
- size_t psize;
- long payload_len = 0;
- long channel = CONTROL_CHAN;
-
- if(verbose)
- std::cout << "[USRP_SERVER] Handling " << n_subpkts << " commands\n";
-
- // The design of the following code is optimized for simplicity, not
- // performance. To performance optimize this code, the total size in bytes
- // needed for all of the CS packets is needed to allocate contiguous memory
- // which contains the USB packets for bursting over the bus. However to do
- // this the packets subpackets would need to be parsed twice and their sizes
- // would need to be determined.
- //
- // The approach taken is to keep parsing the subpackets and putting them in to
- // USB packets. Once the USB packet is full, a write is sent for it and
- // another packet is created.
- //
- // The subpacket creation methods will return false if the subpacket will not
- // fit in to the current USB packet. In these cases a new USB packet is
- // created and the old is sent.
-
- new_packet:
- // This code needs to become "smart" and only make a new packet when full
- pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
- transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize);
- payload_len = 0;
-
- pkt->set_header(0, channel, 0, payload_len);
- pkt->set_timestamp(0xffffffff);
-
- while(curr_subpkt < n_subpkts) {
-
- pmt_t subp = pmt_nth(curr_subpkt, subpackets);
- pmt_t subp_cmd = pmt_nth(0, subp);
- pmt_t subp_data = pmt_nth(1, subp);
-
- //--------- PING FIXED --------------//
- if(pmt_eq(subp_cmd, s_op_ping_fixed)) {
-
- long urid = pmt_to_long(pmt_nth(0, subp_data));
- long pingval = pmt_to_long(pmt_nth(1, subp_data));
-
- // USRP server sets request ID's to keep track of which application gets
- // what response back. To allow a full 6-bits for an RID to the user, we
- // keep a mapping and replace the RID's as the packets go in and out. If
- // there are no RID's available, the command is thrown away silently.
- long srid;
- if((srid = next_rid()) == -1)
- goto subpkt_bail;
-
- // We use a vector to store the owner of the ping request and will use it
- // to send the request on any RX port they own.
- d_rids[srid].owner = port->port_symbol();
- d_rids[srid].user_rid = urid;
-
- // Adds a ping after the previous command in the pkt
- if(!pkt->cs_ping(srid, pingval))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- // Return the RID
- d_rids[srid].owner = PMT_NIL;
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received ping command request"
- << " assigning RID " << srid << std::endl;
-
- }
-
- //----------- WRITE REG ---------------//
- if(pmt_eq(subp_cmd, s_op_write_reg)) {
-
- long reg_num = pmt_to_long(pmt_nth(0, subp_data));
- long val = pmt_to_long(pmt_nth(1, subp_data));
-
- if(!pkt->cs_write_reg(reg_num, val))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received write register request "
- << "("
- << "Reg: " << reg_num << ", "
- << "Val: " << val
- << ")\n";
- }
-
- //------- WRITE REG MASKED ----------//
- if(pmt_eq(subp_cmd, s_op_write_reg_masked)) {
-
- long reg_num = pmt_to_long(pmt_nth(0, subp_data));
- long val = pmt_to_long(pmt_nth(1, subp_data));
- long mask = pmt_to_long(pmt_nth(2, subp_data));
-
- if(!pkt->cs_write_reg_masked(reg_num, val, mask))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received write register masked request\n";
- }
-
- //------------ READ REG --------------//
- if(pmt_eq(subp_cmd, s_op_read_reg)) {
-
- long urid = pmt_to_long(pmt_nth(0, subp_data));
- long reg_num = pmt_to_long(pmt_nth(1, subp_data));
-
- long srid;
- if((srid = next_rid()) == -1)
- goto subpkt_bail;
-
- d_rids[srid].owner = port->port_symbol();
- d_rids[srid].user_rid = urid;
-
- if(!pkt->cs_read_reg(srid, reg_num))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- // Return the rid
- d_rids[srid].owner = PMT_NIL;
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received read register request"
- << " assigning RID " << srid << std::endl;
- }
-
- //------------ DELAY --------------//
- if(pmt_eq(subp_cmd, s_op_delay)) {
-
- long ticks = pmt_to_long(pmt_nth(0, subp_data));
-
- if(!pkt->cs_delay(ticks))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received delay request of "
- << ticks << " ticks\n";
- }
-
- //--------- I2C WRITE -----------//
- // FIXME: could check that byte count does not exceed 2^8 which
- // is the max length in the subpacket for # of bytes to read.
- if(pmt_eq(subp_cmd, s_op_i2c_write)) {
-
- long i2c_addr = pmt_to_long(pmt_nth(0, subp_data));
- pmt_t data = pmt_nth(1, subp_data);
-
- // Get a readable address to the data which also gives us the length
- size_t data_len;
- uint8_t *i2c_data = (uint8_t *) pmt_u8vector_writable_elements(data, data_len);
-
- // Make the USB packet
- if(!pkt->cs_i2c_write(i2c_addr, i2c_data, data_len))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received I2C write\n";
- }
-
- //----------- I2C Read -------------//
- if(pmt_eq(subp_cmd, s_op_i2c_read)) {
-
- long urid = pmt_to_long(pmt_nth(0, subp_data));
- long i2c_addr = pmt_to_long(pmt_nth(1, subp_data));
- long i2c_bytes = pmt_to_long(pmt_nth(2, subp_data));
-
- long srid;
- if((srid = next_rid()) == -1)
- goto subpkt_bail;
-
- d_rids[srid].owner = port->port_symbol();
- d_rids[srid].user_rid = urid;
-
- if(!pkt->cs_i2c_read(srid, i2c_addr, i2c_bytes))
- {
-
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- d_rids[srid].owner = PMT_NIL;
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received I2C read\n";
- }
-
- //--------- SPI WRITE -----------//
- if(pmt_eq(subp_cmd, s_op_spi_write)) {
-
- long enables = pmt_to_long(pmt_nth(0, subp_data));
- long format = pmt_to_long(pmt_nth(1, subp_data));
- long opt = pmt_to_long(pmt_nth(2, subp_data));
- pmt_t data = pmt_nth(3, subp_data);
-
- // Get a readable address to the data which also gives us the length
- size_t data_len;
- uint8_t *spi_data = (uint8_t *) pmt_u8vector_writable_elements(data, data_len);
-
- // Make the USB packet
- if(!pkt->cs_spi_write(enables, format, opt, spi_data, data_len))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received SPI write\n";
- }
-
- //--------- SPI READ -----------//
- if(pmt_eq(subp_cmd, s_op_spi_read)) {
-
- long urid = pmt_to_long(pmt_nth(0, subp_data));
- long enables = pmt_to_long(pmt_nth(1, subp_data));
- long format = pmt_to_long(pmt_nth(2, subp_data));
- long opt = pmt_to_long(pmt_nth(3, subp_data));
- long n_bytes = pmt_to_long(pmt_nth(4, subp_data));
-
- long srid;
- if((srid = next_rid()) == -1)
- goto subpkt_bail;
-
- d_rids[srid].owner = port->port_symbol();
- d_rids[srid].user_rid = urid;
-
- // Make the USB packet
- if(!pkt->cs_spi_read(srid, enables, format, opt, n_bytes))
- {
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- // Return the rid
- d_rids[srid].owner = PMT_NIL;
-
- goto new_packet;
- }
-
- if(verbose)
- std::cout << "[USRP_SERVER] Received SPI read\n";
- }
-
- subpkt_bail:
- curr_subpkt++;
-
- }
-
-
- // If the current packets length is > 0, we know there are subpackets that
- // need to be sent out still.
- if(pkt->payload_len() > 0)
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packet));
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is a
- * command to start reading samples from the USRP (cmd-start-recv-raw-samples).
- *
- * The \p port the command was sent on and the channel info (\p chan_info) of
- * the channel are passed to ensure that the caller owns the channel.
- *
- * The \p data parameter should be in the format of a cmd-start-recv-raw-samples
- * command where the first element in the list is an invocation handle, and the
- * second is the channel the signal generator wants to receive the samples on.
- */
-void
-usrp_server::handle_cmd_start_recv_raw_samples(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- long channel = pmt_to_long(pmt_nth(1, data));
-
- // Ensure the channel is valid and the caller owns the port
- if(!check_valid(port, channel, chan_info,
- pmt_list2(s_response_xmit_raw_frame, invocation_handle)))
- return;
-
- // Already started receiving samples? (another start before a stop)
- // Check the RX channel bitmask.
- if(d_rx_chan_mask & (1 << channel)) {
- port->send(s_response_recv_raw_samples,
- pmt_list5(invocation_handle,
- s_err_already_receiving,
- PMT_NIL,
- PMT_NIL,
- PMT_NIL));
- return;
- }
-
- // We only need to generate a 'start reading' command down to the
- // low level interface if no other channel is already reading
- //
- // We carry this over the CS interface because the lower level
- // interface does not care about the channel, we only demux it
- // at the usrp_server on responses.
- if(d_rx_chan_mask == 0) {
-
- if(verbose)
- std::cout << "[USRP_SERVER] Sending read request down to start recv\n";
-
- d_cs_usrp->send(s_cmd_usrp_start_reading, pmt_list1(invocation_handle));
- }
-
- d_rx_chan_mask |= 1<<channel;
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * stop receiving samples from the USRP (cmd-stop-recv-raw-samples).
- *
- * The \p port the command was sent on and the channel info (\p chan_info) of
- * the channel are passed to ensure that the caller owns the channel.
- *
- * The \p data parameter should be in the format of a cmd-stop-recv-raw-samples
- * command where the first element in the list is an invocation handle, and the
- * second is the channel the signal generator wants to stop receiving the
- * samples from.
- */
-void
-usrp_server::handle_cmd_stop_recv_raw_samples(
- mb_port_sptr port,
- std::vector<struct channel_info> &chan_info,
- pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- long channel = pmt_to_long(pmt_nth(1, data));
-
- // FIX ME : we have no responses to send an error...
- // Ensure the channel is valid and the caller owns the port
- //if(!check_valid(port, channel, chan_info,
- // pmt_list2(s_response_xmit_raw_frame, invocation_handle)))
- // return;
-
- // Remove this hosts bit from the receiver mask
- d_rx_chan_mask &= ~(1<<channel);
-
- // We only need to generate a 'start reading' command down to the
- // low level interface if no other channel is already reading
- //
- // We carry this over the CS interface because the lower level
- // interface does not care about the channel, we only demux it
- // at the usrp_server on responses.
- if(d_rx_chan_mask == 0) {
-
- if(verbose)
- std::cout << "[USRP_SERVER] Sending stop reading request down\n";
-
- d_cs_usrp->send(s_cmd_usrp_stop_reading, pmt_list1(invocation_handle));
- }
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method when an incoming signal is
- * generated to USRP server that contains raw samples from the USRP. This
- * method generates the response-recv-raw-samples signals that are the result of
- * a cmd-start-recv-raw-samples signal.
- *
- * The raw lower-level packet is extracted from \p data, where the format for \p
- * data is a PMT list. The PMT \p data list should contain an invocation handle
- * as the first element, the status of the lower-level read as the second
- * element, and a uniform vector representation of the packets as the third
- * element.
- *
- * The packet contains a channel field that the samples are destined to, and the
- * method determines where to send the samples based on this channel since each
- * channel has an associated port which allocated it.
- */
-void
-usrp_server::handle_response_usrp_read(pmt_t data)
-{
-
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t v_pkt = pmt_nth(2, data);
-
- size_t n_bytes;
- size_t ignore;
-
- if (d_fake_rx) {
-
- pmt_t pkt = pmt_nth(2, data);
-
- d_rx[0]->send(s_response_recv_raw_samples,
- pmt_list5(PMT_F,
- PMT_T,
- pkt,
- pmt_from_long(0xffff),
- PMT_NIL));
-
- return;
- }
-
- // Extract the packet and return appropriately
- transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, n_bytes);
-
- // The channel is used to find the port to pass the samples on
- long channel = pkt->chan();
- long payload_len = pkt->payload_len();
- long port;
-
- // Ignore packets which seem to have incorrect size or size 0
- if(payload_len > pkt->max_payload() || payload_len == 0)
- return;
-
- // If the packet is a C/S packet, parse it separately
- if(channel == CONTROL_CHAN) {
- parse_control_pkt(invocation_handle, pkt);
- return;
- }
-
- if((port = rx_port_index(d_chaninfo_rx[channel].owner)) == -1)
- return; // Don't know where to send the sample... possibility on abrupt close
-
- pmt_t v_samples = pmt_make_u8vector(payload_len, 0);
- uint8_t *samples = pmt_u8vector_writable_elements(v_samples, ignore);
-
- memcpy(samples, pkt->payload(), payload_len);
-
- // Build a properties dictionary to store things such as the RSSI
- pmt_t properties = pmt_make_dict();
-
- pmt_dict_set(properties,
- pmt_intern("rssi"),
- pmt_from_long(pkt->rssi()));
-
- if(pkt->overrun())
- pmt_dict_set(properties,
- pmt_intern("overrun"),
- PMT_T);
-
- if(pkt->underrun())
- pmt_dict_set(properties,
- pmt_intern("underrun"),
- PMT_T);
-
- d_rx[port]->send(s_response_recv_raw_samples,
- pmt_list6(invocation_handle,
- status,
- v_samples,
- pmt_from_long(pkt->timestamp()),
- pmt_from_long(channel),
- properties));
- return;
-}
-
-/*!
- * \brief Called by handle_response_usrp_read() when the incoming packet has a
- * channel of CONTROL_CHAN. This means that the incoming packet contains a
- * response for a command sent to the control channel, which this method will
- * parse.
- *
- * The \p pkt parameter is a pointer to the full packet (transport_pkt) in
- * memory.
- *
- * Given that all commands sent to the control channel that require responses
- * will carry an RID (request ID), the method will use the RID passed back with
- * the response to determine which port the response should be sent on.
- */
-void
-usrp_server::parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt)
-{
-
- long payload_len = pkt->payload_len();
- long curr_payload = 0;
- long port;
-
- // We dispatch based on the control packet type, however we can extract the
- // opcode and the length immediately which is consistent in all responses.
- //
- // Since each control packet can have multiple responses, we keep reading the
- // lengths of each subpacket until we reach the payload length.
- while(curr_payload < payload_len) {
-
- pmt_t sub_packet = pkt->read_subpacket(curr_payload);
- pmt_t op_symbol = pmt_nth(0, sub_packet);
-
- int len = pkt->cs_len(curr_payload);
-
- if(verbose)
- std::cout << "[USRP_SERVER] Parsing subpacket "
- << op_symbol << " ... length " << len << std::endl;
-
- //----------------- PING RESPONSE ------------------//
- if(pmt_eq(op_symbol, s_op_ping_fixed_reply)) {
-
- long srid = pmt_to_long(pmt_nth(1, sub_packet));
- pmt_t pingval = pmt_nth(2, sub_packet);
-
- long urid = d_rids[srid].user_rid;
-
- if(verbose)
- std::cout << "[USRP_SERVER] Found ping response "
- << "("
- << "URID: " << urid << ", "
- << "SRID: " << srid << ", "
- << "VAL: " << pingval
- << ")\n";
-
- // Do some bounds checking incase of bogus/corrupt responses
- if(srid > D_MAX_RID)
- return;
-
- pmt_t owner = d_rids[srid].owner;
-
- // Return the RID
- d_rids[srid].owner = PMT_NIL;
-
- // FIXME: should be 1 response for all subpackets here ?
- if((port = tx_port_index(owner)) != -1)
- d_tx[port]->send(s_response_from_control_channel,
- pmt_list4(invocation_handle,
- PMT_T,
- pmt_list2(s_op_ping_fixed_reply, // subp
- pmt_list2(pmt_from_long(urid),
- pingval)),
- pmt_from_long(pkt->timestamp())));
- }
-
- //----------------- READ REG RESPONSE ------------------//
- else if(pmt_eq(op_symbol, s_op_read_reg_reply)) {
-
- long srid = pmt_to_long(pmt_nth(1, sub_packet));
- pmt_t reg_num = pmt_nth(2, sub_packet);
- pmt_t reg_val = pmt_nth(3, sub_packet);
-
- long urid = d_rids[srid].user_rid;
-
- if(verbose)
- std::cout << "[USRP_SERVER] Found read register response "
- << "("
- << "URID: " << urid << ", "
- << "SRID: " << srid << ", "
- << "REG: " << reg_num << ", "
- << "VAL: " << reg_val
- << ")\n";
-
- // Do some bounds checking to avoid seg faults
- if(srid > D_MAX_RID)
- return;
-
- pmt_t owner = d_rids[srid].owner;
-
- // Return the RID
- d_rids[srid].owner = PMT_NIL;
-
- // FIXME: should be 1 response for all subpackets here ?
- if((port = tx_port_index(owner)) != -1)
- d_tx[port]->send(s_response_from_control_channel,
- pmt_list4(invocation_handle,
- PMT_T,
- pmt_list2(s_op_read_reg_reply, // subp
- pmt_list3(pmt_from_long(urid),
- reg_num,
- reg_val)),
- pmt_from_long(pkt->timestamp())));
- }
-
- //------------------ I2C READ REPLY -------------------//
- else if(pmt_eq(op_symbol, s_op_i2c_read_reply)) {
-
- long srid = pmt_to_long(pmt_nth(1, sub_packet));
- pmt_t i2c_addr = pmt_nth(2, sub_packet);
- pmt_t i2c_data = pmt_nth(3, sub_packet);
-
- long urid = d_rids[srid].user_rid;
-
- if(verbose)
- std::cout << "[USRP_SERVER] Found i2c read reply "
- << "("
- << "URID: " << urid << ", "
- << "SRID: " << srid << ", "
- << "Addr: " << i2c_addr << ", "
- << "Data: " << i2c_data
- << ")\n";
-
- // Do some bounds checking to avoid seg faults
- if(srid > D_MAX_RID)
- return;
-
- pmt_t owner = d_rids[srid].owner;
-
- // Return the RID
- d_rids[srid].owner = PMT_NIL;
-
- if((port = tx_port_index(owner)) != -1)
- d_tx[port]->send(s_response_from_control_channel,
- pmt_list4(invocation_handle,
- PMT_T,
- pmt_list2(s_op_i2c_read_reply,
- pmt_list3(pmt_from_long(urid),
- i2c_addr,
- i2c_data)),
- pmt_from_long(pkt->timestamp())));
- }
-
- //------------------ SPI READ REPLY -------------------//
- else if(pmt_eq(op_symbol, s_op_spi_read_reply)) {
-
- long srid = pmt_to_long(pmt_nth(1, sub_packet));
- pmt_t spi_data = pmt_nth(2, sub_packet);
-
- long urid = d_rids[srid].user_rid;
-
- if(verbose)
- std::cout << "[USRP_SERVER] Found SPI read reply "
- << "("
- << "URID: " << urid << ", "
- << "SRID: " << srid << ", "
- << "Data: " << spi_data
- << ")\n";
-
- // Bounds check the RID
- if(srid > D_MAX_RID)
- return;
-
- pmt_t owner = d_rids[srid].owner;
-
- // Return the RID
- d_rids[srid].owner = PMT_NIL;
-
- if((port = tx_port_index(owner)) != -1)
- d_tx[port]->send(s_response_from_control_channel,
- pmt_list4(invocation_handle,
- PMT_T,
- pmt_list2(s_op_spi_read_reply,
- pmt_list2(pmt_from_long(urid),
- spi_data)),
- pmt_from_long(pkt->timestamp())));
- }
-
- // Each subpacket has an unaccounted for 2 bytes which is the opcode
- // and the length field
- curr_payload += len + 2;
-
- // All subpackets are 32-bit aligned
- int align_offset = 4 - (curr_payload % 4);
-
- if(align_offset != 4)
- curr_payload += align_offset;
- }
-}
-
-/*!
- * \brief Used to recall all incoming signals that were deferred when USRP
- * server was in the initialization state.
- */
-void
-usrp_server::recall_defer_queue()
-{
-
- std::vector<mb_message_sptr> recall;
-
- while(!d_defer_queue.empty()) {
- recall.push_back(d_defer_queue.front());
- d_defer_queue.pop();
- }
-
- // Parse the messages that were queued while waiting for an open response
- for(int i=0; i < (int)recall.size(); i++)
- handle_message(recall[i]);
-
- return;
-}
-
-/*!
- * \brief Commonly called by any method which handles outgoing frames or control
- * packets to the USRP to check if the port on which the signal was sent owns
- * the channel the outgoing packet will be associated with. This helps ensure
- * that applications do not send data on other application's ports.
- *
- * The \p port parameter is the port symbol that the caller wishes to determine
- * owns the channel specified by \p chan_info.
- *
- * The \p signal_info parameter is a PMT list containing two elements: the
- * response signal to use if the permissions are invalid, and the invocation
- * handle that was passed. This allows the method to generate detailed failure
- * responses to signals without having to return some sort of structured
- * information which the caller must then parse and interpret to determine the
- * failure type.
- *
- * \returns true if \p port owns the channel specified by \p chan_info, false
- * otherwise.
- */
-bool
-usrp_server::check_valid(mb_port_sptr port,
- long channel,
- std::vector<struct channel_info> &chan_info,
- pmt_t signal_info)
-{
-
- pmt_t response_signal = pmt_nth(0, signal_info);
- pmt_t invocation_handle = pmt_nth(1, signal_info);
-
- // not a valid channel number?
- if(channel >= (long)chan_info.size() && channel != CONTROL_CHAN) {
- port->send(response_signal,
- pmt_list2(invocation_handle,
- s_err_channel_invalid));
-
- if(verbose)
- std::cout << "[USRP_SERVER] Invalid channel number for event "
- << response_signal << std::endl;
- return false;
- }
-
- // not the owner of the port?
- if(chan_info[channel].owner != port->port_symbol()) {
- port->send(response_signal,
- pmt_list2(invocation_handle,
- s_err_channel_permission_denied));
-
- if(verbose)
- std::cout << "[USRP_SERVER] Invalid permissions"
- << " for " << response_signal
- << " from " << port->port_symbol()
- << " proper owner is " << chan_info[channel].owner
- << " on channel " << channel
- << " invocation " << invocation_handle
- << std::endl;
- return false;
- }
-
- return true;
-}
-
-/*!
- * \brief Finds the next available RID for internal USRP server use with control
- * and status packets.
- *
- * \returns the next valid RID or -1 if no more RIDs are available.
- */
-long
-usrp_server::next_rid()
-{
- for(int i = 0; i < D_MAX_RID; i++)
- if(pmt_eqv(d_rids[i].owner, PMT_NIL))
- return i;
-
- if(verbose)
- std::cout << "[USRP_SERVER] No RIDs left\n";
- return -1;
-}
-
-/*!
- * \brief Called by handle_message() when USRP server gets a response that the
- * USRP was opened successfully to initialize the registers using the new
- * register read/write control packets.
- */
-void
-usrp_server::initialize_registers()
-{
- // We use handle_cmd_to_control_channel() to create the register writes using
- // PMT_NIL as the response port to tell usrp_server not to pass the response
- // up to any application.
- if(verbose)
- std::cout << "[USRP_SERVER] Initializing registers...\n";
-
- // RX mode to normal (0)
- set_register(FR_MODE, 0);
-
- // FPGA debugging?
- if(d_fpga_debug) {
- set_register(FR_DEBUG_EN, 1);
- // FIXME: need to figure out exact register writes to control daughterboard
- // pins that need to be written to
- } else {
- set_register(FR_DEBUG_EN, 0);
- }
-
- // Set the transmit sample rate divisor, which is 4-1
- set_register(FR_TX_SAMPLE_RATE_DIV, 3);
-
- // Dboard IO buffer and register settings
- set_register(FR_OE_0, (0xffff << 16) | 0x0000);
- set_register(FR_IO_0, (0xffff << 16) | 0x0000);
- set_register(FR_OE_1, (0xffff << 16) | 0x0000);
- set_register(FR_IO_1, (0xffff << 16) | 0x0000);
- set_register(FR_OE_2, (0xffff << 16) | 0x0000);
- set_register(FR_IO_2, (0xffff << 16) | 0x0000);
- set_register(FR_OE_3, (0xffff << 16) | 0x0000);
- set_register(FR_IO_3, (0xffff << 16) | 0x0000);
-
- // zero Tx side Auto Transmit/Receive regs
- set_register(FR_ATR_MASK_0, 0);
- set_register(FR_ATR_TXVAL_0, 0);
- set_register(FR_ATR_RXVAL_0, 0);
- set_register(FR_ATR_MASK_1, 0);
- set_register(FR_ATR_TXVAL_1, 0);
- set_register(FR_ATR_RXVAL_1, 0);
- set_register(FR_ATR_MASK_2, 0);
- set_register(FR_ATR_TXVAL_2, 0);
- set_register(FR_ATR_RXVAL_2, 0);
- set_register(FR_ATR_MASK_3, 0);
- set_register(FR_ATR_TXVAL_3, 0);
- set_register(FR_ATR_RXVAL_3, 0);
-
- // Configure TX mux, this is a hacked value
- set_register(FR_TX_MUX, 0x00000081);
-
- // Set the interpolation rate, which is the rate divided by 4, minus 1
- set_register(FR_INTERP_RATE, (d_interp_tx/4)-1);
-
- // Apparently this register changes again
- set_register(FR_TX_MUX, 0x00000981);
-
- // Set the receive sample rate divisor, which is 2-1
- set_register(FR_RX_SAMPLE_RATE_DIV, 1);
-
- // DC offset
- set_register(FR_DC_OFFSET_CL_EN, 0x0000000f);
-
- // Reset the DC correction offsets
- set_register(FR_ADC_OFFSET_0, 0);
- set_register(FR_ADC_OFFSET_1, 0);
-
- // Some hard-coded RX configuration
- set_register(FR_RX_FORMAT, 0x00000300);
- set_register(FR_RX_MUX, 1);
-
- // RX decimation rate is divided by two, then subtract 1
- set_register(FR_DECIM_RATE, (d_decim_rx/2)-1);
-
- // More hard coding
- set_register(FR_RX_MUX, 0x000e4e41);
-
- // Resetting RX registers
- set_register(FR_RX_PHASE_0, 0);
- set_register(FR_RX_PHASE_1, 0);
- set_register(FR_RX_PHASE_2, 0);
- set_register(FR_RX_PHASE_3, 0);
- set_register(FR_RX_FREQ_0, 0x28000000);
- set_register(FR_RX_FREQ_1, 0);
- set_register(FR_RX_FREQ_2, 0);
- set_register(FR_RX_FREQ_3, 0);
-
- // Enable debug bus
- set_register(FR_DEBUG_EN, 0xf);
- set_register(FR_OE_0, -1);
- set_register(FR_OE_1, -1);
- set_register(FR_OE_2, -1);
- set_register(FR_OE_3, -1);
-
- // DEBUGGING
- //check_register_initialization();
-}
-
-// FIXME: used for debugging to determine if all the registers are actually
-// being set correctly
-void
-usrp_server::check_register_initialization()
-{
- // RX mode to normal (0)
- read_register(FR_MODE);
-
- // FPGA debugging?
- if(d_fpga_debug) {
- read_register(FR_DEBUG_EN);
- // FIXME: need to figure out exact register writes to control daughterboard
- // pins that need to be written to
- } else {
- read_register(FR_DEBUG_EN);
- }
-
- // Set the transmit sample rate divisor, which is 4-1
- read_register(FR_TX_SAMPLE_RATE_DIV);
-
- // Dboard IO buffer and register settings
- read_register(FR_OE_0);
- read_register(FR_IO_0);
- read_register(FR_OE_1);
- read_register(FR_IO_1);
- read_register(FR_OE_2);
- read_register(FR_IO_2);
- read_register(FR_OE_3);
- read_register(FR_IO_3);
-
- // zero Tx side Auto Transmit/Receive regs
- read_register(FR_ATR_MASK_0);
- read_register(FR_ATR_TXVAL_0);
- read_register(FR_ATR_RXVAL_0);
- read_register(FR_ATR_MASK_1);
- read_register(FR_ATR_TXVAL_1);
- read_register(FR_ATR_RXVAL_1);
- read_register(FR_ATR_MASK_2);
- read_register(FR_ATR_TXVAL_2);
- read_register(FR_ATR_RXVAL_2);
- read_register(FR_ATR_MASK_3);
- read_register(FR_ATR_TXVAL_3);
- read_register(FR_ATR_RXVAL_3);
-
- // Configure TX mux, this is a hacked value
- read_register(FR_TX_MUX);
-
- // Set the interpolation rate, which is the rate divided by 4, minus 1
- read_register(FR_INTERP_RATE);
-
- // Apparently this register changes again
- read_register(FR_TX_MUX);
-
- // Set the receive sample rate divisor, which is 2-1
- read_register(FR_RX_SAMPLE_RATE_DIV);
-
- // DC offset
- read_register(FR_DC_OFFSET_CL_EN);
-
- // Reset the DC correction offsets
- read_register(FR_ADC_OFFSET_0);
- read_register(FR_ADC_OFFSET_1);
-
- // Some hard-coded RX configuration
- read_register(FR_RX_FORMAT);
- read_register(FR_RX_MUX);
-
- // RX decimation rate is divided by two, then subtract 1
- read_register(FR_DECIM_RATE);
-
- // More hard coding
- read_register(FR_RX_MUX);
-
- // Resetting RX registers
- read_register(FR_RX_PHASE_0);
- read_register(FR_RX_PHASE_1);
- read_register(FR_RX_PHASE_2);
- read_register(FR_RX_PHASE_3);
- read_register(FR_RX_FREQ_0);
- read_register(FR_RX_FREQ_1);
- read_register(FR_RX_FREQ_2);
- read_register(FR_RX_FREQ_3);
-}
-
-/*!
- * \brief Used to generate FPGA register write commands to reset all of the FPGA
- * registers to a value of 0.
- */
-void
-usrp_server::reset_all_registers()
-{
- for(int i=0; i<64; i++)
- set_register(i, 0);
-}
-
-/*!
- * \brief Used internally by USRP server to generate a control/status packet
- * which contains a register write.
- *
- * The \p reg parameter is the register number that the value \p val will be
- * written to.
- */
-void
-usrp_server::set_register(long reg, long val)
-{
- size_t psize;
- long payload_len = 0;
-
- pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
- transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize);
-
- pkt->set_header(0, CONTROL_CHAN, 0, payload_len);
- pkt->set_timestamp(0xffffffff);
-
- pkt->cs_write_reg(reg, val);
-
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(PMT_NIL,
- pmt_from_long(CONTROL_CHAN),
- v_packet));
-}
-
-/*!
- * \brief Used internally by USRP server to generate a control/status packet
- * which contains a register read. This is important to use internally so that
- * USRP server can bypass the use of RIDs with register reads, as they are not
- * needed and it would use up the finite number of RIDs available for use for
- * applications to receive responses.
- *
- * The \p reg parameter is the register number that the value should be read
- * from.
- */
-void
-usrp_server::read_register(long reg)
-{
- size_t psize;
- long payload_len = 0;
-
- pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
- transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize);
-
- pkt->set_header(0, CONTROL_CHAN, 0, payload_len);
- pkt->set_timestamp(0xffffffff);
-
- pkt->cs_read_reg(0, reg);
-
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(PMT_NIL,
- pmt_from_long(CONTROL_CHAN),
- v_packet));
-}
-
-REGISTER_MBLOCK_CLASS(usrp_server);
diff --git a/usrp/host/lib/inband/usrp_server.h b/usrp/host/lib/inband/usrp_server.h
deleted file mode 100644
index dd1825d57..000000000
--- a/usrp/host/lib/inband/usrp_server.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_SERVER_H
-#define INCLUDED_USRP_SERVER_H
-
-#include <mblock/mblock.h>
-#include <vector>
-#include <queue>
-#include <fstream>
-#include <usrp_inband_usb_packet.h>
-
-typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy
-
-/*!
- * \brief Implements the lowest-level mblock usb_interface to the USRP
- */
-class usrp_server : public mb_mblock
-{
-public:
-
- // our ports
- enum port_types {
- RX_PORT = 0,
- TX_PORT = 1
- };
- static const int N_PORTS = 4;
- std::vector<mb_port_sptr> d_tx, d_rx;
- mb_port_sptr d_cs;
- mb_port_sptr d_cs_usrp;
-
- static const int D_USB_CAPACITY = 32 * 1024 * 1024;
- static const int D_MAX_CHANNELS = 16;
- long d_ntx_chan;
- long d_nrx_chan;
-
- pmt_t d_usrp_dict;
-
- bool d_fpga_debug;
-
- long d_interp_tx;
- long d_decim_rx;
-
- // Keep track of the request IDs
- struct rid_info {
- pmt_t owner;
- long user_rid;
-
- rid_info() {
- owner = PMT_NIL;
- user_rid = 0;
- }
- };
-
- static const long D_MAX_RID = 64;
- std::vector<rid_info> d_rids;
-
- struct channel_info {
- long assigned_capacity; // the capacity currently assignedby the channel
- pmt_t owner; // port ID of the owner of the channel
-
- channel_info() {
- assigned_capacity = 0;
- owner = PMT_NIL;
- }
- };
-
- long d_rx_chan_mask; // A bitmask representing the channels in the
- // receiving state
-
- std::vector<struct channel_info> d_chaninfo_tx;
- std::vector<struct channel_info> d_chaninfo_rx;
-
- std::queue<mb_message_sptr> d_defer_queue;
-
- bool d_defer;
- bool d_opened;
-
- bool d_fake_rx;
-
-public:
- usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_server();
-
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
-protected:
- static int max_capacity() { return D_USB_CAPACITY; }
-
-private:
- void handle_cmd_allocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- void handle_cmd_to_control_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
- int rx_port_index(pmt_t port_id);
- int tx_port_index(pmt_t port_id);
- long current_capacity_allocation();
- void recall_defer_queue();
- void reset_channels();
- void handle_response_usrp_read(pmt_t data);
- bool check_valid(mb_port_sptr port, long channel, std::vector<struct channel_info> &chan_info, pmt_t signal_info);
- void parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt);
- long next_rid();
- void initialize_registers();
- void set_register(long reg, long val);
- void read_register(long reg);
- void check_register_initialization();
- void reset_all_registers();
-};
-
-#endif /* INCLUDED_USRP_SERVER_H */
diff --git a/usrp/host/lib/inband/usrp_server.mbh b/usrp/host/lib/inband/usrp_server.mbh
deleted file mode 100644
index ed7943fc3..000000000
--- a/usrp/host/lib/inband/usrp_server.mbh
+++ /dev/null
@@ -1,255 +0,0 @@
-;; -*- scheme -*- ; not really, but tells emacs how to format this
-;;
-;; Copyright 2007 Free Software Foundation, Inc.
-;;
-;; This file is part of GNU Radio
-;;
-;; GNU Radio is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-;;
-;; GNU Radio is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License along
-;; with this program; if not, write to the Free Software Foundation, Inc.,
-;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-;;
-
-;; ----------------------------------------------------------------
-;; This is an mblock header file
-;;
-;; The format is very much a work-in-progress.
-;; It'll be compiled to C++.
-;; ----------------------------------------------------------------
-
-;; In the outgoing messages described below, invocation-handle is an
-;; identifier provided by the client to tag the method invocation.
-;; The identifier will be returned with the response, to provide the
-;; client with a mechanism to match asynchronous responses with the
-;; commands that generate them. The value of the invocation-handle is
-;; opaque the the server, and is not required by the server to be
-;; unique.
-;;
-;; In the incoming messages described below, invocation-handle is the
-;; identifier provided by the client in the prompting invocation. The
-;; identifier is returned with the response, so that the client has a
-;; mechanism to match asynchronous responses with the commands that
-;; generated them.
-;;
-;; status is either #t, indicating success, or a symbol indicating an error.
-;; All symbol's names shall begin with %error-
-
-
-;; ----------------------------------------------------------------
-;; usrp-channel
-;;
-;; The protocol class is defined from the client's point-of-view.
-;; (The client port is unconjugated, the server port is conjugated.)
-
-(define-protocol-class usrp-channel
-
- (:outgoing
-
- (cmd-allocate-channel invocation-handle capacity-reservation)
-
- ;; The cmd-allocate-channel message requests that the server
- ;; allocates a logical channel in the FPGA for use.
- ;; capacity-reservation specifies the number of bytes/s of
- ;; interconnect capacity (USB or ethernet) to reserve for this
- ;; channel. (The reservation is just a sanity check, no OS
- ;; specific mechanism is used.)
-
- (cmd-deallocate-channel invocation-handle channel)
-
- ;; The integer channel specifies the channel to deallocate.
-
- )
-
- (:incoming
-
-
- (response-allocate-channel invocation-handle status channel)
-
- ;; If successful, a channel the specified capacity was allocated.
- ;; channel, an integer, indicates which channel was allocated.
-
- (response-deallocate-channel invocation-handle status)
-
- ;; If successful, the specified channel and associated interconnect
- ;; capacity were deallocated.
-
- )
- )
-
-;; ----------------------------------------------------------------
-;; usrp-low-level-cs
-;;
-;; The protocol class is defined from the client's point-of-view.
-;; (The client port is unconjugated, the server port is conjugated.)
-;;
-;; This defines a low level control and status interface to the usrp.
-;; This will probably be replaced (or at least augmented) with a
-;; higher level interface. For now, this will allow us to get on
-;; the air.
-;;
-;; The subpackets are lists containing the relevant parameters. The
-;; server will marshall them appropriately. Below is a list of
-;; subpackets. See inband-signaling-usb for details. The opcodes are
-;; symbols; unless otherwise indicated the remaining parameters are
-;; integers. rid values are limited to 3-bits.
-;;
-;; (op-ping-fixed rid ping-value)
-;; (op-ping-fixed-reply rid ping-value)
-;; (op-write-reg reg-number reg-value)
-;; (op-write-reg-masked reg-number reg-value mask-value)
-;; (op-read-reg rid reg-number)
-;; (op-read-reg-reply rid reg-number reg-value)
-;; (op-i2c-write i2c-addr u8-vec)
-;; (op-i2c-read rid i2c-addr nbytes)
-;; (op-i2c-read-reply rid i2c-addr u8-vec)
-;; (op-spi-write enables format opt-header-bytes u8-vec)
-;; (op-spi-read rid enables format opt-header-bytes nbytes)
-;; (op-spi-read-reply rid u8-vec)
-;; (op-delay ticks)
-
-
-(define-protocol-class usrp-low-level-cs
-
- (:outgoing
-
- (cmd-to-control-channel invocation-handle list-of-subpackets)
-
- )
-
- (:incoming
-
- (response-from-control-channel invocation-handle status list-of-subpackets timestamp)
-
- )
- )
-
-;; ----------------------------------------------------------------
-;; usrp-tx
-;;
-;; The protocol class is defined from the client's point-of-view.
-;; (The client port is unconjugated, the server port is conjugated.)
-
-(define-protocol-class usrp-tx
- (:include usrp-channel)
- (:include usrp-low-level-cs)
-
- (:outgoing
-
- (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties)
-
- ;; The argument channel must be an integer. It specifies the
- ;; channel on which the frame of samples will be be sent.
- ;;
- ;; samples must be a uniform numeric vector. The contents of the
- ;; sample vector is treated as opaque and is passed on to the FPGA
- ;; unmodified. It is the responsibility of the sender to ensure
- ;; that the binary format is sensible for the current FPGA
- ;; configuration.
- ;;
- ;; timestamp is a 32-bit integer that specifies the time at which
- ;; the first sample in samples shall be sent to the D/A converter.
- ;; The format and interpration of time is specified in the file
- ;; inband-signaling-usb
- )
-
- (:incoming
-
- (response-xmit-raw-frame invocation-handle status)
-
- ;; If successful, the samples of the associated frame have been
- ;; transmitted to the USRP. This message may be used to implement
- ;; Tx flow control. The client could for example implement a
- ;; policy of never having more than 4 unacknowledged
- ;; cmd-xmit-raw-frame's outstanding.
-
- )
- )
-
-;; ----------------------------------------------------------------
-;; usrp-rx
-;;
-;; The protocol class is defined from the client's point-of-view.
-;; (The client port is unconjugated, the server port is conjugated.)
-
-(define-protocol-class usrp-rx
- (:include usrp-channel)
- (:include usrp-low-level-cs)
-
- (:outgoing
-
- (cmd-start-recv-raw-samples invocation-handle channel)
-
- ;; The argument channel must be an integer. It specifies the
- ;; channel from which frames of samples will be be received. The
- ;; server will return response-recv-raw-samples messages until a
- ;; cmd-stop-recv-raw-samples message is received.
-
- (cmd-stop-recv-raw-samples invocation-handle channel)
-
- ;; The argument channel must be an integer. There is no reply to
- ;; this message.
-
- )
-
- (:incoming
-
- (response-recv-raw-samples invocation-handle status samples timestamp channel properties)
-
- ;; samples is a uniform numeric vector. The contents of the sample
- ;; vector is treated as opaque and is passed from the FPGA
- ;; unmodified. It is the responsibility of the receiver to decode
- ;; the binary format as appropriate for the current FPGA
- ;; configuration.
- ;;
- ;; timestamp is a 32-bit integer that specifies the time at which
- ;; the first sample in samples was received from the A/D converter.
- ;; The format and interpretation of time is as specified in the
- ;; file inband-signaling-usb.
- ;;
- ;; properties is a dictionary containing additional (key, value)
- ;; pairs associated with the reception of these samples. In
- ;; particular, the map may contain the Received Signal Strength
- ;; Indication (RSSI) reported by the front end at the time the
- ;; first sample was received from the A/D.
-
- )
- )
-
-
-;; ----------------------------------------------------------------
-;; usrp-server-cs
-;;
-;; Control and status port for usrp-server
-;;
-;; The protocol class is defined from the client's point-of-view.
-;; (The client port is unconjugated, the server port is conjugated.)
-
-(define-protocol-class usrp-server-cs
-
- (:outgoing
- (cmd-open invocation-handle which-usrp)
- (cmd-close invocation-handle)
- (cmd-max-capacity invocation-handle)
- (cmd-ntx-chan invocation-handle)
- (cmd-nrx-chan invocation-handle)
- (cmd-current-capacity-allocation invocation-handle)
- )
-
- (:incoming
- (response-open invocation-handle status)
- (response-close invocation-handle status)
- (response-max-capacity invocation-handle status capacity)
- (response-ntx-chan invocation-handle status ntx-chan)
- (response-nrx-chan invocation-handle status nrx-chan)
- (response-current-capacity-allocation invocation-handle status capacity)
- )
- )
diff --git a/usrp/host/lib/inband/usrp_tx.cc b/usrp/host/lib/inband/usrp_tx.cc
deleted file mode 100644
index 0d4a84619..000000000
--- a/usrp/host/lib/inband/usrp_tx.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_tx.h>
-#include <iostream>
-#include <usb.h>
-#include <mblock/class_registry.h>
-#include <usrp_inband_usb_packet.h>
-#include <fpga_regs_common.h>
-#include <usrp_standard.h>
-#include <stdio.h>
-
-#include <symbols_usrp_tx_cs.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-static const bool verbose = false;
-
-usrp_tx::usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_disk_write(false)
-{
- d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL);
-
- //d_disk_write=true;
-
- if(d_disk_write) {
- d_ofile.open("tx_data.dat",std::ios::binary|std::ios::out);
- d_cs_ofile.open("tx_cs.dat",std::ios::binary|std::ios::out);
- }
-}
-
-usrp_tx::~usrp_tx()
-{
- if(d_disk_write) {
- d_ofile.close();
- d_cs_ofile.close();
- }
-}
-
-void
-usrp_tx::initial_transition()
-{
-
-}
-
-/*!
- * \brief Handles incoming signals to to the m-block, wihch should only ever be
- * a single message: cmd-usrp-tx-write.
- */
-void
-usrp_tx::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal();
- pmt_t port_id = msg->port_id();
- pmt_t data = msg->data();
-
- // Theoretically only have 1 message to ever expect, but
- // want to make sure its at least what we want
- if(pmt_eq(port_id, d_cs->port_symbol())) {
-
- if(pmt_eqv(event, s_cmd_usrp_tx_write))
- write(data);
- }
-}
-
-/*!
- * \brief Performs the actual writing of data to the USB bus, called by
- * handle_message() when a cmd-usrp-tx-write signal is received.
- *
- * The \p data parameter is a PMT list which contains three mandatory elements,
- * in the following order: an invocation handle, a channel, and a uniform vector
- * of memory which contains the packets to be written to the bus.
- */
-void
-usrp_tx::write(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t channel = pmt_nth(1, data);
- pmt_t v_packets = pmt_nth(2, data);
- d_utx = boost::any_cast<usrp_standard_tx_sptr>(pmt_any_ref(pmt_nth(3, data)));
-
- size_t n_bytes;
- bool underrun; // this will need to go, as it is taken care of in the packet headers
-
- transport_pkt *pkts = (transport_pkt *) pmt_u8vector_writable_elements(v_packets, n_bytes);
-
- int ret = d_utx->write (pkts, n_bytes, &underrun);
-
- if (0 && underrun)
- fprintf(stderr, "uU");
-
- if (ret == (int) n_bytes) {
- if (verbose)
- std::cout << "[usrp_server] Write of " << n_bytes << " successful\n";
- // need to respond with the channel so the USRP server knows who to forward the result of
- // the write to by looking up the owner of the channel
- d_cs->send(s_response_usrp_tx_write,
- pmt_list3(invocation_handle, PMT_T, channel));
- }
- else {
- if (verbose)
- std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB bus\n";
- d_cs->send(s_response_usrp_tx_write,
- pmt_list3(invocation_handle, PMT_F, channel));
- }
-
- long n_packets =
- static_cast<long>(std::ceil(n_bytes / (double)transport_pkt::max_pkt_size()));
-
- for(int i=0; i < n_packets; i++) {
-
- if(d_disk_write) {
- if(pkts[i].chan() == CONTROL_CHAN)
- d_cs_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
- else
- d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
-
- d_cs_ofile.flush();
- d_ofile.flush();
- }
- }
-
-
- return;
-}
-
-REGISTER_MBLOCK_CLASS(usrp_tx);
diff --git a/usrp/host/lib/inband/usrp_tx.h b/usrp/host/lib/inband/usrp_tx.h
deleted file mode 100644
index d3a6f8b54..000000000
--- a/usrp/host/lib/inband/usrp_tx.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_TX_H
-#define INCLUDED_USRP_TX_H
-
-#include <mblock/mblock.h>
-#include <fstream>
-#include "usrp_standard.h"
-
-/*!
- * \brief Implements the low level usb interface to the USRP
- */
-class usrp_tx : public mb_mblock
-{
- mb_port_sptr d_cs;
- usrp_standard_tx_sptr d_utx;
-
- bool d_disk_write;
- std::ofstream d_ofile;
- std::ofstream d_cs_ofile;
-
- public:
- usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_tx();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- private:
- void write(pmt_t data);
-};
-
-
-#endif /* INCLUDED_USRP_TX_H */
-
diff --git a/usrp/host/lib/inband/usrp_tx_stub.cc b/usrp/host/lib/inband/usrp_tx_stub.cc
deleted file mode 100644
index c78b1a7b8..000000000
--- a/usrp/host/lib/inband/usrp_tx_stub.cc
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <iostream>
-#include <vector>
-#include <usb.h>
-#include <mblock/class_registry.h>
-#include <usrp_tx_stub.h>
-#include <usrp_inband_usb_packet.h>
-#include <fpga_regs_common.h>
-#include "usrp_standard.h"
-#include <stdio.h>
-#include <fstream>
-#include <usrp_rx_stub.h>
-
-#include <symbols_usrp_tx_cs.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-static const bool verbose = false;
-
-usrp_tx_stub::usrp_tx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_disk_write(false)
-{
- d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL);
-
- //d_disk_write=true;
-
- if(d_disk_write) {
- d_ofile.open("tx_stub_data.dat",std::ios::binary|std::ios::out);
- d_cs_ofile.open("tx_stub_cs.dat",std::ios::binary|std::ios::out);
- }
-}
-
-usrp_tx_stub::~usrp_tx_stub()
-{
- if(d_disk_write) {
- d_ofile.close();
- d_cs_ofile.close();
- }
-}
-
-void
-usrp_tx_stub::initial_transition()
-{
-
-}
-
-void
-usrp_tx_stub::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal();
- pmt_t port_id = msg->port_id();
- pmt_t data = msg->data();
-
- // Theoretically only have 1 message to ever expect, but
- // want to make sure its at least what we want
- if(pmt_eq(port_id, d_cs->port_symbol())) {
-
- if(pmt_eqv(event, s_cmd_usrp_tx_write))
- write(data);
- }
-}
-
-void
-usrp_tx_stub::write(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t channel = pmt_nth(1, data);
- pmt_t v_packets = pmt_nth(2, data);
- d_utx = boost::any_cast<usrp_standard_tx *>(pmt_any_ref(pmt_nth(3, data)));
-
- size_t n_bytes;
-
- transport_pkt *pkts = (transport_pkt *) pmt_u8vector_writable_elements(v_packets, n_bytes);
- long n_packets = static_cast<long>(std::ceil(n_bytes / (double)transport_pkt::max_pkt_size()));
-
- // Parse the packets looking for C/S packets and dump them to a disk if
- // necessary
- for(long i=0; i<n_packets; i++) {
-
- if(d_disk_write) {
- if(pkts[i].chan() == CONTROL_CHAN)
- d_cs_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
- else
- d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
-
- d_cs_ofile.flush();
- d_ofile.flush();
- }
-
- if(pkts[i].chan() == CONTROL_CHAN)
- parse_cs(invocation_handle, pkts[i]);
- }
-
- d_cs->send(s_response_usrp_tx_write,
- pmt_list3(invocation_handle, PMT_T, channel));
-
- return;
-}
-
-void
-usrp_tx_stub::parse_cs(pmt_t invocation_handle, transport_pkt pkt)
-{
-
- long payload_len = pkt.payload_len();
- long curr_payload = 0;
-
- size_t ignore;
-
- // There is the possibility that the responses for a single USB packet full of
- // CS packets will not fit back in a single USB packet, considering some
- // responses are greater than their commands (read registers).
- new_packet:
- pmt_t v_pkt = pmt_make_u8vector(sizeof(transport_pkt), 0);
-
- transport_pkt *q_pkt =
- (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore);
-
- q_pkt->set_header(0, CONTROL_CHAN, 0, 0);
- q_pkt->set_timestamp(0xffffffff);
-
- // We dispatch based on the control packet type, however we can extract the
- // opcode and the length immediately which is consistent in all responses.
- //
- // Since each control packet can have multiple responses, we keep reading the
- // lengths of each subpacket until we reach the payload length.
- while(curr_payload < payload_len) {
-
- pmt_t sub_packet = pkt.read_subpacket(curr_payload);
- pmt_t op_symbol = pmt_nth(0, sub_packet);
-
- int len = pkt.cs_len(curr_payload);
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Parsing subpacket "
- << op_symbol << " ... length " << len << std::endl;
-
- //----------------- PING FIXED ------------------//
- if(pmt_eq(op_symbol, s_op_ping_fixed)) {
-
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
- long pingval = pmt_to_long(pmt_nth(2, sub_packet));
-
- // Generate a reply and put it in the queue for the RX stub to read
- if(!q_pkt->cs_ping_reply(rid, pingval))
- goto new_packet;
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Generated ping response "
- << "("
- << "RID: " << rid << ", "
- << "VAL: " << pingval
- << ")\n";
- }
-
- //----------------- READ REG ------------------//
- if(pmt_eq(op_symbol, s_op_read_reg)) {
-
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
- long reg_num = pmt_to_long(pmt_nth(2, sub_packet));
- long reg_val = 0xdeef;
-
- // Generate a reply and put it in the queue for the RX stub to read
- if(!q_pkt->cs_read_reg_reply(rid, reg_num, reg_val))
- goto new_packet;
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Generated read register response "
- << "("
- << "RID: " << rid << ", "
- << "REG: " << reg_num << ", "
- << "VAL: " << reg_val
- << ")\n";
- }
-
- //----------------- DELAY ------------------//
- if(pmt_eq(op_symbol, s_op_delay)) {
-
- long ticks = pmt_to_long(pmt_nth(1, sub_packet));
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received delay command "
- << "("
- << "Ticks: " << ticks
- << ")\n";
- }
-
- //----------------- WRITE REG ------------------//
- if(pmt_eq(op_symbol, s_op_write_reg)) {
-
- pmt_t reg_num = pmt_nth(1, sub_packet);
- pmt_t reg_val = pmt_nth(2, sub_packet);
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received write register command "
- << "("
- << "RegNum: " << reg_num << ", "
- << "Val: " << reg_val
- << ")\n";
- }
-
- //----------------- WRITE REG MASK ---------------//
- if(pmt_eq(op_symbol, s_op_write_reg_masked)) {
-
- pmt_t reg_num = pmt_nth(1, sub_packet);
- pmt_t reg_val = pmt_nth(2, sub_packet);
- pmt_t mask = pmt_nth(3, sub_packet);
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received write register command "
- << "("
- << "RegNum: " << reg_num << ", "
- << "Val: " << reg_val << ", "
- << "Mask: " << mask
- << ")\n";
- }
-
- //---------------- I2C WRITE ------------------//
- if(pmt_eq(op_symbol, s_op_i2c_write)) {
- pmt_t i2c_addr = pmt_nth(1, sub_packet);
- pmt_t i2c_data = pmt_nth(2, sub_packet);
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received i2c write command "
- << "("
- << "Addr: " << i2c_addr << ", "
- << "Data: " << i2c_data
- << ")\n";
- }
-
- //---------------- I2C READ ------------------//
- if(pmt_eq(op_symbol, s_op_i2c_read)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
- long i2c_addr = pmt_to_long(pmt_nth(2, sub_packet));
- long i2c_bytes = pmt_to_long(pmt_nth(3, sub_packet));
-
- // Create data to place as a response, filled with 0xff
- size_t ignore;
- pmt_t i2c_data = pmt_make_u8vector(i2c_bytes, 0xff);
- uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(i2c_data, ignore);
-
- // Generate a reply and put it in the queue for the RX stub to read
- if(!q_pkt->cs_i2c_read_reply(rid, i2c_addr, w_data, i2c_bytes))
- goto new_packet;
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received i2c read "
- << "("
- << "RID: " << rid << ", "
- << "Addr: " << i2c_addr << ", "
- << "Bytes: " << i2c_bytes
- << ")\n";
- }
-
- //---------------- SPI WRITE ------------------//
- if(pmt_eq(op_symbol, s_op_spi_write)) {
- long enables = pmt_to_long(pmt_nth(1, sub_packet));
- long format = pmt_to_long(pmt_nth(2, sub_packet));
- long opt = pmt_to_long(pmt_nth(3, sub_packet));
- pmt_t data = pmt_nth(4, sub_packet);
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received spi write command "
- << "("
- << "Enables: " << enables << ", "
- << "Format: " << format << ", "
- << "Options: " << opt << ", "
- << "Data: " << data
- << ")\n";
- }
-
- //---------------- SPI READ ------------------//
- if(pmt_eq(op_symbol, s_op_spi_read)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
- long enables = pmt_to_long(pmt_nth(2, sub_packet));
- long format = pmt_to_long(pmt_nth(3, sub_packet));
- long opt = pmt_to_long(pmt_nth(4, sub_packet));
- long n_bytes = pmt_to_long(pmt_nth(5, sub_packet));
-
- // Create data to place as a fake response
- size_t ignore;
- pmt_t spi_data = pmt_make_u8vector(n_bytes, 0xff);
- uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(spi_data, ignore);
-
- // Generate a reply and put it in the queue for the RX stub to read
- if(!q_pkt->cs_spi_read_reply(rid, w_data, n_bytes))
- goto new_packet;
-
- if(verbose)
- std::cout << "[USRP_TX_STUB] Received spi read command "
- << "("
- << "RID: " << rid << ", "
- << "Enables: " << enables << ", "
- << "Format: " << format << ", "
- << "Options: " << opt << ", "
- << "Bytes: " << n_bytes
- << ")\n";
-
- }
-
- // Each subpacket has an unaccounted for 2 bytes which is the opcode
- // and the length field
- curr_payload += len + 2;
-
- // All subpackets are 32-bit aligned
- int align_offset = 4 - (curr_payload % 4);
-
- if(align_offset != 4)
- curr_payload += align_offset;
-
- }
-
- // If the packet has data in the payload, it needs queued
- if(q_pkt->payload_len() > 0)
- d_cs_queue.push(pmt_list2(invocation_handle, v_pkt));
-
- return;
-}
-
-REGISTER_MBLOCK_CLASS(usrp_tx_stub);
diff --git a/usrp/host/lib/inband/usrp_tx_stub.h b/usrp/host/lib/inband/usrp_tx_stub.h
deleted file mode 100644
index b81037ad7..000000000
--- a/usrp/host/lib/inband/usrp_tx_stub.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_TX_STUB_H
-#define INCLUDED_USRP_TX_STUB_H
-
-#include <mblock/mblock.h>
-#include <vector>
-#include "usrp_standard.h"
-#include <fstream>
-#include <usrp_inband_usb_packet.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-/*!
- * \brief Implements the low level usb interface to the USRP
- */
-class usrp_tx_stub : public mb_mblock
-{
- public:
-
- mb_port_sptr d_cs;
- usrp_standard_tx* d_utx;
-
- std::ofstream d_ofile;
- std::ofstream d_cs_ofile;
-
- bool d_disk_write;
-
- public:
- usrp_tx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_tx_stub();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
-
- private:
- void write(pmt_t data);
- void parse_cs(pmt_t invocation_handle, transport_pkt pkt);
-
-};
-
-
-#endif /* INCLUDED_USRP_TX_STUB_H */
-
diff --git a/usrp/host/lib/inband/usrp_usb_interface.cc b/usrp/host/lib/inband/usrp_usb_interface.cc
deleted file mode 100644
index fb7109a5a..000000000
--- a/usrp/host/lib/inband/usrp_usb_interface.cc
+++ /dev/null
@@ -1,601 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <usrp_usb_interface.h>
-
-#include <iostream>
-#include <vector>
-#include <usb.h>
-#include <mblock/class_registry.h>
-#include <usrp_inband_usb_packet.h>
-#include <fpga_regs_common.h>
-#include "usrp_rx.h"
-#include <usrp_rx_stub.h>
-#include "usrp_tx.h"
-#include "usrp_standard.h"
-#include <stdio.h>
-#include <usrp_dbid.h>
-
-typedef usrp_inband_usb_packet transport_pkt;
-
-#include <symbols_usrp_interface_cs.h>
-#include <symbols_usrp_tx_cs.h>
-#include <symbols_usrp_rx_cs.h>
-static pmt_t s_shutdown = pmt_intern("%shutdown");
-
-static const bool verbose = false;
-
-
-/*!
- * \brief Initializes the USB interface m-block.
- *
- * The \p user_arg should be a PMT dictionary which can contain optional
- * arguments for the block, such as the decimatoin and interpolation rate.
- */
-usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
- : mb_mblock(rt, instance_name, user_arg),
- d_fake_usrp(false),
- d_rx_reading(false),
- d_interp_tx(128),
- d_decim_rx(128),
- d_rf_freq(-1),
- d_rbf("inband_tx_rx.rbf")
-{
- // Dictionary for arguments to all of the components
- pmt_t usrp_dict = user_arg;
-
- // Default TX/RX interface
- std::string tx_interface = "usrp_tx";
- std::string rx_interface = "usrp_rx";
-
- if (pmt_is_dict(usrp_dict)) {
-
- // The 'fake-usrp' key enables the TX and RX stubs if PMT_T
- if(pmt_t fake_usrp = pmt_dict_ref(usrp_dict,
- pmt_intern("fake-usrp"),
- PMT_NIL)) {
- if(pmt_eqv(fake_usrp, PMT_T)) {
- tx_interface = "usrp_tx_stub";
- rx_interface = "usrp_rx_stub";
- d_fake_usrp=true;
- }
- }
-
- // Read the TX interpolations
- if(pmt_t interp_tx = pmt_dict_ref(usrp_dict,
- pmt_intern("interp-tx"),
- PMT_NIL)) {
- if(!pmt_eqv(interp_tx, PMT_NIL))
- d_interp_tx = pmt_to_long(interp_tx);
- }
-
- // Read the RX decimation rate
- if(pmt_t decim_rx = pmt_dict_ref(usrp_dict,
- pmt_intern("decim-rx"),
- PMT_NIL)) {
- if(!pmt_eqv(decim_rx, PMT_NIL))
- d_decim_rx = pmt_to_long(decim_rx);
- }
-
- // Read the RBF
- if(pmt_t rbf = pmt_dict_ref(usrp_dict,
- pmt_intern("rbf"),
- PMT_NIL)) {
- if(!pmt_eqv(rbf, PMT_NIL))
- d_rbf = pmt_symbol_to_string(rbf);
- }
-
- // The RF center frequency
- if(pmt_t rf_freq = pmt_dict_ref(usrp_dict,
- pmt_intern("rf-freq"),
- PMT_NIL)) {
- if(!pmt_eqv(rf_freq, PMT_NIL))
- d_rf_freq = pmt_to_double(rf_freq);
- }
- }
-
- if (verbose) {
- std::cout << "[USRP_USB_INTERFACE] Setting USRP RBF to "
- << d_rbf << std::endl;
-
- std::cout << "[USRP_USB_INTERFACE] Setting TX interpolation to "
- << d_interp_tx << std::endl;
-
- std::cout << "[USRP_USB_INTERFACE] Setting RX interpolation to "
- << d_decim_rx << std::endl;
-
- std::cout << "[USRP_USB_INTERFACE] Using TX interface: "
- << tx_interface << "\n";
-
- std::cout << "[USRP_USB_INTERFACE] Using RX interface: "
- << rx_interface << "\n";
-
- }
-
- d_cs = define_port("cs", "usrp-interface-cs", true, mb_port::EXTERNAL);
- d_rx_cs = define_port("rx_cs", "usrp-rx-cs", false, mb_port::INTERNAL);
- d_tx_cs = define_port("tx_cs", "usrp-tx-cs", false, mb_port::INTERNAL);
-
- // Connect to TX and RX
- define_component("tx", tx_interface, usrp_dict);
- define_component("rx", rx_interface, usrp_dict);
- connect("self", "rx_cs", "rx", "cs");
- connect("self", "tx_cs", "tx", "cs");
-
- // FIXME: the code should query the FPGA to retrieve the number of channels and such
- d_ntx_chan = 2;
- d_nrx_chan = 2;
-}
-
-usrp_usb_interface::~usrp_usb_interface()
-{
-
-}
-
-void
-usrp_usb_interface::initial_transition()
-{
-
-}
-
-/*!
- * \brief Handles all incoming signals to the block from the lowest m-blocks
- * which read/write to the bus, or the higher m-block which is the USRP server.
- */
-void
-usrp_usb_interface::handle_message(mb_message_sptr msg)
-{
- pmt_t event = msg->signal(); // the "name" of the message
- pmt_t port_id = msg->port_id(); // which port it came in on
- pmt_t data = msg->data();
- pmt_t invocation_handle;
-
- if (pmt_eq(event, s_shutdown)) // ignore (for now)
- return;
-
- //------------- CONTROL / STATUS -------------//
- if (pmt_eq(port_id, d_cs->port_symbol())) {
-
- //------------ OPEN --------------//
- if (pmt_eq(event, s_cmd_usrp_open)){
- handle_cmd_open(data);
- return;
- }
- //----------- CLOSE -------------//
- else if (pmt_eq(event, s_cmd_usrp_close)) {
- handle_cmd_close(data);
- return;
- }
- //---------- NTX CHAN ----------//
- else if (pmt_eq(event, s_cmd_usrp_ntx_chan)) {
- invocation_handle = pmt_nth(0, data);
- d_cs->send(s_response_usrp_ntx_chan,
- pmt_list2(invocation_handle,
- pmt_from_long(d_ntx_chan)));
- return;
- }
- //---------- NRX CHAN ----------//
- else if (pmt_eq(event, s_cmd_usrp_nrx_chan)) {
- invocation_handle = pmt_nth(0, data);
- d_cs->send(s_response_usrp_nrx_chan,
- pmt_list2(invocation_handle,
- pmt_from_long(d_nrx_chan)));
- return;
- }
- //------------ WRITE -----------//
- else if(pmt_eq(event, s_cmd_usrp_write)) {
- handle_cmd_write(data);
- return;
- }
- //-------- START READING --------//
- else if(pmt_eq(event, s_cmd_usrp_start_reading)) {
- handle_cmd_start_reading(data);
- return;
- }
- //-------- STOP READING --------//
- else if(pmt_eq(event, s_cmd_usrp_stop_reading)) {
- handle_cmd_stop_reading(data);
- return;
- }
-
- goto unhandled;
- }
-
- //---------------- RX ------------------//
- if (pmt_eq(port_id, d_rx_cs->port_symbol())) {
-
- // Relay reads back up
- if(pmt_eq(event, s_response_usrp_rx_read)) {
- d_cs->send(s_response_usrp_read, data);
- return;
- }
-
- goto unhandled;
- }
-
- //---------------- TX ------------------//
- if (pmt_eq(port_id, d_tx_cs->port_symbol())) {
-
- if(pmt_eq(event, s_response_usrp_tx_write)) {
-
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t channel = pmt_nth(2, data);
-
- d_cs->send(s_response_usrp_write,
- pmt_list3(invocation_handle,
- status,
- channel));
-
- return;
- }
-
- goto unhandled;
- }
-
- unhandled:
- std::cout << "[USRP_USB_INTERFACE] unhandled msg: " << msg << std::endl;
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * open a USB connection to the USRP (cmd-usrp-open).
- *
- * The \p data parameter is a PMT list, where the elements are an invocation
- * handle and the USRP number.
- */
-void
-usrp_usb_interface::handle_cmd_open(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- long which_usrp = pmt_to_long(pmt_nth(1, data));
- pmt_t reply_data;
-
- if(d_fake_usrp) {
- d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
- return;
- }
-
- if (verbose)
- std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << which_usrp << "\n";
-
- // Open up a standard RX and TX for communication with the USRP
-
- d_utx = usrp_standard_tx::make(which_usrp,
- d_interp_tx,
- 1, // 1 channel
- -1, // mux
- 4096, // USB block size
- 16, // nblocks for async transfers
- d_rbf
- );
-
- if(d_utx==0) {
- if (verbose)
- std::cout << "[USRP_USB_INTERFACE] Failed to open TX\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
-
- // Perform TX daughterboard tuning
- double target_freq;
- unsigned int mux;
- int tgain, rgain;
- float input_rate;
- bool ok;
- usrp_tune_result r;
-
- // Cast to usrp_basic and then detect daughterboards
- d_ub_tx = d_utx;
- usrp_subdev_spec tspec = pick_tx_subdevice();
- db_base_sptr tsubdev = d_ub_tx->selected_subdev(tspec);
-
- // Set the TX mux value
- mux = d_utx->determine_tx_mux_value(tspec);
- d_utx->set_mux(mux);
-
- // Set the TX gain and determine rate
- tgain = tsubdev->gain_max();
- tsubdev->set_gain(tgain);
- input_rate = d_ub_tx->converter_rate() / d_utx->interp_rate();
-
- // Perform the actual tuning, if no frequency specified then pick
- if(d_rf_freq==-1)
- target_freq = tsubdev->freq_min()+((tsubdev->freq_max()-tsubdev->freq_min())/2.0);
- else
- target_freq = d_rf_freq;
- ok = d_utx->tune(tsubdev->which(), tsubdev, target_freq, &r);
- tsubdev->set_enable(true);
-
- if(verbose) {
- printf("TX Subdevice name is %s\n", tsubdev->name().c_str());
- printf("TX Subdevice freq range: (%g, %g)\n",
- tsubdev->freq_min(), tsubdev->freq_max());
- printf("mux: %#08x\n", mux);
- printf("target_freq: %f\n", target_freq);
- printf("ok: %s\n", ok ? "true" : "false");
- printf("gain: %d\n", tgain);
- printf("r.baseband_freq: %f\n", r.baseband_freq);
- printf("r.dxc_freq: %f\n", r.dxc_freq);
- printf("r.residual_freq: %f\n", r.residual_freq);
- printf("r.inverted: %d\n", r.inverted);
- }
-
- if(!ok) {
- std::cerr << "[USRP_USB_INTERFACE] Failed to set center frequency on TX\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
-
- d_utx->start();
-
- if (verbose)
- std::cout << "[USRP_USB_INTERFACE] Setup TX channel\n";
-
- d_urx =
- usrp_standard_rx::make (which_usrp,
- d_decim_rx,
- 1, // nchan
- -1, // mux
- 0, // set blank mode to start
- 4096, // USB block size
- 16, // number of blocks for async transfers
- d_rbf);
-
- if(!d_urx) {
- if (verbose)
- std::cout << "[usrp_server] Failed to open RX\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
-
- // Cast to usrp_basic and then detect daughterboards
- d_ub_rx = d_urx;
- usrp_subdev_spec rspec = pick_rx_subdevice();
- db_base_sptr rsubdev = d_ub_rx->selected_subdev(rspec);
-
- // Set the RX mux value
- mux = d_urx->determine_rx_mux_value(rspec);
- d_urx->set_mux(mux);
-
- // Set the RX gain and determine rate
- rgain = rsubdev->gain_max()/2.0;
- rsubdev->set_gain(rgain);
- input_rate = d_ub_rx->converter_rate() / d_urx->decim_rate();
-
- ok = d_urx->tune(rsubdev->which(), rsubdev, target_freq, &r);
- rsubdev->set_enable(true);
-
- if(verbose) {
- printf("RX Subdevice name is %s\n", rsubdev->name().c_str());
- printf("RX Subdevice freq range: (%g, %g)\n",
- rsubdev->freq_min(), rsubdev->freq_max());
- printf("mux: %#08x\n", mux);
- printf("target_freq: %f\n", target_freq);
- printf("ok: %s\n", ok ? "true" : "false");
- printf("gain: %d\n", rgain);
- printf("r.baseband_freq: %f\n", r.baseband_freq);
- printf("r.dxc_freq: %f\n", r.dxc_freq);
- printf("r.residual_freq: %f\n", r.residual_freq);
- printf("r.inverted: %d\n", r.inverted);
- }
-
- if(!ok) {
- std::cerr << "[USRP_USB_INTERFACE] Failed to set center frequency on RX\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
-
- if (verbose)
- std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n";
-
-// d_utx->_write_fpga_reg(FR_DEBUG_EN,0xf);
-// d_utx->_write_oe(0, 0xffff, 0xffff);
-// d_urx->_write_oe(0, 0xffff, 0xffff);
-// d_utx->_write_oe(1, 0xffff, 0xffff);
-// d_urx->_write_oe(1, 0xffff, 0xffff);
-
- d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * write data to the USB bus (cmd-usrp-write).
- *
- * The \p data parameter is a PMT list containing 3 mandatory elements in the
- * following order: an invocation handle, channel, and a uniform vector
- * representation of the packets.
- */
-void
-usrp_usb_interface::handle_cmd_write(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t channel = pmt_nth(1, data);
- pmt_t pkts = pmt_nth(2, data);
-
- pmt_t tx_handle = pmt_make_any(d_utx);
-
- d_tx_cs->send(s_cmd_usrp_tx_write,
- pmt_list4(invocation_handle,
- channel,
- pkts,
- tx_handle));
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * start reading data from the USB bus (cmd-usrp-start-reading).
- *
- * The \p data parameter is a PMT list with a single element: an invocation
- * handle which can be returned with the response.
- */
-void
-usrp_usb_interface::handle_cmd_start_reading(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
-
- if(verbose)
- std::cout << "[USRP_USB_INTERFACE] Starting RX...\n";
-
- if(!d_fake_usrp)
- d_urx->start();
-
- pmt_t rx_handle = pmt_make_any(d_urx);
-
- d_rx_cs->send(s_cmd_usrp_rx_start_reading, pmt_list2(PMT_NIL, rx_handle));
-
- d_rx_reading = true;
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * stop reading data from the USB bus (cmd-usrp-stop-reading).
- *
- * The \p data parameter is a PMT list with a single element: an invocation
- * handle which can be returned with the response.
- */
-void
-usrp_usb_interface::handle_cmd_stop_reading(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
-
- if(!d_fake_usrp) {
- if(verbose)
- std::cout << "[USRP_USB_INTERFACE] Stopping RX...\n";
- usrp_rx_stop = true;
-
- // Used to allow a read() being called by a lower layer to complete before
- // stopping, else there can be partial data left on the bus and can generate
- // errors.
- while(usrp_rx_stop) {usleep(1);}
- d_urx->stop();
- }
- else {
- if(verbose)
- std::cout << "[USRP_USB_INTERFACE] Stopping fake RX...\n";
- usrp_rx_stop_stub = true; // extern to communicate with stub to wait
- }
-
- d_rx_reading = false;
-
- return;
-}
-
-/*!
- * \brief Called by the handle_message() method when the incoming signal is to
- * close the USB connection to the USRP.
- *
- * The \p data parameter is a PMT list with a single element: an invocation
- * handle which can be returned with the response.
- */
-void
-usrp_usb_interface::handle_cmd_close(pmt_t data)
-{
- pmt_t invocation_handle = pmt_nth(0, data);
-
- if(d_rx_reading)
- handle_cmd_stop_reading(PMT_NIL);
-
- if(d_fake_usrp) {
- d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
- return;
- }
-
- if (verbose)
- std::cout << "[USRP_USB_INTERFACE] Handling close request for USRP\n";
-
- d_utx.reset();
- d_urx.reset();
-
- d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
-
- // FIXME This seems like a _very_ strange place to be calling shutdown_all.
- // That decision should be left to high-level code, not low-level code like this.
- shutdown_all(PMT_T);
-}
-
-usrp_subdev_spec
-usrp_usb_interface::pick_rx_subdevice()
-{
- int dbids[] = {
- USRP_DBID_FLEX_400_RX,
- USRP_DBID_FLEX_900_RX,
- USRP_DBID_FLEX_1200_RX,
- USRP_DBID_FLEX_2400_RX,
- USRP_DBID_TV_RX,
- USRP_DBID_TV_RX_REV_2,
- USRP_DBID_DBS_RX,
- USRP_DBID_BASIC_RX
- };
-
- std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int)));
- return pick_subdev(d_ub_rx, candidates);
-}
-
-usrp_subdev_spec
-usrp_usb_interface::pick_tx_subdevice()
-{
- int dbids[] = {
- USRP_DBID_FLEX_400_TX,
- USRP_DBID_FLEX_900_TX,
- USRP_DBID_FLEX_1200_TX,
- USRP_DBID_FLEX_2400_TX,
- USRP_DBID_BASIC_TX
- };
-
- std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int)));
- return pick_subdev(d_ub_tx, candidates);
-}
-
-usrp_subdev_spec
-usrp_usb_interface::pick_subdev(boost::shared_ptr<usrp_basic> d_usrp_basic, std::vector<int> candidates)
-{
- int dbid0 = d_usrp_basic->selected_subdev(usrp_subdev_spec(0, 0))->dbid();
- int dbid1 = d_usrp_basic->selected_subdev(usrp_subdev_spec(1, 0))->dbid();
-
- for (int i = 0; i < candidates.size(); i++) {
- int dbid = candidates[i];
- if (dbid0 == dbid)
- return usrp_subdev_spec(0, 0);
- if (dbid1 == dbid)
- return usrp_subdev_spec(1, 0);
- }
-
- if (dbid0 >= 0)
- return usrp_subdev_spec(0, 0);
- if (dbid1 >= 0)
- return usrp_subdev_spec(1, 0);
-
- throw std::runtime_error("No suitable daughterboard found!");
-}
-
-
-REGISTER_MBLOCK_CLASS(usrp_usb_interface);
diff --git a/usrp/host/lib/inband/usrp_usb_interface.h b/usrp/host/lib/inband/usrp_usb_interface.h
deleted file mode 100644
index 4d7750a7d..000000000
--- a/usrp/host/lib/inband/usrp_usb_interface.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_USB_INTERFACE_H
-#define INCLUDED_USRP_USB_INTERFACE_H
-
-#include <mblock/mblock.h>
-#include <vector>
-#include "usrp_standard.h"
-
-/*!
- * \brief Implements the low level usb interface to the USRP
- */
-class usrp_usb_interface : public mb_mblock
-{
- public:
-
- usrp_standard_tx_sptr d_utx;
- usrp_standard_rx_sptr d_urx;
-
- boost::shared_ptr<usrp_basic> d_ub_tx;
- boost::shared_ptr<usrp_basic> d_ub_rx;
-
- mb_port_sptr d_cs;
- mb_port_sptr d_rx_cs;
- mb_port_sptr d_tx_cs;
-
- long d_ntx_chan;
- long d_nrx_chan;
-
- bool d_fake_usrp;
-
- bool d_rx_reading;
-
- long d_interp_tx;
- long d_decim_rx;
-
- double d_rf_freq;
-
- std::string d_rbf;
-
- public:
- usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
- ~usrp_usb_interface();
- void initial_transition();
- void handle_message(mb_message_sptr msg);
- usrp_subdev_spec pick_rx_subdevice();
- usrp_subdev_spec pick_tx_subdevice();
- usrp_subdev_spec pick_subdev(boost::shared_ptr<usrp_basic> d_usrp_basic, std::vector<int> candidates);
-
- private:
- void handle_cmd_open(pmt_t data);
- void handle_cmd_close(pmt_t data);
- void handle_cmd_write(pmt_t data);
- void handle_cmd_start_reading(pmt_t data);
- void handle_cmd_stop_reading(pmt_t data);
-
-};
-
-
-#endif /* INCLUDED_USRP_USB_INTERFACE_H */
diff --git a/usrp/host/lib/legacy/Makefile.am b/usrp/host/lib/legacy/Makefile.am
deleted file mode 100644
index e1b1b850a..000000000
--- a/usrp/host/lib/legacy/Makefile.am
+++ /dev/null
@@ -1,196 +0,0 @@
-#
-# USRP - Universal Software Radio Peripheral
-#
-# Copyright (C) 2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA
-#
-
-include $(top_srcdir)/Makefile.common
-
-common_INCLUDES = $(USRP_INCLUDES)
-
-lib_LTLIBRARIES = libusrp.la
-
-libusrp_la_common_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 $(BOOST_LDFLAGS)
-
-libusrp_la_common_LIBADD = \
- $(USB_LIBS) \
- $(BOOST_THREAD_LIB) \
- ../../misc/libmisc.la
-
-# darwin fusb requires omnithreads
-if FUSB_TECH_darwin
-AM_CPPFLAGS = $(common_INCLUDES) $(OMNITHREAD_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES)
-libusrp_la_LIBADD = $(libusrp_la_common_LIBADD) $(OMNITHREAD_LA)
-libusrp_la_LDFLAGS = $(libusrp_la_common_LDFLAGS) -framework CoreFoundation
-else
-AM_CPPFLAGS = $(common_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES)
-libusrp_la_LIBADD = $(libusrp_la_common_LIBADD)
-libusrp_la_LDFLAGS = $(libusrp_la_common_LDFLAGS)
-endif
-
-EXTRA_DIST = \
- std_paths.h.in \
- usrp_dbid.dat
-
-BUILT_SOURCES = \
- usrp_dbid.h
-
-BUILT_SOURCES += usrp_dbid.cc \
- usrp_dbid.py
-
-# ----------------------------------------------------------------
-# FUSB_TECH is set at configure time by way of
-# usrp/config/usrp_fusb_tech.m4.
-# It indicates which fast usb strategy we should be building.
-# We currently implement "generic", "darwin", "win32" and "linux"
-
-
-generic_CODE = \
- fusb_generic.cc \
- fusb_sysconfig_generic.cc
-
-darwin_CODE = \
- fusb_darwin.cc \
- fusb_sysconfig_darwin.cc \
- README_OSX \
- circular_buffer.h \
- circular_linked_list.h \
- darwin_libusb.h \
- mld_threads.h
-
-win32_CODE = \
- fusb_win32.cc \
- fusb_sysconfig_win32.cc
-
-linux_CODE = \
- fusb_linux.cc \
- fusb_sysconfig_linux.cc
-
-ra_wb_CODE = \
- fusb_ra_wb.cc \
- fusb_sysconfig_ra_wb.cc
-
-
-#
-# include each <foo>_CODE entry here...
-#
-EXTRA_libusrp_la_SOURCES = \
- $(generic_CODE) \
- $(darwin_CODE) \
- $(win32_CODE) \
- $(linux_CODE) \
- $(ra_wb_CODE)
-
-
-# work around automake deficiency
-libusrp_la_common_SOURCES = \
- fusb.cc \
- md5.c \
- usrp_basic.cc \
- usrp_config.cc \
- usrp_dbid.cc \
- usrp_local_sighandler.cc \
- usrp_prims.cc \
- usrp_standard.cc \
- db_boards.cc \
- db_base.cc \
- db_basic.cc \
- db_tv_rx.cc \
- db_flexrf.cc \
- db_flexrf_mimo.cc \
- db_dbs_rx.cc \
- db_xcvr2450.cc \
- db_dtt754.cc \
- db_dtt768.cc \
- db_util.cc
-
-
-
-if FUSB_TECH_generic
-libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(generic_CODE)
-endif
-
-if FUSB_TECH_darwin
-libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(darwin_CODE)
-endif
-
-if FUSB_TECH_win32
-libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(win32_CODE)
-endif
-
-if FUSB_TECH_linux
-libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(linux_CODE)
-endif
-
-if FUSB_TECH_ra_wb
-libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(ra_wb_CODE)
-endif
-
-include_HEADERS = \
- db_base.h \
- db_basic.h \
- db_dbs_rx.h \
- db_dtt754.h \
- db_dtt768.h \
- db_flexrf.h \
- db_flexrf_mimo.h \
- db_tv_rx.h \
- db_util.h \
- db_xcvr2450.h \
- usrp_basic.h \
- usrp_bytesex.h \
- usrp_config.h \
- usrp_dbid.h \
- usrp_prims.h \
- usrp_slots.h \
- usrp_standard.h \
- usrp_subdev_spec.h \
- usrp_tune_result.h
-
-noinst_HEADERS = \
- ad9862.h \
- db_base_impl.h \
- db_boards.h \
- db_wbx.h \
- fusb.h \
- fusb_darwin.h \
- fusb_generic.h \
- fusb_linux.h \
- fusb_ra_wb.h \
- fusb_win32.h \
- md5.h \
- rate_to_regval.h \
- usrp_local_sighandler.h
-
-if PYTHON
-usrppython_PYTHON = \
- usrp_dbid.py
-
-noinst_PYTHON = \
- gen_usrp_dbid.py \
- check_data.py \
- dump_data.py
-
-swiginclude_HEADERS = db_base.i
-endif
-
-# common way for generating sources from templates when using
-# BUILT_SOURCES, using parallel build protection.
-gen_sources = $(BUILT_SOURCES)
-gen_sources_deps = gen_usrp_dbid.py usrp_dbid.dat
-par_gen_command = PYTHONPATH=$(top_srcdir)/usrp/src srcdir=$(srcdir) $(PYTHON) $(srcdir)/gen_usrp_dbid.py $(srcdir)/usrp_dbid.dat
-include $(top_srcdir)/Makefile.par.gen
diff --git a/usrp/host/lib/legacy/db_base.h b/usrp/host/lib/legacy/db_base.h
deleted file mode 100644
index 35470891a..000000000
--- a/usrp/host/lib/legacy/db_base.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-//
-
-#ifndef INCLUDED_DB_BASE_H
-#define INCLUDED_DB_BASE_H
-
-#include <string>
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
-#include <iosfwd>
-
-class db_base;
-typedef boost::shared_ptr<db_base> db_base_sptr;
-
-class usrp_basic;
-typedef boost::shared_ptr<usrp_basic> usrp_basic_sptr;
-
-struct freq_result_t
-{
- bool ok;
- double baseband_freq;
-};
-
-/******************************************************************************/
-
-/*!
- * \brief Abstract base class for all USRP daughterboards
- * \ingroup usrp
- */
-class db_base
-{
- protected:
- bool d_is_shutdown;
- usrp_basic *d_raw_usrp;
- int d_which;
- double d_lo_offset;
-
- void _enable_refclk(bool enable);
- virtual double _refclk_freq();
- virtual int _refclk_divisor();
-
- usrp_basic *usrp(){
- return d_raw_usrp;
- }
-
- public:
- db_base(boost::shared_ptr<usrp_basic> usrp, int which);
- virtual ~db_base();
-
- int dbid();
- std::string name();
- std::string side_and_name();
- int which() { return d_which; }
-
- bool bypass_adc_buffers(bool bypass);
- bool set_atr_mask(int v);
- bool set_atr_txval(int v);
- bool set_atr_rxval(int v);
- bool set_atr_tx_delay(int v);
- bool set_atr_rx_delay(int v);
- bool set_lo_offset(double offset);
- double lo_offset() { return d_lo_offset; }
-
-
- ////////////////////////////////////////////////////////
- // derived classes should override the following methods
-
-protected:
- friend class usrp_basic;
-
- /*!
- * Called to shutdown daughterboard. Called from dtor and usrp_basic dtor.
- *
- * N.B., any class that overrides shutdown MUST call shutdown in its destructor.
- */
- virtual void shutdown();
-
-
-public:
- virtual float gain_min() = 0;
- virtual float gain_max() = 0;
- virtual float gain_db_per_step() = 0;
- virtual double freq_min() = 0;
- virtual double freq_max() = 0;
- virtual struct freq_result_t set_freq(double target_freq) = 0;
- virtual bool set_gain(float gain) = 0;
- virtual bool is_quadrature() = 0;
- virtual bool i_and_q_swapped();
- virtual bool spectrum_inverted();
- virtual bool set_enable(bool on);
- virtual bool set_auto_tr(bool on);
- virtual bool select_rx_antenna(int which_antenna);
- virtual bool select_rx_antenna(const std::string &which_antenna);
- virtual bool set_bw(float bw);
-};
-
-
-std::ostream & operator<<(std::ostream &os, db_base &x);
-
-#endif /* INCLUDED_DB_BASE_H */
diff --git a/usrp/host/lib/legacy/db_base.i b/usrp/host/lib/legacy/db_base.i
deleted file mode 100644
index bd5483aa8..000000000
--- a/usrp/host/lib/legacy/db_base.i
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008,2009 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-//
-
-
-%{
-#include "db_base.h"
-%}
-
-%include <gr_shared_ptr.i>
-
-class usrp_tune_result
-{
-public:
- usrp_tune_result(double baseband=0, double dxc=0,
- double residual=0, bool inv=0);
- ~usrp_tune_result();
-
- double baseband_freq;
- double dxc_freq;
- double residual_freq;
- bool inverted;
-};
-
-struct freq_result_t
-{
- bool ok;
- double baseband_freq;
-};
-
-class db_base
-{
- private:
- db_base(boost::shared_ptr<usrp_basic> usrp, int which);
-
- public:
- virtual ~db_base();
-
- int dbid();
- std::string name();
- std::string side_and_name();
- int which() { return d_which; }
-
- bool bypass_adc_buffers(bool bypass);
- bool set_atr_mask(int v);
- bool set_atr_txval(int v);
- bool set_atr_rxval(int v);
- bool set_atr_tx_delay(int v);
- bool set_atr_rx_delay(int v);
- bool set_lo_offset(double offset);
- double lo_offset() { return d_lo_offset; }
-
- virtual float gain_min() = 0;
- virtual float gain_max() = 0;
- virtual float gain_db_per_step() = 0;
- virtual double freq_min() = 0;
- virtual double freq_max() = 0;
- virtual struct freq_result_t set_freq(double target_freq) = 0;
- virtual bool set_gain(float gain) = 0;
- virtual bool is_quadrature() = 0;
- virtual bool i_and_q_swapped();
- virtual bool spectrum_inverted();
- virtual bool set_enable(bool on);
- virtual bool set_auto_tr(bool on);
- virtual bool select_rx_antenna(int which_antenna);
- virtual bool select_rx_antenna(const std::string &antenna);
- virtual bool set_bw(float bw);
-};
-
-// Create templates for db's, vectors of db's, and vector of vectors of db's
-typedef boost::shared_ptr<db_base> db_base_sptr;
-%template(db_base_sptr) boost::shared_ptr<db_base>;
-%template(db_base_sptr_vector) std::vector<db_base_sptr>;
-%template(db_base_sptr_vector_vector) std::vector<std::vector<db_base_sptr> >;
-
-// Set better class name in Python
-// Enable freq_range and gain_range from public methods of class not implemented in C++
-// And create a dummy wrapper for backwards compatability with some of the example code
-%pythoncode %{
- db_base_sptr.__repr__ = lambda self: "<db_base::%s>" % (self.name(),)
- db_base_sptr.freq_range = lambda self: (self.freq_min(), self.freq_max(), 1)
- db_base_sptr.gain_range = lambda self: (self.gain_min(), self.gain_max(), self.gain_db_per_step())
-
-%}
diff --git a/usrp/host/lib/legacy/db_basic.h b/usrp/host/lib/legacy/db_basic.h
deleted file mode 100644
index 4dd92b997..000000000
--- a/usrp/host/lib/legacy/db_basic.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_BASIC_H
-#define DB_BASIC_H
-
-#include <db_base.h>
-
-
-/******************************************************************************/
-
-
-class db_basic_tx : public db_base
-{
-public:
- db_basic_tx(usrp_basic_sptr usrp, int which);
- ~db_basic_tx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double target_freq);
- bool set_gain(float gain);
- bool is_quadrature();
-};
-
-
-/******************************************************************************/
-
-
-class db_basic_rx : public db_base
-{
- public:
- db_basic_rx(usrp_basic_sptr usrp, int which, int subdev);
- ~db_basic_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double target_freq);
- bool set_gain(float gain);
- bool is_quadrature();
-
-private:
- int d_subdev;
-};
-
-
-/******************************************************************************/
-
-
-class db_lf_rx : public db_basic_rx
-{
- public:
- db_lf_rx(usrp_basic_sptr usrp, int which, int subdev);
- ~db_lf_rx();
-
- double freq_min();
- double freq_max();
-};
-
-
-/******************************************************************************/
-
-
-class db_lf_tx : public db_basic_tx
-{
- public:
- db_lf_tx(usrp_basic_sptr usrp, int which);
- ~db_lf_tx();
-
- double freq_min();
- double freq_max();
-};
-
-
-#endif
diff --git a/usrp/host/lib/legacy/db_dbs_rx.h b/usrp/host/lib/legacy/db_dbs_rx.h
deleted file mode 100644
index 723771f15..000000000
--- a/usrp/host/lib/legacy/db_dbs_rx.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_DBS_RX_H
-#define DB_DBS_RX_H
-
-#include <db_base.h>
-#include <vector>
-
-#if 0
-struct bw_t {
- int m;
- int fdac;
- float div;
-};
-#endif
-
-class db_dbs_rx : public db_base
-{
-private:
- int d_osc, d_cp, d_n, d_div2, d_r, d_r_int;
- int d_fdac, d_m, d_dl, d_ade, d_adl, d_gc1, d_gc2, d_diag;
- int d_i2c_addr;
-
- // Internal gain functions
- void _write_reg(int regno, int v);
- void _write_regs(int starting_regno, const std::vector<int> &vals);
- std::vector<int> _read_status();
- void _send_reg(int regno);
- void _set_m(int m);
- void _set_fdac(int fdac);
- void _set_dl(int dl);
- void _set_gc2(int gc2);
- void _set_gc1(int gc1);
- void _set_pga(int pga_gain);
-
- // Internal frequency function
- void _set_osc(int osc);
- void _set_cp(int cp);
- void _set_n(int n);
- void _set_div2(int div2);
- void _set_r(int r);
- void _set_ade(int ade);
-
- int _refclk_divisor();
-
-protected:
- void shutdown();
-
-public:
- db_dbs_rx(usrp_basic_sptr usrp, int which);
- ~db_dbs_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double freq);
- bool set_gain(float gain);
- bool is_quadrature();
- bool set_bw(float bw);
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/db_dtt754.h b/usrp/host/lib/legacy/db_dtt754.h
deleted file mode 100644
index 0c104ac0c..000000000
--- a/usrp/host/lib/legacy/db_dtt754.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_DTT754_H
-#define DB_DTT754_H
-
-#include <db_base.h>
-#include <boost/shared_ptr.hpp>
-
-class db_dtt754 : public db_base
-{
-public:
- db_dtt754(usrp_basic_sptr usrp, int which);
- ~db_dtt754();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool set_gain(float gain);
-
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double target_freq);
-
- bool is_quadrature();
- bool spectrum_inverted();
- bool set_bw(float bw);
-
-private:
- void _set_rfagc(float gain);
- void _set_ifagc(float gain);
- void _set_pga(float pga_gain);
-
- int d_i2c_addr;
- float d_bw, d_freq, d_IF, d_f_ref;
- bool d_inverted;
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/db_dtt768.h b/usrp/host/lib/legacy/db_dtt768.h
deleted file mode 100644
index dd5a59abd..000000000
--- a/usrp/host/lib/legacy/db_dtt768.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_DTT768_H
-#define DB_DTT768_H
-
-#include <db_base.h>
-#include <boost/shared_ptr.hpp>
-
-class db_dtt768 : public db_base
-{
-public:
- db_dtt768(usrp_basic_sptr usrp, int which);
- ~db_dtt768();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool set_gain(float gain);
-
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double target_freq);
-
- bool is_quadrature();
- bool spectrum_inverted();
- bool set_bw(float bw);
-
-private:
- void _set_rfagc(float gain);
- void _set_ifagc(float gain);
- void _set_pga(float pga_gain);
-
- int d_i2c_addr;
- float d_bw, d_freq, d_IF, d_f_ref;
- bool d_inverted;
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/db_flexrf.h b/usrp/host/lib/legacy/db_flexrf.h
deleted file mode 100644
index b9ccfc3ac..000000000
--- a/usrp/host/lib/legacy/db_flexrf.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_FLEXRF_H
-#define DB_FLEXRF_H
-
-#include <db_base.h>
-#include <cmath>
-
-//debug_using_gui = true // Must be set to True or False
-#define debug_using_gui false // Must be set to True or False
-
-class _AD4360_common;
-
-class flexrf_base : public db_base
-{
-public:
- flexrf_base(usrp_basic_sptr usrp, int which, int _power_on=0);
- ~flexrf_base();
-
- struct freq_result_t set_freq(double freq);
-
- bool is_quadrature();
- double freq_min();
- double freq_max();
-
-protected:
- void _write_all(int R, int control, int N);
- void _write_control(int control);
- void _write_R(int R);
- void _write_N(int N);
- void _write_it(int v);
- bool _lock_detect();
-
- virtual bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
- double _refclk_freq();
-
- bool _set_pga(float pga_gain);
-
- int power_on() { return d_power_on; }
- int power_off() { return 0; }
-
- bool d_first;
- int d_spi_format;
- int d_spi_enable;
- int d_power_on;
- int d_PD;
-
- _AD4360_common *d_common;
-};
-
-// ----------------------------------------------------------------
-
-class flexrf_base_tx : public flexrf_base
-{
-protected:
- void shutdown();
-
-public:
- flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
- ~flexrf_base_tx();
-
- // All RFX tx d'boards have fixed gain
- float gain_min();
- float gain_max();
- float gain_db_per_step();
-
- bool set_auto_tr(bool on);
- bool set_enable(bool on);
- bool set_gain(float gain);
-};
-
-class flexrf_base_rx : public flexrf_base
-{
-protected:
- void shutdown();
-
-public:
- flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
- ~flexrf_base_rx();
-
- bool set_auto_tr(bool on);
- bool select_rx_antenna(int which_antenna);
- bool select_rx_antenna(const std::string &which_antenna);
- bool set_gain(float gain);
-
-};
-
-// ----------------------------------------------------------------
-
-
-class _AD4360_common
-{
-public:
- _AD4360_common();
- virtual ~_AD4360_common();
-
- virtual double freq_min() = 0;
- virtual double freq_max() = 0;
-
- bool _compute_regs(double refclk_freq, double freq, int &retR,
- int &retcontrol, int &retN, double &retfreq);
- int _compute_control_reg();
- virtual int _refclk_divisor();
- int _prescaler();
-
- void R_DIV(int div) { d_R_DIV = div; }
-
-protected:
- int d_R_RSV, d_BSC, d_TEST, d_LDP, d_ABP, d_N_RSV, d_PL, d_MTLD;
- int d_CPG, d_CP3S, d_PDP, d_MUXOUT, d_CR, d_PC;
-
- // FIXME: d_PD might cause conflict from flexrf_base
- int d_A_DIV, d_B_DIV, d_R_DIV, d_P, d_PD, d_CP2, d_CP1, d_DIVSEL;
- int d_DIV2, d_CPGAIN, d_freq_mult;
-
-};
-
-//----------------------------------------------------------------------
-
-class _2400_common : public _AD4360_common
-{
- public:
- _2400_common();
- ~_2400_common() {}
-
- double freq_min();
- double freq_max();
-};
-
-//----------------------------------------------------------------------
-
-class _1200_common : public _AD4360_common
-{
-public:
- _1200_common();
- ~_1200_common() {}
-
- double freq_min();
- double freq_max();
-};
-
-//-------------------------------------------------------------------------
-
-class _1800_common : public _AD4360_common
-{
- public:
- _1800_common();
- ~_1800_common() {}
-
- double freq_min();
- double freq_max();
-};
-
-//-------------------------------------------------------------------------
-
-class _900_common : public _AD4360_common
-{
-public:
- _900_common();
- ~_900_common() {}
-
- double freq_min();
- double freq_max();
-};
-
-//-------------------------------------------------------------------------
-
-class _400_common : public _AD4360_common
-{
-public:
- _400_common();
- ~_400_common() {}
-
- double freq_min();
- double freq_max();
-};
-
-class _400_tx : public _400_common
-{
-public:
- _400_tx();
- ~_400_tx() {}
-};
-
-class _400_rx : public _400_common
-{
-public:
- _400_rx();
- ~_400_rx() {}
-};
-
-//------------------------------------------------------------
-
-class db_flexrf_2400_tx : public flexrf_base_tx
-{
- public:
- db_flexrf_2400_tx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_2400_tx();
-
- // Wrapper calls to d_common functions
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-class db_flexrf_2400_rx : public flexrf_base_rx
-{
-public:
- db_flexrf_2400_rx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_2400_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool i_and_q_swapped();
-
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-//------------------------------------------------------------
-
-class db_flexrf_1200_tx : public flexrf_base_tx
-{
-public:
- db_flexrf_1200_tx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_1200_tx();
-
- // Wrapper calls to d_common functions
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-class db_flexrf_1200_rx : public flexrf_base_rx
-{
-public:
- db_flexrf_1200_rx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_1200_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool i_and_q_swapped();
-
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-//------------------------------------------------------------
-
-class db_flexrf_1800_tx : public flexrf_base_tx
-{
- public:
- db_flexrf_1800_tx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_1800_tx();
-
- // Wrapper calls to d_common functions
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-class db_flexrf_1800_rx : public flexrf_base_rx
-{
-public:
- db_flexrf_1800_rx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_1800_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool i_and_q_swapped();
-
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-//------------------------------------------------------------
-
-class db_flexrf_900_tx : public flexrf_base_tx
-{
- public:
- db_flexrf_900_tx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_900_tx();
-
- // Wrapper calls to d_common functions
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-class db_flexrf_900_rx : public flexrf_base_rx
-{
-public:
- db_flexrf_900_rx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_900_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool i_and_q_swapped();
-
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-
-//------------------------------------------------------------
-
-class db_flexrf_400_tx : public flexrf_base_tx
-{
- public:
- db_flexrf_400_tx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_400_tx();
-
- // Wrapper calls to d_common functions
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-class db_flexrf_400_rx : public flexrf_base_rx
-{
-public:
- db_flexrf_400_rx(usrp_basic_sptr usrp, int which);
- ~db_flexrf_400_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool i_and_q_swapped();
-
- bool _compute_regs(double freq, int &retR, int &retcontrol,
- int &retN, double &retfreq);
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/db_flexrf_mimo.h b/usrp/host/lib/legacy/db_flexrf_mimo.h
deleted file mode 100644
index aeff53258..000000000
--- a/usrp/host/lib/legacy/db_flexrf_mimo.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <db_flexrf.h>
-
-class db_flexrf_2400_tx_mimo_a : public db_flexrf_2400_tx
-{
- public:
- db_flexrf_2400_tx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_2400_rx_mimo_a : public db_flexrf_2400_rx
-{
- public:
- db_flexrf_2400_rx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_2400_tx_mimo_b : public db_flexrf_2400_tx
-{
- public:
- db_flexrf_2400_tx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_2400_rx_mimo_b : public db_flexrf_2400_rx
-{
- public:
- db_flexrf_2400_rx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-
-class db_flexrf_1800_tx_mimo_a : public db_flexrf_1800_tx
-{
- public:
- db_flexrf_1800_tx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1800_rx_mimo_a : public db_flexrf_1800_rx
-{
- public:
- db_flexrf_1800_rx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1800_tx_mimo_b : public db_flexrf_1800_tx
-{
- public:
- db_flexrf_1800_tx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1800_rx_mimo_b : public db_flexrf_1800_rx
-{
- public:
- db_flexrf_1800_rx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1200_tx_mimo_a : public db_flexrf_1200_tx
-{
- public:
- db_flexrf_1200_tx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1200_rx_mimo_a : public db_flexrf_1200_rx
-{
- public:
- db_flexrf_1200_rx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1200_tx_mimo_b : public db_flexrf_1200_tx
-{
- public:
- db_flexrf_1200_tx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_1200_rx_mimo_b : public db_flexrf_1200_rx
-{
- public:
- db_flexrf_1200_rx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_900_tx_mimo_a : public db_flexrf_900_tx
-{
- public:
- db_flexrf_900_tx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_900_rx_mimo_a : public db_flexrf_900_rx
-{
- public:
- db_flexrf_900_rx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_900_tx_mimo_b : public db_flexrf_900_tx
-{
- public:
- db_flexrf_900_tx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_900_rx_mimo_b : public db_flexrf_900_rx
-{
- public:
- db_flexrf_900_rx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_400_tx_mimo_a : public db_flexrf_400_tx
-{
- public:
- db_flexrf_400_tx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_400_rx_mimo_a : public db_flexrf_400_rx
-{
- public:
- db_flexrf_400_rx_mimo_a(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_400_tx_mimo_b : public db_flexrf_400_tx
-{
- public:
- db_flexrf_400_tx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
-
-class db_flexrf_400_rx_mimo_b : public db_flexrf_400_rx
-{
- public:
- db_flexrf_400_rx_mimo_b(usrp_basic_sptr usrp, int which);
- int _refclk_divisor();
-};
diff --git a/usrp/host/lib/legacy/db_tv_rx.h b/usrp/host/lib/legacy/db_tv_rx.h
deleted file mode 100644
index ed9162637..000000000
--- a/usrp/host/lib/legacy/db_tv_rx.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_TV_RX_H
-#define DB_TV_RX_H
-
-#include <db_base.h>
-
-class db_tv_rx : public db_base
-{
-private:
- void _set_rfagc(float gain);
- void _set_ifagc(float gain);
- void _set_pga(float pga_gain);
-
- int d_i2c_addr;
- double d_first_IF, d_second_IF;
- int d_reference_divisor;
- bool d_fast_tuning;
- bool d_inverted;
-
-public:
- db_tv_rx(usrp_basic_sptr usrp, int which,
- double first_IF, double second_IF);
- ~db_tv_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- double freq_min();
- double freq_max();
- struct freq_result_t set_freq(double target_freq);
- bool set_gain(float gain);
- bool is_quadrature();
- bool spectrum_inverted();
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/db_xcvr2450.h b/usrp/host/lib/legacy/db_xcvr2450.h
deleted file mode 100644
index 1f9dd7c2c..000000000
--- a/usrp/host/lib/legacy/db_xcvr2450.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- c++ -*- */
-//
-// Copyright 2008,2009 Free Software Foundation, Inc.
-//
-// This file is part of GNU Radio
-//
-// GNU Radio is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either asversion 3, or (at your option)
-// any later version.
-//
-// GNU Radio is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GNU Radio; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street,
-// Boston, MA 02110-1301, USA.
-
-#ifndef DB_XCVR2450_H
-#define DB_XCVR2450_H
-
-#include <db_base.h>
-#include <boost/shared_ptr.hpp>
-
-class xcvr2450;
-typedef boost::shared_ptr<xcvr2450> xcvr2450_sptr;
-
-
-/******************************************************************************/
-
-
-class db_xcvr2450_base: public db_base
-{
- /*
- * Abstract base class for all xcvr2450 boards.
- *
- * Derive board specific subclasses from db_xcvr2450_base_{tx,rx}
- */
-public:
- db_xcvr2450_base(usrp_basic_sptr usrp, int which);
- ~db_xcvr2450_base();
- struct freq_result_t set_freq(double target_freq);
- bool is_quadrature();
- double freq_min();
- double freq_max();
-
-protected:
- xcvr2450_sptr d_xcvr;
- void shutdown_common();
-};
-
-
-/******************************************************************************/
-
-
-class db_xcvr2450_tx : public db_xcvr2450_base
-{
-protected:
- void shutdown();
-
-public:
- db_xcvr2450_tx(usrp_basic_sptr usrp, int which);
- ~db_xcvr2450_tx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool set_gain(float gain);
- bool i_and_q_swapped();
-};
-
-class db_xcvr2450_rx : public db_xcvr2450_base
-{
-protected:
- void shutdown();
-
-public:
- db_xcvr2450_rx(usrp_basic_sptr usrp, int which);
- ~db_xcvr2450_rx();
-
- float gain_min();
- float gain_max();
- float gain_db_per_step();
- bool set_gain(float gain);
-};
-
-
-
-#endif
diff --git a/usrp/host/lib/legacy/usrp_basic.h b/usrp/host/lib/legacy/usrp_basic.h
deleted file mode 100644
index 86c48635a..000000000
--- a/usrp/host/lib/legacy/usrp_basic.h
+++ /dev/null
@@ -1,991 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * ----------------------------------------------------------------------
- * Mid level interface to the Universal Software Radio Peripheral (Rev 1)
- *
- * These classes implement the basic functionality for talking to the
- * USRP. They try to be as independent of the signal processing code
- * in FPGA as possible. They implement access to the low level
- * peripherals on the board, provide a common way for reading and
- * writing registers in the FPGA, and provide the high speed interface
- * to streaming data across the USB.
- *
- * It is expected that subclasses will be derived that provide
- * access to the functionality to a particular FPGA configuration.
- * ----------------------------------------------------------------------
- */
-
-#ifndef INCLUDED_USRP_BASIC_H
-#define INCLUDED_USRP_BASIC_H
-
-#include <db_base.h>
-#include <usrp_slots.h>
-#include <string>
-#include <vector>
-#include <boost/utility.hpp>
-#include <usrp_subdev_spec.h>
-
-struct usb_dev_handle;
-class fusb_devhandle;
-class fusb_ephandle;
-
-enum txrx_t {
- C_RX = 0,
- C_TX = 1
-};
-
-/*!
- * \brief abstract base class for usrp operations
- * \ingroup usrp
- */
-class usrp_basic : boost::noncopyable
-{
-protected:
- void shutdown_daughterboards();
-
-protected:
- struct usb_dev_handle *d_udh;
- int d_usb_data_rate; // bytes/sec
- int d_bytes_per_poll; // how often to poll for overruns
- bool d_verbose;
- long d_fpga_master_clock_freq;
-
- static const int MAX_REGS = 128;
- unsigned int d_fpga_shadows[MAX_REGS];
-
- int d_dbid[2]; // daughterboard ID's (side A, side B)
-
- /*!
- * Shared pointers to subclasses of db_base.
- *
- * The outer vector is of length 2 (0 = side A, 1 = side B). The
- * inner vectors are of length 1, 2 or 3 depending on the number of
- * subdevices implemented by the daugherboard. At this time, only
- * the Basic Rx and LF Rx implement more than 1 subdevice.
- */
- std::vector< std::vector<db_base_sptr> > d_db;
-
- //! One time call, made only only from usrp_standard_*::make after shared_ptr is created.
- void init_db(usrp_basic_sptr u);
-
-
- usrp_basic (int which_board,
- struct usb_dev_handle *open_interface (struct usb_device *dev),
- const std::string fpga_filename = "",
- const std::string firmware_filename = "");
-
- /*!
- * \brief advise usrp_basic of usb data rate (bytes/sec)
- *
- * N.B., this doesn't tweak any hardware. Derived classes
- * should call this to inform us of the data rate whenever it's
- * first set or if it changes.
- *
- * \param usb_data_rate bytes/sec
- */
- void set_usb_data_rate (int usb_data_rate);
-
- /*!
- * \brief Write auxiliary digital to analog converter.
- *
- * \param slot Which Tx or Rx slot to write.
- * N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
- * SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
- * \param which_dac [0,3] RX slots must use only 0 and 1. TX slots must use only 2 and 3.
- * \param value [0,4095]
- * \returns true iff successful
- */
- bool _write_aux_dac (int slot, int which_dac, int value);
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param slot 2-bit slot number. E.g., SLOT_TX_A
- * \param which_adc [0,1]
- * \param value return 12-bit value [0,4095]
- * \returns true iff successful
- */
- bool _read_aux_adc (int slot, int which_adc, int *value);
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param slot 2-bit slot number. E.g., SLOT_TX_A
- * \param which_adc [0,1]
- * \returns value in the range [0,4095] if successful, else READ_FAILED.
- */
- int _read_aux_adc (int slot, int which_adc);
-
-
-public:
- virtual ~usrp_basic ();
-
-
- /*!
- * Return a vector of vectors that contain shared pointers
- * to the daughterboard instance(s) associated with the specified side.
- *
- * It is an error to use the returned objects after the usrp_basic
- * object has been destroyed.
- */
- std::vector<std::vector<db_base_sptr> > db() const { return d_db; }
-
- /*!
- * Return a vector of size >= 1 that contains shared pointers
- * to the daughterboard instance(s) associated with the specified side.
- *
- * \param which_side [0,1] which daughterboard
- *
- * It is an error to use the returned objects after the usrp_basic
- * object has been destroyed.
- */
- std::vector<db_base_sptr> db(int which_side);
-
- /*!
- * \brief is the subdev_spec valid?
- */
- bool is_valid(const usrp_subdev_spec &ss);
-
- /*!
- * \brief given a subdev_spec, return the corresponding daughterboard object.
- * \throws std::invalid_ argument if ss is invalid.
- *
- * \param ss specifies the side and subdevice
- */
- db_base_sptr selected_subdev(const usrp_subdev_spec &ss);
-
- /*!
- * \brief return frequency of master oscillator on USRP
- */
- long fpga_master_clock_freq () const { return d_fpga_master_clock_freq; }
-
- /*!
- * Tell API that the master oscillator on the USRP is operating at a non-standard
- * fixed frequency. This is only needed for custom USRP hardware modified to
- * operate at a different frequency from the default factory configuration. This
- * function must be called prior to any other API function.
- * \param master_clock USRP2 FPGA master clock frequency in Hz (10..64 MHz)
- */
- void set_fpga_master_clock_freq (long master_clock) { d_fpga_master_clock_freq = master_clock; }
-
- /*!
- * \returns usb data rate in bytes/sec
- */
- int usb_data_rate () const { return d_usb_data_rate; }
-
- void set_verbose (bool on) { d_verbose = on; }
-
- //! magic value used on alternate register read interfaces
- static const int READ_FAILED = -99999;
-
- /*!
- * \brief Write EEPROM on motherboard or any daughterboard.
- * \param i2c_addr I2C bus address of EEPROM
- * \param eeprom_offset byte offset in EEPROM to begin writing
- * \param buf the data to write
- * \returns true iff sucessful
- */
- bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
-
- /*!
- * \brief Read EEPROM on motherboard or any daughterboard.
- * \param i2c_addr I2C bus address of EEPROM
- * \param eeprom_offset byte offset in EEPROM to begin reading
- * \param len number of bytes to read
- * \returns the data read if successful, else a zero length string.
- */
- std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
-
- /*!
- * \brief Write to I2C peripheral
- * \param i2c_addr I2C bus address (7-bits)
- * \param buf the data to write
- * \returns true iff successful
- * Writes are limited to a maximum of of 64 bytes.
- */
- bool write_i2c (int i2c_addr, const std::string buf);
-
- /*!
- * \brief Read from I2C peripheral
- * \param i2c_addr I2C bus address (7-bits)
- * \param len number of bytes to read
- * \returns the data read if successful, else a zero length string.
- * Reads are limited to a maximum of 64 bytes.
- */
- std::string read_i2c (int i2c_addr, int len);
-
- /*!
- * \brief Set ADC offset correction
- * \param which_adc which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
- * \param offset 16-bit value to subtract from raw ADC input.
- */
- bool set_adc_offset (int which_adc, int offset);
-
- /*!
- * \brief Set DAC offset correction
- * \param which_dac which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
- * \param offset 10-bit offset value (ambiguous format: See AD9862 datasheet).
- * \param offset_pin 1-bit value. If 0 offset applied to -ve differential pin;
- * If 1 offset applied to +ve differential pin.
- */
- bool set_dac_offset (int which_dac, int offset, int offset_pin);
-
- /*!
- * \brief Control ADC input buffer
- * \param which_adc which ADC[0,3]
- * \param bypass if non-zero, bypass input buffer and connect input
- * directly to switched cap SHA input of RxPGA.
- */
- bool set_adc_buffer_bypass (int which_adc, bool bypass);
-
- /*!
- * \brief Enable/disable automatic DC offset removal control loop in FPGA
- *
- * \param bits which control loops to enable
- * \param mask which \p bits to pay attention to
- *
- * If the corresponding bit is set, enable the automatic DC
- * offset correction control loop.
- *
- * <pre>
- * The 4 low bits are significant:
- *
- * ADC0 = (1 << 0)
- * ADC1 = (1 << 1)
- * ADC2 = (1 << 2)
- * ADC3 = (1 << 3)
- * </pre>
- *
- * By default the control loop is enabled on all ADC's.
- */
- bool set_dc_offset_cl_enable(int bits, int mask);
-
- /*!
- * \brief return the usrp's serial number.
- *
- * \returns non-zero length string iff successful.
- */
- std::string serial_number();
-
- /*!
- * \brief Return daughterboard ID for given side [0,1].
- *
- * \param which_side [0,1] which daughterboard
- *
- * \return daughterboard id >= 0 if successful
- * \return -1 if no daugherboard
- * \return -2 if invalid EEPROM on daughterboard
- */
- virtual int daughterboard_id (int which_side) const = 0;
-
- /*!
- * \brief Clock ticks to delay rising of T/R signal
- * \sa write_atr_mask, write_atr_txval, write_atr_rxval
- */
- bool write_atr_tx_delay(int value);
-
- /*!
- * \brief Clock ticks to delay falling edge of T/R signal
- * \sa write_atr_mask, write_atr_txval, write_atr_rxval
- */
- bool write_atr_rx_delay(int value);
-
-
- // ================================================================
- // Routines to access and control daughterboard specific i/o
- //
- // Those with a common_ prefix access either the Tx or Rx side depending
- // on the txrx parameter. Those without the common_ prefix are virtual
- // and are overriden in usrp_basic_rx and usrp_basic_tx to access the
- // the Rx or Tx sides automatically. We provide the common_ versions
- // for those daughterboards such as the WBX and XCVR2450 that share
- // h/w resources (such as the LO) between the Tx and Rx sides.
-
- // ----------------------------------------------------------------
- // BEGIN common_ daughterboard control functions
-
- /*!
- * \brief Set Programmable Gain Amplifier(PGA)
- *
- * \param txrx Tx or Rx?
- * \param which_amp which amp [0,3]
- * \param gain_in_db gain value(linear in dB)
- *
- * gain is rounded to closest setting supported by hardware.
- *
- * \returns true iff sucessful.
- *
- * \sa pga_min(), pga_max(), pga_db_per_step()
- */
- bool common_set_pga(txrx_t txrx, int which_amp, double gain_in_db);
-
- /*!
- * \brief Return programmable gain amplifier gain setting in dB.
- *
- * \param txrx Tx or Rx?
- * \param which_amp which amp [0,3]
- */
- double common_pga(txrx_t txrx, int which_amp) const;
-
- /*!
- * \brief Return minimum legal PGA gain in dB.
- * \param txrx Tx or Rx?
- */
- double common_pga_min(txrx_t txrx) const;
-
- /*!
- * \brief Return maximum legal PGA gain in dB.
- * \param txrx Tx or Rx?
- */
- double common_pga_max(txrx_t txrx) const;
-
- /*!
- * \brief Return hardware step size of PGA(linear in dB).
- * \param txrx Tx or Rx?
- */
- double common_pga_db_per_step(txrx_t txrx) const;
-
- /*!
- * \brief Write direction register(output enables) for pins that go to daughterboard.
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which size
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- *
- * Each d'board has 16-bits of general purpose i/o.
- * Setting the bit makes it an output from the FPGA to the d'board.
- *
- * This register is initialized based on a value stored in the
- * d'board EEPROM. In general, you shouldn't be using this routine
- * without a very good reason. Using this method incorrectly will
- * kill your USRP motherboard and/or daughterboard.
- */
- bool _common_write_oe(txrx_t txrx, int which_side, int value, int mask);
-
- /*!
- * \brief Write daughterboard i/o pin value
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- */
- bool common_write_io(txrx_t txrx, int which_side, int value, int mask);
-
- /*!
- * \brief Read daughterboard i/o pin value
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \param value output
- */
- bool common_read_io(txrx_t txrx, int which_side, int *value);
-
- /*!
- * \brief Read daughterboard i/o pin value
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \returns register value if successful, else READ_FAILED
- */
- int common_read_io(txrx_t txrx, int which_side);
-
- /*!
- * \brief Write daughterboard refclk config register
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \param value value to write into register, see below
- *
- * <pre>
- * Control whether a reference clock is sent to the daughterboards,
- * and what frequency. The refclk is sent on d'board i/o pin 0.
- *
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-----------------------------------------------+-+------------+
- * | Reserved (Must be zero) |E| DIVISOR |
- * +-----------------------------------------------+-+------------+
- *
- * Bit 7 -- 1 turns on refclk, 0 allows IO use
- * Bits 6:0 Divider value
- * </pre>
- */
- bool common_write_refclk(txrx_t txrx, int which_side, int value);
-
- /*!
- * \brief Automatic Transmit/Receive switching
- * <pre>
- *
- * If automatic transmit/receive (ATR) switching is enabled in the
- * FR_ATR_CTL register, the presence or absence of data in the FPGA
- * transmit fifo selects between two sets of values for each of the 4
- * banks of daughterboard i/o pins.
- *
- * Each daughterboard slot has 3 16-bit registers associated with it:
- * FR_ATR_MASK_*, FR_ATR_TXVAL_* and FR_ATR_RXVAL_*
- *
- * FR_ATR_MASK_{0,1,2,3}:
- *
- * These registers determine which of the daugherboard i/o pins are
- * affected by ATR switching. If a bit in the mask is set, the
- * corresponding i/o bit is controlled by ATR, else it's output
- * value comes from the normal i/o pin output register:
- * FR_IO_{0,1,2,3}.
- *
- * FR_ATR_TXVAL_{0,1,2,3}:
- * FR_ATR_RXVAL_{0,1,2,3}:
- *
- * If the Tx fifo contains data, then the bits from TXVAL that are
- * selected by MASK are output. Otherwise, the bits from RXVAL that
- * are selected by MASK are output.
- * </pre>
- */
- bool common_write_atr_mask(txrx_t txrx, int which_side, int value);
- bool common_write_atr_txval(txrx_t txrx, int which_side, int value);
- bool common_write_atr_rxval(txrx_t txrx, int which_side, int value);
-
- /*!
- * \brief Write auxiliary digital to analog converter.
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
- * SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
- * \param which_dac [2,3] TX slots must use only 2 and 3.
- * \param value [0,4095]
- * \returns true iff successful
- */
- bool common_write_aux_dac(txrx_t txrx, int which_side, int which_dac, int value);
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \param which_adc [0,1]
- * \param value return 12-bit value [0,4095]
- * \returns true iff successful
- */
- bool common_read_aux_adc(txrx_t txrx, int which_side, int which_adc, int *value);
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param txrx Tx or Rx?
- * \param which_side [0,1] which d'board
- * \param which_adc [0,1]
- * \returns value in the range [0,4095] if successful, else READ_FAILED.
- */
- int common_read_aux_adc(txrx_t txrx, int which_side, int which_adc);
-
- // END common_ daughterboard control functions
- // ----------------------------------------------------------------
- // BEGIN virtual daughterboard control functions
-
- /*!
- * \brief Set Programmable Gain Amplifier (PGA)
- *
- * \param which_amp which amp [0,3]
- * \param gain_in_db gain value (linear in dB)
- *
- * gain is rounded to closest setting supported by hardware.
- *
- * \returns true iff sucessful.
- *
- * \sa pga_min(), pga_max(), pga_db_per_step()
- */
- virtual bool set_pga (int which_amp, double gain_in_db) = 0;
-
- /*!
- * \brief Return programmable gain amplifier gain setting in dB.
- *
- * \param which_amp which amp [0,3]
- */
- virtual double pga (int which_amp) const = 0;
-
- /*!
- * \brief Return minimum legal PGA gain in dB.
- */
- virtual double pga_min () const = 0;
-
- /*!
- * \brief Return maximum legal PGA gain in dB.
- */
- virtual double pga_max () const = 0;
-
- /*!
- * \brief Return hardware step size of PGA (linear in dB).
- */
- virtual double pga_db_per_step () const = 0;
-
- /*!
- * \brief Write direction register (output enables) for pins that go to daughterboard.
- *
- * \param which_side [0,1] which size
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- *
- * Each d'board has 16-bits of general purpose i/o.
- * Setting the bit makes it an output from the FPGA to the d'board.
- *
- * This register is initialized based on a value stored in the
- * d'board EEPROM. In general, you shouldn't be using this routine
- * without a very good reason. Using this method incorrectly will
- * kill your USRP motherboard and/or daughterboard.
- */
- virtual bool _write_oe (int which_side, int value, int mask) = 0;
-
- /*!
- * \brief Write daughterboard i/o pin value
- *
- * \param which_side [0,1] which d'board
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- */
- virtual bool write_io (int which_side, int value, int mask) = 0;
-
- /*!
- * \brief Read daughterboard i/o pin value
- *
- * \param which_side [0,1] which d'board
- * \param value output
- */
- virtual bool read_io (int which_side, int *value) = 0;
-
- /*!
- * \brief Read daughterboard i/o pin value
- *
- * \param which_side [0,1] which d'board
- * \returns register value if successful, else READ_FAILED
- */
- virtual int read_io (int which_side) = 0;
-
- /*!
- * \brief Write daughterboard refclk config register
- *
- * \param which_side [0,1] which d'board
- * \param value value to write into register, see below
- *
- * <pre>
- * Control whether a reference clock is sent to the daughterboards,
- * and what frequency. The refclk is sent on d'board i/o pin 0.
- *
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-----------------------------------------------+-+------------+
- * | Reserved (Must be zero) |E| DIVISOR |
- * +-----------------------------------------------+-+------------+
- *
- * Bit 7 -- 1 turns on refclk, 0 allows IO use
- * Bits 6:0 Divider value
- * </pre>
- */
- virtual bool write_refclk(int which_side, int value) = 0;
-
- virtual bool write_atr_mask(int which_side, int value) = 0;
- virtual bool write_atr_txval(int which_side, int value) = 0;
- virtual bool write_atr_rxval(int which_side, int value) = 0;
-
- /*!
- * \brief Write auxiliary digital to analog converter.
- *
- * \param which_side [0,1] which d'board
- * N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
- * SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
- * \param which_dac [2,3] TX slots must use only 2 and 3.
- * \param value [0,4095]
- * \returns true iff successful
- */
- virtual bool write_aux_dac (int which_side, int which_dac, int value) = 0;
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param which_side [0,1] which d'board
- * \param which_adc [0,1]
- * \param value return 12-bit value [0,4095]
- * \returns true iff successful
- */
- virtual bool read_aux_adc (int which_side, int which_adc, int *value) = 0;
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param which_side [0,1] which d'board
- * \param which_adc [0,1]
- * \returns value in the range [0,4095] if successful, else READ_FAILED.
- */
- virtual int read_aux_adc (int which_side, int which_adc) = 0;
-
- /*!
- * \brief returns current fusb block size
- */
- virtual int block_size() const = 0;
-
- /*!
- * \brief returns A/D or D/A converter rate in Hz
- */
- virtual long converter_rate() const = 0;
-
- // END virtual daughterboard control functions
-
- // ----------------------------------------------------------------
- // Low level implementation routines.
- // You probably shouldn't be using these...
- //
-
- bool _set_led (int which_led, bool on);
-
- /*!
- * \brief Write FPGA register.
- * \param regno 7-bit register number
- * \param value 32-bit value
- * \returns true iff successful
- */
- bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
-
- /*!
- * \brief Read FPGA register.
- * \param regno 7-bit register number
- * \param value 32-bit value
- * \returns true iff successful
- */
- bool _read_fpga_reg (int regno, int *value); //< 7-bit regno, 32-bit value
-
- /*!
- * \brief Read FPGA register.
- * \param regno 7-bit register number
- * \returns register value if successful, else READ_FAILED
- */
- int _read_fpga_reg (int regno);
-
- /*!
- * \brief Write FPGA register with mask.
- * \param regno 7-bit register number
- * \param value 16-bit value
- * \param mask 16-bit value
- * \returns true if successful
- * Only use this for registers who actually implement a mask in the verilog firmware, like FR_RX_MASTER_SLAVE
- */
- bool _write_fpga_reg_masked (int regno, int value, int mask);
-
- /*!
- * \brief Write AD9862 register.
- * \param which_codec 0 or 1
- * \param regno 6-bit register number
- * \param value 8-bit value
- * \returns true iff successful
- */
- bool _write_9862 (int which_codec, int regno, unsigned char value);
-
- /*!
- * \brief Read AD9862 register.
- * \param which_codec 0 or 1
- * \param regno 6-bit register number
- * \param value 8-bit value
- * \returns true iff successful
- */
- bool _read_9862 (int which_codec, int regno, unsigned char *value) const;
-
- /*!
- * \brief Read AD9862 register.
- * \param which_codec 0 or 1
- * \param regno 6-bit register number
- * \returns register value if successful, else READ_FAILED
- */
- int _read_9862 (int which_codec, int regno) const;
-
- /*!
- * \brief Write data to SPI bus peripheral.
- *
- * \param optional_header 0,1 or 2 bytes to write before buf.
- * \param enables bitmask of peripherals to write. See usrp_spi_defs.h
- * \param format transaction format. See usrp_spi_defs.h SPI_FMT_*
- * \param buf the data to write
- * \returns true iff successful
- * Writes are limited to a maximum of 64 bytes.
- *
- * If \p format specifies that optional_header bytes are present, they are
- * written to the peripheral immediately prior to writing \p buf.
- */
- bool _write_spi (int optional_header, int enables, int format, std::string buf);
-
- /*
- * \brief Read data from SPI bus peripheral.
- *
- * \param optional_header 0,1 or 2 bytes to write before buf.
- * \param enables bitmask of peripheral to read. See usrp_spi_defs.h
- * \param format transaction format. See usrp_spi_defs.h SPI_FMT_*
- * \param len number of bytes to read. Must be in [0,64].
- * \returns the data read if sucessful, else a zero length string.
- *
- * Reads are limited to a maximum of 64 bytes.
- *
- * If \p format specifies that optional_header bytes are present, they
- * are written to the peripheral first. Then \p len bytes are read from
- * the peripheral and returned.
- */
- std::string _read_spi (int optional_header, int enables, int format, int len);
-
- /*!
- * \brief Start data transfers.
- * Called in base class to derived class order.
- */
- bool start ();
-
- /*!
- * \brief Stop data transfers.
- * Called in base class to derived class order.
- */
- bool stop ();
-};
-
- /*!
- * \brief class for accessing the receive side of the USRP
- * \ingroup usrp
- */
-class usrp_basic_rx : public usrp_basic
-{
-private:
- fusb_devhandle *d_devhandle;
- fusb_ephandle *d_ephandle;
- int d_bytes_seen; // how many bytes we've seen
- bool d_first_read;
- bool d_rx_enable;
-
-protected:
- /*!
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename name of the rbf file to load
- * \param firmware_filename name of ihx file to load
- */
- usrp_basic_rx (int which_board,
- int fusb_block_size=0,
- int fusb_nblocks=0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- ); // throws if trouble
-
- bool set_rx_enable (bool on);
- bool rx_enable () const { return d_rx_enable; }
-
- bool disable_rx (); // conditional disable, return prev state
- void restore_rx (bool on); // conditional set
-
- void probe_rx_slots (bool verbose);
-
-public:
- ~usrp_basic_rx ();
-
- /*!
- * \brief invokes constructor, returns instance or 0 if trouble
- *
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename name of file that contains image to load into FPGA
- * \param firmware_filename name of file that contains image to load into FX2
- */
- static usrp_basic_rx *make (int which_board,
- int fusb_block_size=0,
- int fusb_nblocks=0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- );
-
- /*!
- * \brief tell the fpga the rate rx samples are coming from the A/D's
- *
- * div = fpga_master_clock_freq () / sample_rate
- *
- * sample_rate is determined by a myriad of registers
- * in the 9862. That's why you have to tell us, so
- * we can tell the fpga.
- */
- bool set_fpga_rx_sample_rate_divisor (unsigned int div);
-
- /*!
- * \brief read data from the D/A's via the FPGA.
- * \p len must be a multiple of 512 bytes.
- *
- * \returns the number of bytes read, or -1 on error.
- *
- * If overrun is non-NULL it will be set true iff an RX overrun is detected.
- */
- int read (void *buf, int len, bool *overrun);
-
-
- //! sampling rate of A/D converter
- virtual long converter_rate() const { return fpga_master_clock_freq(); } // 64M
- long adc_rate() const { return converter_rate(); }
- int daughterboard_id (int which_side) const { return d_dbid[which_side & 0x1]; }
-
- bool set_pga (int which_amp, double gain_in_db);
- double pga (int which_amp) const;
- double pga_min () const;
- double pga_max () const;
- double pga_db_per_step () const;
-
- bool _write_oe (int which_side, int value, int mask);
- bool write_io (int which_side, int value, int mask);
- bool read_io (int which_side, int *value);
- int read_io (int which_side);
- bool write_refclk(int which_side, int value);
- bool write_atr_mask(int which_side, int value);
- bool write_atr_txval(int which_side, int value);
- bool write_atr_rxval(int which_side, int value);
-
- bool write_aux_dac (int which_side, int which_dac, int value);
- bool read_aux_adc (int which_side, int which_adc, int *value);
- int read_aux_adc (int which_side, int which_adc);
-
- int block_size() const;
-
- // called in base class to derived class order
- bool start ();
- bool stop ();
-};
-
- /*!
- * \brief class for accessing the transmit side of the USRP
- * \ingroup usrp
- */
-class usrp_basic_tx : public usrp_basic
-{
-private:
- fusb_devhandle *d_devhandle;
- fusb_ephandle *d_ephandle;
- int d_bytes_seen; // how many bytes we've seen
- bool d_first_write;
- bool d_tx_enable;
-
- protected:
- /*!
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename name of file that contains image to load into FPGA
- * \param firmware_filename name of file that contains image to load into FX2
- */
- usrp_basic_tx (int which_board,
- int fusb_block_size=0,
- int fusb_nblocks=0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- ); // throws if trouble
-
- bool set_tx_enable (bool on);
- bool tx_enable () const { return d_tx_enable; }
-
- bool disable_tx (); // conditional disable, return prev state
- void restore_tx (bool on); // conditional set
-
- void probe_tx_slots (bool verbose);
-
-public:
-
- ~usrp_basic_tx ();
-
- /*!
- * \brief invokes constructor, returns instance or 0 if trouble
- *
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename name of file that contains image to load into FPGA
- * \param firmware_filename name of file that contains image to load into FX2
- */
- static usrp_basic_tx *make (int which_board, int fusb_block_size=0, int fusb_nblocks=0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- );
-
- /*!
- * \brief tell the fpga the rate tx samples are going to the D/A's
- *
- * div = fpga_master_clock_freq () * 2
- *
- * sample_rate is determined by a myriad of registers
- * in the 9862. That's why you have to tell us, so
- * we can tell the fpga.
- */
- bool set_fpga_tx_sample_rate_divisor (unsigned int div);
-
- /*!
- * \brief Write data to the A/D's via the FPGA.
- *
- * \p len must be a multiple of 512 bytes.
- * \returns number of bytes written or -1 on error.
- *
- * if \p underrun is non-NULL, it will be set to true iff
- * a transmit underrun condition is detected.
- */
- int write (const void *buf, int len, bool *underrun);
-
- /*
- * Block until all outstanding writes have completed.
- * This is typically used to assist with benchmarking
- */
- void wait_for_completion ();
-
- //! sampling rate of D/A converter
- virtual long converter_rate() const { return fpga_master_clock_freq () * 2; } // 128M
- long dac_rate() const { return converter_rate(); }
- int daughterboard_id (int which_side) const { return d_dbid[which_side & 0x1]; }
-
- bool set_pga (int which_amp, double gain_in_db);
- double pga (int which_amp) const;
- double pga_min () const;
- double pga_max () const;
- double pga_db_per_step () const;
-
- bool _write_oe (int which_side, int value, int mask);
- bool write_io (int which_side, int value, int mask);
- bool read_io (int which_side, int *value);
- int read_io (int which_side);
- bool write_refclk(int which_side, int value);
- bool write_atr_mask(int which_side, int value);
- bool write_atr_txval(int which_side, int value);
- bool write_atr_rxval(int which_side, int value);
-
- bool write_aux_dac (int which_side, int which_dac, int value);
- bool read_aux_adc (int which_side, int which_adc, int *value);
- int read_aux_adc (int which_side, int which_adc);
-
- int block_size() const;
-
- // called in base class to derived class order
- bool start ();
- bool stop ();
-};
-
-#endif
diff --git a/usrp/host/lib/legacy/usrp_bytesex.h b/usrp/host/lib/legacy/usrp_bytesex.h
deleted file mode 100644
index 331db31c9..000000000
--- a/usrp/host/lib/legacy/usrp_bytesex.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_USRP_BYTESEX_H
-#define INCLUDED_USRP_BYTESEX_H
-
-/*!
- * \brief routines for convertering between host and usrp byte order
- *
- * Prior to including this file, the user must include "config.h"
- * which will or won't define WORDS_BIGENDIAN based on the
- * result of the AC_C_BIGENDIAN autoconf test.
- */
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-
-#warning Using non-portable code (likely wrong other than ILP32).
-
-static inline unsigned short int
-bswap_16 (unsigned short int x)
-{
- return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
-}
-
-static inline unsigned int
-bswap_32 (unsigned int x)
-{
- return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
-}
-#endif
-
-
-#ifdef WORDS_BIGENDIAN
-
-static inline unsigned int
-host_to_usrp_u32 (unsigned int x)
-{
- return bswap_32(x);
-}
-
-static inline unsigned int
-usrp_to_host_u32 (unsigned int x)
-{
- return bswap_32(x);
-}
-
-static inline short int
-host_to_usrp_short (short int x)
-{
- return bswap_16 (x);
-}
-
-static inline short int
-usrp_to_host_short (short int x)
-{
- return bswap_16 (x);
-}
-
-#else
-
-static inline unsigned int
-host_to_usrp_u32 (unsigned int x)
-{
- return x;
-}
-
-static inline unsigned int
-usrp_to_host_u32 (unsigned int x)
-{
- return x;
-}
-
-static inline short int
-host_to_usrp_short (short int x)
-{
- return x;
-}
-
-static inline short int
-usrp_to_host_short (unsigned short int x)
-{
- return x;
-}
-
-#endif
-
-#endif /* INCLUDED_USRP_BYTESEX_H */
diff --git a/usrp/host/lib/legacy/usrp_local_sighandler.h b/usrp/host/lib/legacy/usrp_local_sighandler.h
deleted file mode 100644
index ee336750f..000000000
--- a/usrp/host/lib/legacy/usrp_local_sighandler.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_USRP_LOCAL_SIGHANDLER_H
-#define INCLUDED_USRP_LOCAL_SIGHANDLER_H
-
-#include <signal.h>
-#include <string>
-
-/*!
- * \brief Representation of signal.
- */
-class usrp_signal
-{
- int d_signum;
-public:
- usrp_signal (int signum) : d_signum (signum) {}
- int signal () const { return d_signum; }
- std::string name () const;
-};
-
-
-/*!
- * \brief Get and set signal handler.
- *
- * Constructor installs new handler, destructor reinstalls
- * original value.
- */
-class usrp_local_sighandler {
- int d_signum;
-#ifdef HAVE_SIGACTION
- struct sigaction d_old_action;
-#endif
-public:
- usrp_local_sighandler (int signum, void (*new_handler)(int));
- ~usrp_local_sighandler ();
-
- /* throw usrp_signal (signum) */
- static void throw_signal (int signum) throw (usrp_signal);
-};
-
-#endif /* INCLUDED_USRP_LOCAL_SIGHANDLER_H */
diff --git a/usrp/host/lib/legacy/usrp_prims.h b/usrp/host/lib/legacy/usrp_prims.h
deleted file mode 100644
index aa1347423..000000000
--- a/usrp/host/lib/legacy/usrp_prims.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2006 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * Low level primitives for directly messing with USRP hardware.
- *
- * If you're trying to use the USRP, you'll probably want to take a look
- * at the usrp_rx and usrp_tx classes. They hide a bunch of low level details
- * and provide high performance streaming i/o.
- *
- * This interface is built on top of libusb, which allegedly works under
- * Linux, *BSD and Mac OS/X. http://libusb.sourceforge.net
- */
-
-#ifndef _USRP_PRIMS_H_
-#define _USRP_PRIMS_H_
-
-#include <usrp_slots.h>
-#include <string>
-
-static const int USRP_HASH_SIZE = 16;
-
-enum usrp_load_status_t { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED };
-
-struct usb_dev_handle;
-struct usb_device;
-
-/*!
- * \brief initialize libusb; probe busses and devices.
- * Safe to call more than once.
- */
-void usrp_one_time_init ();
-
-/*
- * force a rescan of the buses and devices
- */
-void usrp_rescan ();
-
-/*!
- * \brief locate Nth (zero based) USRP device in system.
- * Return pointer or 0 if not found.
- *
- * The following kinds of devices are considered USRPs:
- *
- * unconfigured USRP (no firwmare loaded)
- * configured USRP (firmware loaded)
- * unconfigured Cypress FX2 (only if fx2_ok_p is true)
- */
-struct usb_device *usrp_find_device (int nth, bool fx2_ok_p = false);
-
-bool usrp_usrp_p (struct usb_device *q); //< is this a USRP
-bool usrp_usrp0_p (struct usb_device *q); //< is this a USRP Rev 0
-bool usrp_usrp1_p (struct usb_device *q); //< is this a USRP Rev 1
-bool usrp_usrp2_p (struct usb_device *q); //< is this a USRP Rev 2
-int usrp_hw_rev (struct usb_device *q); //< return h/w rev code
-
-bool usrp_fx2_p (struct usb_device *q); //< is this an unconfigured Cypress FX2
-
-bool usrp_unconfigured_usrp_p (struct usb_device *q); //< some kind of unconfigured USRP
-bool usrp_configured_usrp_p (struct usb_device *q); //< some kind of configured USRP
-
-/*!
- * \brief given a usb_device return an instance of the appropriate usb_dev_handle
- *
- * These routines claim the specified interface and select the
- * correct alternate interface. (USB nomenclature is totally screwed!)
- *
- * If interface can't be opened, or is already claimed by some other
- * process, 0 is returned.
- */
-struct usb_dev_handle *usrp_open_cmd_interface (struct usb_device *dev);
-struct usb_dev_handle *usrp_open_rx_interface (struct usb_device *dev);
-struct usb_dev_handle *usrp_open_tx_interface (struct usb_device *dev);
-
-/*!
- * \brief close interface.
- */
-bool usrp_close_interface (struct usb_dev_handle *udh);
-
-/*!
- * \brief load intel hex format file into USRP/Cypress FX2 (8051).
- *
- * The filename extension is typically *.ihx
- *
- * Note that loading firmware may cause the device to renumerate. I.e.,
- * change its configuration, invalidating the current device handle.
- */
-
-usrp_load_status_t
-usrp_load_firmware (struct usb_dev_handle *udh, const char *filename, bool force);
-
-/*!
- * \brief load intel hex format file into USRP FX2 (8051).
- *
- * The filename extension is typically *.ihx
- *
- * Note that loading firmware may cause the device to renumerate. I.e.,
- * change its configuration, invalidating the current device handle.
- * If the result is ULS_OK, usrp_load_firmware_nth delays 1 second
- * then rescans the busses and devices.
- */
-usrp_load_status_t
-usrp_load_firmware_nth (int nth, const char *filename, bool force);
-
-/*!
- * \brief load fpga configuration bitstream
- */
-usrp_load_status_t
-usrp_load_fpga (struct usb_dev_handle *udh, const char *filename, bool force);
-
-/*!
- * \brief load the regular firmware and fpga bitstream in the Nth USRP.
- *
- * This is the normal starting point...
- */
-bool usrp_load_standard_bits (int nth, bool force,
- const std::string fpga_filename = "",
- const std::string firmware_filename = "");
-
-/*!
- * \brief copy the given \p hash into the USRP hash slot \p which.
- * The usrp implements two hash slots, 0 and 1.
- */
-bool usrp_set_hash (struct usb_dev_handle *udh, int which,
- const unsigned char hash[USRP_HASH_SIZE]);
-
-/*!
- * \brief retrieve the \p hash from the USRP hash slot \p which.
- * The usrp implements two hash slots, 0 and 1.
- */
-bool usrp_get_hash (struct usb_dev_handle *udh, int which,
- unsigned char hash[USRP_HASH_SIZE]);
-
-bool usrp_write_fpga_reg (struct usb_dev_handle *udh, int reg, int value);
-bool usrp_read_fpga_reg (struct usb_dev_handle *udh, int reg, int *value);
-bool usrp_set_fpga_reset (struct usb_dev_handle *udh, bool on);
-bool usrp_set_fpga_tx_enable (struct usb_dev_handle *udh, bool on);
-bool usrp_set_fpga_rx_enable (struct usb_dev_handle *udh, bool on);
-bool usrp_set_fpga_tx_reset (struct usb_dev_handle *udh, bool on);
-bool usrp_set_fpga_rx_reset (struct usb_dev_handle *udh, bool on);
-bool usrp_set_led (struct usb_dev_handle *udh, int which, bool on);
-
-bool usrp_check_rx_overrun (struct usb_dev_handle *udh, bool *overrun_p);
-bool usrp_check_tx_underrun (struct usb_dev_handle *udh, bool *underrun_p);
-
-// i2c_read and i2c_write are limited to a maximum len of 64 bytes.
-
-bool usrp_i2c_write (struct usb_dev_handle *udh, int i2c_addr,
- const void *buf, int len);
-
-bool usrp_i2c_read (struct usb_dev_handle *udh, int i2c_addr,
- void *buf, int len);
-
-// spi_read and spi_write are limited to a maximum of 64 bytes
-// See usrp_spi_defs.h for more info
-
-bool usrp_spi_write (struct usb_dev_handle *udh,
- int optional_header, int enables, int format,
- const void *buf, int len);
-
-bool usrp_spi_read (struct usb_dev_handle *udh,
- int optional_header, int enables, int format,
- void *buf, int len);
-
-
-bool usrp_9862_write (struct usb_dev_handle *udh,
- int which_codec, // [0, 1]
- int regno, // [0, 63]
- int value); // [0, 255]
-
-bool usrp_9862_read (struct usb_dev_handle *udh,
- int which_codec, // [0, 1]
- int regno, // [0, 63]
- unsigned char *value); // [0, 255]
-
-/*!
- * \brief Write multiple 9862 regs at once.
- *
- * \p buf contains alternating register_number, register_value pairs.
- * \p len must be even and is the length of buf in bytes.
- */
-bool usrp_9862_write_many (struct usb_dev_handle *udh, int which_codec,
- const unsigned char *buf, int len);
-
-
-/*!
- * \brief write specified regs to all 9862's in the system
- */
-bool usrp_9862_write_many_all (struct usb_dev_handle *udh,
- const unsigned char *buf, int len);
-
-
-// Write 24LC024 / 24LC025 EEPROM on motherboard or daughterboard.
-// Which EEPROM is determined by i2c_addr. See i2c_addr.h
-
-bool usrp_eeprom_write (struct usb_dev_handle *udh, int i2c_addr,
- int eeprom_offset, const void *buf, int len);
-
-
-// Read 24LC024 / 24LC025 EEPROM on motherboard or daughterboard.
-// Which EEPROM is determined by i2c_addr. See i2c_addr.h
-
-bool usrp_eeprom_read (struct usb_dev_handle *udh, int i2c_addr,
- int eeprom_offset, void *buf, int len);
-
-
-// Slot specific i/o routines
-
-/*!
- * \brief write to the specified aux dac.
- *
- * \p slot: which Tx or Rx slot to write.
- * N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's
- * SLOT_TX_B and SLOT_RX_B share the same AUX DAC's
- *
- * \p which_dac: [0,3] RX slots must use only 0 and 1.
- * TX slots must use only 2 and 3.
- *
- * AUX DAC 3 is really the 9862 sigma delta output.
- *
- * \p value to write to aux dac. All dacs take straight
- * binary values. Although dacs 0, 1 and 2 are 8-bit and dac 3 is 12-bit,
- * the interface is in terms of 12-bit values [0,4095]
- */
-bool usrp_write_aux_dac (struct usb_dev_handle *uhd, int slot,
- int which_dac, int value);
-
-/*!
- * \brief Read the specified aux adc
- *
- * \p slot: which Tx or Rx slot to read aux dac
- * \p which_adc: [0,1] which of the two adcs to read
- * \p *value: return value, 12-bit straight binary.
- */
-bool usrp_read_aux_adc (struct usb_dev_handle *udh, int slot,
- int which_adc, int *value);
-
-
-/*!
- * \brief usrp daughterboard id to name mapping
- */
-const std::string usrp_dbid_to_string (int dbid);
-
-
-enum usrp_dbeeprom_status_t { UDBE_OK, UDBE_BAD_SLOT, UDBE_NO_EEPROM, UDBE_INVALID_EEPROM };
-
-struct usrp_dboard_eeprom {
- unsigned short id; // d'board identifier code
- unsigned short oe; // fpga output enables:
- // If bit set, i/o pin is an output from FPGA.
- short offset[2]; // ADC/DAC offset correction
-};
-
-/*!
- * \brief Read and return parsed daughterboard eeprom
- */
-usrp_dbeeprom_status_t
-usrp_read_dboard_eeprom (struct usb_dev_handle *udh,
- int slot_id, usrp_dboard_eeprom *eeprom);
-
-/*!
- * \brief write ADC/DAC offset calibration constants to d'board eeprom
- */
-bool usrp_write_dboard_offsets (struct usb_dev_handle *udh, int slot_id,
- short offset0, short offset1);
-
-/*!
- * \brief return a usrp's serial number.
- *
- * Note that this only works on a configured usrp.
- * \returns non-zero length string iff successful.
- */
-std::string usrp_serial_number(struct usb_dev_handle *udh);
-
-#endif /* _USRP_PRIMS_H_ */
diff --git a/usrp/host/lib/legacy/usrp_slots.h b/usrp/host/lib/legacy/usrp_slots.h
deleted file mode 100644
index d2c50fc47..000000000
--- a/usrp/host/lib/legacy/usrp_slots.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_USRP_SLOTS_H
-#define INCLUDED_USRP_SLOTS_H
-
-// daughterboard slot numbers used in some calls
-
-static const int SLOT_TX_A = 0;
-static const int SLOT_RX_A = 1;
-static const int SLOT_TX_B = 2;
-static const int SLOT_RX_B = 3;
-
-#endif /* INCLUDED_USRP_SLOTS_H */
diff --git a/usrp/host/lib/legacy/usrp_standard.h b/usrp/host/lib/legacy/usrp_standard.h
deleted file mode 100644
index 734fff4b5..000000000
--- a/usrp/host/lib/legacy/usrp_standard.h
+++ /dev/null
@@ -1,452 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_USRP_STANDARD_H
-#define INCLUDED_USRP_STANDARD_H
-
-#include <usrp_basic.h>
-#include <boost/shared_ptr.hpp>
-#include <usrp_tune_result.h>
-
-class usrp_standard_tx;
-class usrp_standard_rx;
-
-typedef boost::shared_ptr<usrp_standard_tx> usrp_standard_tx_sptr;
-typedef boost::shared_ptr<usrp_standard_rx> usrp_standard_rx_sptr;
-
-/*!
- * \ingroup usrp
- */
-class usrp_standard_common
-{
- int d_fpga_caps; // capability register val
-
-protected:
- usrp_standard_common(usrp_basic *parent);
-
-public:
- /*!
- *\brief does the FPGA implement the final Rx half-band filter?
- * If it doesn't, the maximum decimation factor with proper gain
- * is 1/2 of what it would otherwise be.
- */
- bool has_rx_halfband() const;
-
- /*!
- * \brief number of digital downconverters implemented in the FPGA
- * This will be 0, 1, 2 or 4.
- */
- int nddcs() const;
-
- /*!
- *\brief does the FPGA implement the initial Tx half-band filter?
- */
- bool has_tx_halfband() const;
-
- /*!
- * \brief number of digital upconverters implemented in the FPGA
- * This will be 0, 1, or 2.
- */
- int nducs() const;
-
- /*!
- * \brief Calculate the frequency to use for setting the digital up or down converter.
- *
- * \param target_freq is the desired RF frequency (Hz).
- * \param baseband_freq is the RF frequency that corresponds to DC in the IF coming from the d'board.
- * \param fs is the sampling frequency.
- * \param[out] dxc_freq the frequency to program into the DDC (or DUC).
- * \param[out] inverted is true if we're operating in an inverted Nyquist zone.
- */
- static void calc_dxc_freq(double target_freq, double baseband_freq, double fs,
- double *dxc_freq, bool *inverted);
-};
-
-/*!
- * \brief The C++ interface the receive side of the USRP
- * \ingroup usrp
- *
- * This is the recommended interface to USRP receive functionality
- * for applications that use the USRP but not GNU Radio.
- */
-class usrp_standard_rx : public usrp_basic_rx, public usrp_standard_common
-{
- private:
- static const int MAX_CHAN = 4;
- unsigned int d_decim_rate;
- int d_nchan;
- int d_sw_mux;
- int d_hw_mux;
- double d_rx_freq[MAX_CHAN];
-
- protected:
- usrp_standard_rx (int which_board,
- unsigned int decim_rate,
- int nchan = 1,
- int mux = -1,
- int mode = 0,
- int fusb_block_size = 0,
- int fusb_nblocks = 0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- ); // throws if trouble
-
- bool write_hw_mux_reg ();
-
- public:
-
- enum {
- FPGA_MODE_NORMAL = 0x00,
- FPGA_MODE_LOOPBACK = 0x01,
- FPGA_MODE_COUNTING = 0x02,
- FPGA_MODE_COUNTING_32BIT = 0x04
- };
-
- ~usrp_standard_rx ();
-
- /*!
- * \brief invokes constructor, returns shared_ptr or shared_ptr equivalent of 0 if trouble
- *
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param decim_rate decimation factor
- * \param nchan number of channels
- * \param mux Rx mux setting, \sa set_mux
- * \param mode mode
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename Name of rbf file to load
- * \param firmware_filename Name of ihx file to load
- */
- static usrp_standard_rx_sptr make(int which_board,
- unsigned int decim_rate,
- int nchan = 1,
- int mux = -1,
- int mode = 0,
- int fusb_block_size = 0,
- int fusb_nblocks = 0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- );
- /*!
- * \brief Set decimator rate. \p rate MUST BE EVEN and in [8, 256].
- *
- * The final complex sample rate across the USB is
- * adc_freq () / decim_rate () * nchannels ()
- */
- bool set_decim_rate (unsigned int rate);
-
- /*!
- * \brief Set number of active channels. \p nchannels must be 1, 2 or 4.
- *
- * The final complex sample rate across the USB is
- * adc_freq () / decim_rate () * nchannels ()
- */
- bool set_nchannels (int nchannels);
-
- /*!
- * \brief Set input mux configuration.
- *
- * This determines which ADC (or constant zero) is connected to
- * each DDC input. There are 4 DDCs. Each has two inputs.
- *
- * <pre>
- * Mux value:
- *
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Q3 | I3 | Q2 | I2 | Q1 | I1 | Q0 | I0 |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- *
- * Each 4-bit I field is either 0,1,2,3
- * Each 4-bit Q field is either 0,1,2,3 or 0xf (input is const zero)
- * All Q's must be 0xf or none of them may be 0xf
- * </pre>
- */
- bool set_mux (int mux);
-
- /*!
- * Determine the appropriate Rx mux value as a function of the subdevice choosen
- * and the characteristics of the respective daughterboard.
- */
- int determine_rx_mux_value(const usrp_subdev_spec &ss);
- int determine_rx_mux_value(const usrp_subdev_spec &ss_a, const usrp_subdev_spec &ss_b);
-
- /*!
- * \brief set the frequency of the digital down converter.
- *
- * \p channel must be in the range [0,3]. \p freq is the center
- * frequency in Hz. \p freq may be either negative or postive.
- * The frequency specified is quantized. Use rx_freq to retrieve
- * the actual value used.
- */
- bool set_rx_freq (int channel, double freq);
-
- /*!
- * \brief set fpga mode
- */
- bool set_fpga_mode (int mode);
-
- /*!
- * \brief Set the digital down converter phase register.
- *
- * \param channel which ddc channel [0, 3]
- * \param phase 32-bit integer phase value.
- */
- bool set_ddc_phase(int channel, int phase);
-
- /*!
- * \brief Specify Rx data format.
- *
- * \param format format specifier
- *
- * Rx data format control register
- *
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-----------------------------------------+-+-+---------+-------+
- * | Reserved (Must be zero) |B|Q| WIDTH | SHIFT |
- * +-----------------------------------------+-+-+---------+-------+
- *
- * SHIFT specifies arithmetic right shift [0, 15]
- * WIDTH specifies bit-width of I & Q samples across the USB [1, 16] (not all valid)
- * Q if set deliver both I & Q, else just I
- * B if set bypass half-band filter.
- *
- * Right now the acceptable values are:
- *
- * B Q WIDTH SHIFT
- * 0 1 16 0
- * 0 1 8 8
- *
- * More valid combos to come.
- *
- * Default value is 0x00000300 16-bits, 0 shift, deliver both I & Q.
- */
- bool set_format(unsigned int format);
-
- static unsigned int make_format(int width=16, int shift=0,
- bool want_q=true, bool bypass_halfband=false);
- static int format_width(unsigned int format);
- static int format_shift(unsigned int format);
- static bool format_want_q(unsigned int format);
- static bool format_bypass_halfband(unsigned int format);
-
- /*!
- * \brief High-level "tune" method. Works for the single channel case.
- *
- * This method adjusts both the daughterboard LO and the DDC so that
- * target_freq ends up at DC in the complex baseband samples.
- *
- * \param chan which DDC channel we're controlling (almost always 0).
- * \param db the daughterboard we're controlling.
- * \param target_freq the RF frequency we want at DC in the complex baseband.
- * \param[out] result details how the hardware was configured.
- *
- * \returns true iff everything was successful.
- */
- bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result);
-
-
- // ACCESSORS
- unsigned int decim_rate () const;
- double rx_freq (int channel) const;
- int nchannels () const;
- int mux () const;
- unsigned int format () const;
-
- // called in base class to derived class order
- bool start ();
- bool stop ();
-};
-
-// ----------------------------------------------------------------
-
-/*!
- * \brief The C++ interface the transmit side of the USRP
- * \ingroup usrp
- *
- * This is the recommended interface to USRP transmit functionality
- * for applications that use the USRP but not GNU Radio.
- *
- * Uses digital upconverter (coarse & fine modulators) in AD9862...
- */
-class usrp_standard_tx : public usrp_basic_tx, public usrp_standard_common
-{
- public:
- enum coarse_mod_t {
- CM_NEG_FDAC_OVER_4, // -32 MHz
- CM_NEG_FDAC_OVER_8, // -16 MHz
- CM_OFF,
- CM_POS_FDAC_OVER_8, // +16 MHz
- CM_POS_FDAC_OVER_4 // +32 MHz
- };
-
- protected:
- static const int MAX_CHAN = 2;
- unsigned int d_interp_rate;
- int d_nchan;
- int d_sw_mux;
- int d_hw_mux;
- double d_tx_freq[MAX_CHAN];
- coarse_mod_t d_coarse_mod[MAX_CHAN];
- unsigned char d_tx_modulator_shadow[MAX_CHAN];
-
- virtual bool set_coarse_modulator (int channel, coarse_mod_t cm);
- usrp_standard_tx::coarse_mod_t coarse_modulator (int channel) const;
-
- protected:
- usrp_standard_tx (int which_board,
- unsigned int interp_rate,
- int nchan = 1,
- int mux = -1,
- int fusb_block_size = 0,
- int fusb_nblocks = 0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- ); // throws if trouble
-
- bool write_hw_mux_reg ();
-
- public:
- ~usrp_standard_tx ();
-
- /*!
- * \brief invokes constructor, returns shared_ptr or shared_ptr equivalent of 0 if trouble
- *
- * \param which_board Which USRP board on usb (not particularly useful; use 0)
- * \param interp_rate interpolation factor
- * \param nchan number of channels
- * \param mux Tx mux setting, \sa set_mux
- * \param fusb_block_size fast usb xfer block size. Must be a multiple of 512.
- * Use zero for a reasonable default.
- * \param fusb_nblocks number of fast usb URBs to allocate. Use zero for a reasonable default.
- * \param fpga_filename Name of rbf file to load
- * \param firmware_filename Name of ihx file to load
- */
- static usrp_standard_tx_sptr make(int which_board,
- unsigned int interp_rate,
- int nchan = 1,
- int mux = -1,
- int fusb_block_size = 0,
- int fusb_nblocks = 0,
- const std::string fpga_filename = "",
- const std::string firmware_filename = ""
- );
-
- /*!
- * \brief Set interpolator rate. \p rate must be in [4, 512] and a multiple of 4.
- *
- * The final complex sample rate across the USB is
- * dac_freq () / interp_rate () * nchannels ()
- */
- virtual bool set_interp_rate (unsigned int rate);
-
- /*!
- * \brief Set number of active channels. \p nchannels must be 1 or 2.
- *
- * The final complex sample rate across the USB is
- * dac_freq () / decim_rate () * nchannels ()
- */
- bool set_nchannels (int nchannels);
-
- /*!
- * \brief Set output mux configuration.
- *
- * <pre>
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-------------------------------+-------+-------+-------+-------+
- * | | DAC3 | DAC2 | DAC1 | DAC0 |
- * +-------------------------------+-------+-------+-------+-------+
- *
- * There are two interpolators with complex inputs and outputs.
- * There are four DACs.
- *
- * Each 4-bit DACx field specifies the source for the DAC and
- * whether or not that DAC is enabled. Each subfield is coded
- * like this:
- *
- * 3 2 1 0
- * +-+-----+
- * |E| N |
- * +-+-----+
- *
- * Where E is set if the DAC is enabled, and N specifies which
- * interpolator output is connected to this DAC.
- *
- * N which interp output
- * --- -------------------
- * 0 chan 0 I
- * 1 chan 0 Q
- * 2 chan 1 I
- * 3 chan 1 Q
- * </pre>
- */
- bool set_mux (int mux);
-
- /*!
- * Determine the appropriate Tx mux value as a function of the subdevice choosen
- * and the characteristics of the respective daughterboard.
- */
- int determine_tx_mux_value(const usrp_subdev_spec &ss);
- int determine_tx_mux_value(const usrp_subdev_spec &ss_a, const usrp_subdev_spec &ss_b);
-
- /*!
- * \brief set the frequency of the digital up converter.
- *
- * \p channel must be in the range [0,1]. \p freq is the center
- * frequency in Hz. It must be in the range [-44M, 44M].
- * The frequency specified is quantized. Use tx_freq to retrieve
- * the actual value used.
- */
- virtual bool set_tx_freq (int channel, double freq); // chan: [0,1]
-
- // ACCESSORS
- unsigned int interp_rate () const;
- double tx_freq (int channel) const;
- int nchannels () const;
- int mux () const;
-
- /*!
- * \brief High-level "tune" method. Works for the single channel case.
- *
- * This method adjusts both the daughterboard LO and the DUC so that
- * DC in the complex baseband samples ends up at RF target_freq.
- *
- * \param chan which DUC channel we're controlling (usually == which_side).
- * \param db the daughterboard we're controlling.
- * \param target_freq the RF frequency we want our baseband translated to.
- * \param[out] result details how the hardware was configured.
- *
- * \returns true iff everything was successful.
- */
- bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result);
-
-
- // called in base class to derived class order
- bool start ();
- bool stop ();
-};
-
-#endif /* INCLUDED_USRP_STANDARD_H */
diff --git a/usrp/host/lib/legacy/usrp_subdev_spec.h b/usrp/host/lib/legacy/usrp_subdev_spec.h
deleted file mode 100644
index e841ff832..000000000
--- a/usrp/host/lib/legacy/usrp_subdev_spec.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_USRP_SUBDEV_SPEC_H
-#define INCLUDED_USRP_SUBDEV_SPEC_H
-
-/*!
- * \brief specify a daughterboard and subdevice on a daughterboard.
- *
- * In the USRP1, there are two sides, A and B.
- *
- * A daughterboard generally implements a single subdevice, but may in
- * general implement any number of subdevices. At this time, all daughterboards
- * with the exception of the Basic Rx and LF Rx implement a single subdevice.
- *
- * The Basic Rx and LF Rx implement 2 subdevices (soon 3). Subdevice
- * 0 routes input RX-A to the DDC I input and routes a constant zero
- * to the DDC Q input. Similarly, subdevice 1 routes input RX-B to
- * the DDC I input and routes a constant zero to the DDC Q
- * input. Subdevice 2 (when implemented) will route RX-A to the DDC I
- * input and RX-B to the DDC Q input.
- */
-
-struct usrp_subdev_spec {
- unsigned int side; // 0 -> A; 1 -> B
- unsigned int subdev; // which subdevice (usually zero)
-
- usrp_subdev_spec(unsigned int _side = 0, unsigned int _subdev = 0)
- : side(_side), subdev(_subdev) {}
-};
-
-#endif /* INCLUDED_USRP_SUBDEV_SPEC_H */
diff --git a/usrp/host/lib/legacy/usrp_tune_result.h b/usrp/host/lib/legacy/usrp_tune_result.h
deleted file mode 100644
index 200541a37..000000000
--- a/usrp/host/lib/legacy/usrp_tune_result.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_USRP_TUNE_RESULT_H
-#define INCLUDED_USRP_TUNE_RESULT_H
-
-class usrp_tune_result
-{
-public:
- // RF frequency that corresponds to DC in the IF
- double baseband_freq;
-
- // frequency programmed into the DDC/DUC
- double dxc_freq;
-
- // residual frequency (typically < 0.01 Hz)
- double residual_freq;
-
- // is the spectrum inverted?
- bool inverted;
-
- usrp_tune_result(double baseband=0, double dxc=0, double residual=0, bool _inverted=false)
- : baseband_freq(baseband), dxc_freq(dxc),
- residual_freq(residual), inverted(_inverted) {}
-};
-
-#endif /* INCLUDED_USRP_TUNE_RESULT_H */
diff --git a/usrp/host/lib/legacy/db_wbx.cc b/usrp/host/lib/limbo/db_wbx.cc
index 9f1d72939..9f1d72939 100644
--- a/usrp/host/lib/legacy/db_wbx.cc
+++ b/usrp/host/lib/limbo/db_wbx.cc
diff --git a/usrp/host/lib/legacy/db_wbx.h b/usrp/host/lib/limbo/db_wbx.h
index 3202d368c..3202d368c 100644
--- a/usrp/host/lib/legacy/db_wbx.h
+++ b/usrp/host/lib/limbo/db_wbx.h
diff --git a/usrp/host/lib/legacy/md5.c b/usrp/host/lib/md5.c
index b15ab390f..b15ab390f 100644
--- a/usrp/host/lib/legacy/md5.c
+++ b/usrp/host/lib/md5.c
diff --git a/usrp/host/lib/legacy/md5.h b/usrp/host/lib/md5.h
index 4a4e790c1..4a4e790c1 100644
--- a/usrp/host/lib/legacy/md5.h
+++ b/usrp/host/lib/md5.h
diff --git a/usrp/host/lib/legacy/mld_threads.h b/usrp/host/lib/mld_threads.h
index 322f557b6..322f557b6 100644
--- a/usrp/host/lib/legacy/mld_threads.h
+++ b/usrp/host/lib/mld_threads.h
diff --git a/usrp/host/lib/legacy/rate_to_regval.h b/usrp/host/lib/rate_to_regval.h
index 1ffdc0f69..1ffdc0f69 100644
--- a/usrp/host/lib/legacy/rate_to_regval.h
+++ b/usrp/host/lib/rate_to_regval.h
diff --git a/usrp/host/lib/legacy/std_paths.h.in b/usrp/host/lib/std_paths.h.in
index e09499e0b..e09499e0b 100644
--- a/usrp/host/lib/legacy/std_paths.h.in
+++ b/usrp/host/lib/std_paths.h.in
diff --git a/usrp/host/lib/legacy/usrp_basic.cc b/usrp/host/lib/usrp_basic.cc
index 295c62f8c..4f3df5212 100644
--- a/usrp/host/lib/legacy/usrp_basic.cc
+++ b/usrp/host/lib/usrp_basic.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003,2004,2008 Free Software Foundation, Inc.
+ * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,8 +24,8 @@
#include "config.h"
#endif
-#include "usrp_basic.h"
-#include "usrp_prims.h"
+#include <usrp/usrp_basic.h>
+#include "usrp/usrp_prims.h"
#include "usrp_interfaces.h"
#include "fpga_regs_common.h"
#include "fpga_regs_standard.h"
diff --git a/usrp/host/lib/legacy/usrp_config.cc b/usrp/host/lib/usrp_config.cc
index fcf207f68..fcf207f68 100644
--- a/usrp/host/lib/legacy/usrp_config.cc
+++ b/usrp/host/lib/usrp_config.cc
diff --git a/usrp/host/lib/legacy/usrp_config.h b/usrp/host/lib/usrp_config.h
index ee5cb63bd..ee5cb63bd 100644
--- a/usrp/host/lib/legacy/usrp_config.h
+++ b/usrp/host/lib/usrp_config.h
diff --git a/usrp/host/lib/legacy/usrp_dbid.dat b/usrp/host/lib/usrp_dbid.dat
index bd7fd7ecb..bd7fd7ecb 100644
--- a/usrp/host/lib/legacy/usrp_dbid.dat
+++ b/usrp/host/lib/usrp_dbid.dat
diff --git a/usrp/host/lib/legacy/usrp_local_sighandler.cc b/usrp/host/lib/usrp_local_sighandler.cc
index 69cde0b37..59013972e 100644
--- a/usrp/host/lib/legacy/usrp_local_sighandler.cc
+++ b/usrp/host/lib/usrp_local_sighandler.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -29,7 +29,7 @@
#include "config.h"
#endif
-#include <usrp_local_sighandler.h>
+#include <usrp/usrp_local_sighandler.h>
#include <stdexcept>
#include <stdio.h>
#include <string.h>
diff --git a/usrp/host/lib/legacy/usrp_prims.cc b/usrp/host/lib/usrp_prims.cc
index c2f74f5f1..3d87d2459 100644
--- a/usrp/host/lib/legacy/usrp_prims.cc
+++ b/usrp/host/lib/usrp_prims.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003,2004,2006 Free Software Foundation, Inc.
+ * Copyright 2003,2004,2006,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,7 +24,7 @@
#include "config.h"
#endif
-#include "usrp_prims.h"
+#include "usrp/usrp_prims.h"
#include "usrp_commands.h"
#include "usrp_ids.h"
#include "usrp_i2c_addr.h"
diff --git a/usrp/host/lib/legacy/usrp_standard.cc b/usrp/host/lib/usrp_standard.cc
index b810f99cd..b112dbe0c 100644
--- a/usrp/host/lib/legacy/usrp_standard.cc
+++ b/usrp/host/lib/usrp_standard.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,9 +20,9 @@
* Boston, MA 02110-1301, USA.
*/
-#include <usrp_standard.h>
+#include <usrp/usrp_standard.h>
-#include "usrp_prims.h"
+#include "usrp/usrp_prims.h"
#include "fpga_regs_common.h"
#include "fpga_regs_standard.h"
#include <stdexcept>