summaryrefslogtreecommitdiff
path: root/usrp/host/apps
diff options
context:
space:
mode:
authorTom Rondeau2011-10-19 16:40:14 -0700
committerTom Rondeau2011-10-19 16:40:14 -0700
commiteb95f431badf197b249131a3119a92bd5317621b (patch)
tree645854a7e1e6cf57fcae56f196a5d828b913555e /usrp/host/apps
parente30b824e9165bff69f09121631c3d5a706cbbd39 (diff)
downloadgnuradio-eb95f431badf197b249131a3119a92bd5317621b.tar.gz
gnuradio-eb95f431badf197b249131a3119a92bd5317621b.tar.bz2
gnuradio-eb95f431badf197b249131a3119a92bd5317621b.zip
Removed usrp(2) directories.
Diffstat (limited to 'usrp/host/apps')
-rw-r--r--usrp/host/apps/.gitignore27
-rw-r--r--usrp/host/apps/Makefile.am56
-rwxr-xr-xusrp/host/apps/burn-db-eeprom174
-rwxr-xr-xusrp/host/apps/burn-serial-number80
-rwxr-xr-xusrp/host/apps/check_order39
-rw-r--r--usrp/host/apps/check_order_quickly.cc62
-rwxr-xr-xusrp/host/apps/dump_12bit_shorts23
-rwxr-xr-xusrp/host/apps/dump_shorts23
-rwxr-xr-xusrp/host/apps/run6
-rwxr-xr-xusrp/host/apps/run24
-rwxr-xr-xusrp/host/apps/run_input5
-rw-r--r--usrp/host/apps/test_usrp_standard_rx.cc273
-rw-r--r--usrp/host/apps/test_usrp_standard_tx.cc314
-rw-r--r--usrp/host/apps/time_stuff.c68
-rw-r--r--usrp/host/apps/time_stuff.h48
-rw-r--r--usrp/host/apps/usrp_cal_dc_offset.cc239
-rw-r--r--usrp/host/apps/usrper.cc356
17 files changed, 0 insertions, 1797 deletions
diff --git a/usrp/host/apps/.gitignore b/usrp/host/apps/.gitignore
deleted file mode 100644
index 16fdf27ad..000000000
--- a/usrp/host/apps/.gitignore
+++ /dev/null
@@ -1,27 +0,0 @@
-/Makefile
-/Makefile.in
-/.la
-/.lo
-/.deps
-/.libs
-/*.la
-/*.lo
-/*.dat
-/usrper
-/usrper2
-/test_input
-/test_fusb
-/test_usrp
-/test_usrp0
-/test_usrp_standard_rx
-/test_usrp_standard_tx
-/test_usrp_inband_timestamps
-/test_usrp_inband_registers
-/test_usrp_inband_rx
-/test_usrp_inband_tx
-/test_usrp_basic_rx
-/check_order_quickly
-/usrp_cal_dc_offset
-/test_usrp_inband_cs
-/read_packets
-/test_usrp_inband_ping
diff --git a/usrp/host/apps/Makefile.am b/usrp/host/apps/Makefile.am
deleted file mode 100644
index 8aa361b22..000000000
--- a/usrp/host/apps/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Copyright 2003,2006,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 $(top_srcdir)/Makefile.common
-
-AM_CPPFLAGS = $(USRP_INCLUDES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \
- $(USB_INCLUDES) $(WITH_INCLUDES)
-
-bin_PROGRAMS = \
- usrper \
- usrp_cal_dc_offset
-
-noinst_PROGRAMS = \
- check_order_quickly \
- test_usrp_standard_rx \
- test_usrp_standard_tx
-
-noinst_HEADERS = \
- time_stuff.h
-
-noinst_PYTHON = \
- burn-db-eeprom \
- burn-serial-number
-
-
-check_order_quickly_SOURCES = check_order_quickly.cc
-
-test_usrp_standard_rx_SOURCES = test_usrp_standard_rx.cc time_stuff.c
-test_usrp_standard_rx_LDADD = $(USRP_LA)
-
-test_usrp_standard_tx_SOURCES = test_usrp_standard_tx.cc time_stuff.c
-test_usrp_standard_tx_LDADD = $(USRP_LA) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB)
-
-usrper_SOURCES = usrper.cc
-usrper_LDADD = $(USRP_LA)
-
-usrp_cal_dc_offset_SOURCES = usrp_cal_dc_offset.cc
-usrp_cal_dc_offset_LDADD = $(USRP_LA)
diff --git a/usrp/host/apps/burn-db-eeprom b/usrp/host/apps/burn-db-eeprom
deleted file mode 100755
index 0c908e3d5..000000000
--- a/usrp/host/apps/burn-db-eeprom
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2007,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.
-#
-
-from usrpm.usrp_prims import *
-from optparse import OptionParser
-import sys
-from usrpm.usrp_dbid import *
-
-i2c_addr_map = { 'TX_A' : 0x54, 'RX_A' : 0x55, 'TX_B' : 0x56, 'RX_B' : 0x57 }
-
-daughterboards = {
- # name : ((tx-dbid, tx-oe), (rx-dbid, rx-oe))
- 'basictx' : ((BASIC_TX, 0x0000), None),
- 'basicrx' : (None, (BASIC_RX, 0x0000)),
- 'dbsrx' : (None, (DBS_RX, 0x0000)),
- 'dbsrx_clkmod' : (None, (DBS_RX_CLKMOD, 0x0000)),
- 'tvrx' : (None, (TV_RX, 0x0000)),
- 'tvrx2' : (None, (TV_RX_REV_2, 0x0000)),
- 'tvrx3' : (None, (TV_RX_REV_3, 0x0000)),
- 'tvrx_mimo' : (None, (TV_RX_MIMO, 0x0000)),
- 'tvrx2_mimo' : (None, (TV_RX_REV_2_MIMO, 0x0000)),
- 'tvrx3_mimo' : (None, (TV_RX_REV_3_MIMO, 0x0000)),
- 'dtt754' : (None, (DTT754, 0x0000)),
- 'dtt768' : (None, (DTT768, 0x0000)),
- 'rfx400' : ((FLEX_400_TX, 0x0000), (FLEX_400_RX, 0x0000)),
- 'rfx900' : ((FLEX_900_TX, 0x0000), (FLEX_900_RX, 0x0000)),
- 'rfx1200' : ((FLEX_1200_TX, 0x0000), (FLEX_1200_RX, 0x0000)),
- 'rfx1800' : ((FLEX_1800_TX, 0x0000), (FLEX_1800_RX, 0x0000)),
- 'rfx2400' : ((FLEX_2400_TX, 0x0000), (FLEX_2400_RX, 0x0000)),
- 'rfx400_tx' : ((FLEX_400_TX, 0x0000), None),
- 'rfx900_tx' : ((FLEX_900_TX, 0x0000), None),
- 'rfx1200_tx' : ((FLEX_1200_TX, 0x0000), None),
- 'rfx1800_tx' : ((FLEX_1800_TX, 0x0000), None),
- 'rfx2400_tx' : ((FLEX_2400_TX, 0x0000), None),
- 'rfx400_rx' : (None, (FLEX_400_RX, 0x0000)),
- 'rfx900_rx' : (None, (FLEX_900_RX, 0x0000)),
- 'rfx1200_rx' : (None, (FLEX_1200_RX, 0x0000)),
- 'rfx1800_rx' : (None, (FLEX_1800_RX, 0x0000)),
- 'rfx2400_rx' : (None, (FLEX_2400_RX, 0x0000)),
- 'rfx400_mimo_a' : ((FLEX_400_TX_MIMO_A, 0x0000), (FLEX_400_RX_MIMO_A, 0x0000)),
- 'rfx900_mimo_a' : ((FLEX_900_TX_MIMO_A, 0x0000), (FLEX_900_RX_MIMO_A, 0x0000)),
- 'rfx1200_mimo_a' : ((FLEX_1200_TX_MIMO_A, 0x0000), (FLEX_1200_RX_MIMO_A, 0x0000)),
- 'rfx1800_mimo_a' : ((FLEX_1800_TX_MIMO_A, 0x0000), (FLEX_1800_RX_MIMO_A, 0x0000)),
- 'rfx2400_mimo_a' : ((FLEX_2400_TX_MIMO_A, 0x0000), (FLEX_2400_RX_MIMO_A, 0x0000)),
- 'rfx400_mimo_b' : ((FLEX_400_TX_MIMO_B, 0x0000), (FLEX_400_RX_MIMO_B, 0x0000)),
- 'rfx900_mimo_b' : ((FLEX_900_TX_MIMO_B, 0x0000), (FLEX_900_RX_MIMO_B, 0x0000)),
- 'rfx1200_mimo_b' : ((FLEX_1200_TX_MIMO_B, 0x0000), (FLEX_1200_RX_MIMO_B, 0x0000)),
- 'rfx1800_mimo_b' : ((FLEX_1800_TX_MIMO_B, 0x0000), (FLEX_1800_RX_MIMO_B, 0x0000)),
- 'rfx2200_mimo_b' : ((FLEX_2200_TX_MIMO_B, 0x0000), (FLEX_2200_RX_MIMO_B, 0x0000)),
- 'rfx2400_mimo_b' : ((FLEX_2400_TX_MIMO_B, 0x0000), (FLEX_2400_RX_MIMO_B, 0x0000)),
- 'lftx' : ((LF_TX, 0x0000), None),
- 'lfrx' : (None, (LF_RX, 0x0000)),
- 'wbx_lo' : ((WBX_LO_TX, 0x0000), (WBX_LO_RX, 0x0000)),
- 'wbx_ng' : ((WBX_NG_TX, 0x0000), (WBX_NG_RX, 0x0000)),
- 'xcvr2450' : ((XCVR2450_TX, 0x0000), (XCVR2450_RX, 0x0000)),
- 'bitshark_rx' : (None, (BITSHARK_RX, 0x0000)),
- 'experimental_tx' : ((EXPERIMENTAL_TX, 0x0000), None),
- 'experimental_rx' : (None, (EXPERIMENTAL_RX, 0x0000)),
- }
-
-def open_cmd_interface(which_board = 0):
- if not usrp_load_standard_bits (which_board, 0):
- raise RuntimeError, "usrp_load_standard_bits"
- dev = usrp_find_device (which_board)
- if not dev:
- raise RuntimeError, "usrp_find_device"
- u = usrp_open_cmd_interface (dev)
- if not u:
- raise RuntimeError, "usrp_open_cmd_interface"
- return u
-
-def write_dboard_eeprom(u, i2c_addr, dbid, oe):
- eeprom = 0x20 * [0]
- eeprom[0] = 0xDB # magic value
- eeprom[1] = dbid & 0xff
- eeprom[2] = (dbid >> 8) & 0xff
- eeprom[3] = oe & 0xff
- eeprom[4] = (oe >> 8) & 0xff
- eeprom[0x1f] = 0xff & (-reduce(lambda x, y: x+y, eeprom)) # checksum
- s = ''.join (map (chr, eeprom))
- ok = usrp_eeprom_write (u, i2c_addr, 0, s)
- return ok
-
-
-def init_eeprom(u, slot_name, force, dbid, oe):
- i2c_addr = i2c_addr_map[slot_name]
- e = usrp_eeprom_read (u, i2c_addr, 0, 0x20)
- if not e:
- print "%s: no d'board, skipped" % (slot_name,)
- return True
-
- if not force and (sum (map (ord, e)) & 0xff) == 0 and ord (e[0]) == 0xDB:
- print "%s: already initialized, skipped" % (slot_name,)
- return True
-
- if not write_dboard_eeprom (u, i2c_addr, dbid, oe):
- print "%s: failed to write d'board EEPROM" % (slot_name,)
- return False
-
- print "%s: OK" % (slot_name,)
- return True
-
-
-def init_daughterboard(u, side, type, force):
- ok = True
- dbinfo = daughterboards[type]
- if dbinfo[0] is not None: # burn tx slot
- ok &= init_eeprom(u, 'TX_' + side, force, dbinfo[0][0], dbinfo[0][1])
- if dbinfo[1] is not None: # burn rx slot
- ok &= init_eeprom(u, 'RX_' + side, force, dbinfo[1][0], dbinfo[1][1])
- return ok
-
-
-def main():
- dbs = daughterboards.keys()
- dbs.sort()
- usage = """\
-usage: %prog [options]
-You must specify a type with -t or --type,
-and at least one side using -A and/or -B."""
-
- parser = OptionParser(usage=usage)
- parser.add_option ("-t", "--type", type="choice", help="choose type from %r" % (dbs,),
- choices=dbs, default=None)
- parser.add_option ("-A", "--burn-a", action="store_true", default=False,
- help="burn eeprom(s) on side A")
- parser.add_option ("-B", "--burn-b", action="store_true", default=False,
- help="burn eeprom(s) on side B")
- parser.add_option ("-f", "--force", action="store_true", default=False,
- help="force init of already initialized eeproms")
- (options, args) = parser.parse_args ()
-
- which=[]
- if options.burn_a:
- which.append('A')
- if options.burn_b:
- which.append('B')
-
- if len(args) != 0 or len(which) == 0 or options.type is None:
- parser.print_help()
- sys.exit (1)
-
- u = open_cmd_interface (0)
- ok = True
- for w in which:
- ok &= init_daughterboard (u, w, options.type, options.force)
-
- if ok:
- sys.exit (0)
- else:
- sys.exit (1)
-
-if __name__ == "__main__":
- main ()
-
diff --git a/usrp/host/apps/burn-serial-number b/usrp/host/apps/burn-serial-number
deleted file mode 100755
index f9a2a86a5..000000000
--- a/usrp/host/apps/burn-serial-number
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006,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 GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from usrpm.usrp_prims import *
-from optparse import OptionParser
-import sys
-import time
-
-
-def open_cmd_interface(which_board = 0):
- if not usrp_load_standard_bits (which_board, 0):
- raise RuntimeError, "usrp_load_standard_bits"
- dev = usrp_find_device (which_board)
- if not dev:
- raise RuntimeError, "usrp_find_device"
- u = usrp_open_cmd_interface (dev)
- if not u:
- raise RuntimeError, "usrp_open_cmd_interface"
- return u
-
-
-def write_serial_number_eeprom(u, serial_number):
- if not str(serial_number):
- raise TypeError
-
- i2c_addr = 0x50 # usrp boot rom
- serial_number_offset = 248 # offset to serial number
- serial_number_len = 8 # length of serial number
-
- lsn = len(serial_number)
- if lsn > serial_number_len:
- serial_number = serial_number[0:serial_number_len]
- if lsn < serial_number_len:
- serial_number = serial_number + (serial_number_len - lsn) * ' '
-
- ok = usrp_eeprom_write (u, i2c_addr, serial_number_offset, serial_number)
- return ok
-
-
-def main():
-
- default_serial_number = hex(int(time.time()))[2:]
- parser = OptionParser()
- parser.add_option ("-s", "--serial-number", default=default_serial_number,
- help="set serial number [default=%default]")
- (options, args) = parser.parse_args ()
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- u = open_cmd_interface (0)
- ok = write_serial_number_eeprom(u, options.serial_number)
-
- if ok:
- sys.exit(0)
- else:
- sys.exit(1)
-
-if __name__ == "__main__":
- main ()
diff --git a/usrp/host/apps/check_order b/usrp/host/apps/check_order
deleted file mode 100755
index 56e192710..000000000
--- a/usrp/host/apps/check_order
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- Python -*-
-
-import sys
-import fileinput
-
-skip_count = 4096
-lineno = 0
-last_error = 0
-
-for line in fileinput.input ():
- lineno += 1
- if lineno < skip_count:
- continue
- (offset, dec_val, hex_val) = line.split ()
- if lineno == skip_count:
- expected_val = int (dec_val)
- int_dec_val = int (dec_val)
- int_hex_val = int (hex_val, 16)
- if int_dec_val != expected_val:
- print "line %6d, delta %4d, expected %6d, got %6d" % (lineno,
- lineno - last_error,
- expected_val,
- int_dec_val)
- last_error = lineno
- elif ((int_hex_val >> 12) & 0xf) != (int_hex_val & 0xf):
- print "line %6d, delta %4d, invalid high bits %04x" % (lineno,
- lineno - last_error,
- int_hex_val)
- last_error = lineno
-
- # expected_val = (expected_val + 1) & 0xffff
- expected_val = (expected_val + 1) & 0x0fff
-
-
-
-
-
-
diff --git a/usrp/host/apps/check_order_quickly.cc b/usrp/host/apps/check_order_quickly.cc
deleted file mode 100644
index 4fa30c7d9..000000000
--- a/usrp/host/apps/check_order_quickly.cc
+++ /dev/null
@@ -1,62 +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.
- */
-
-#include <stdio.h>
-
-static bool
-check (int v, int counter, int offset)
-{
- if ((v & 0x0fff) != counter){
- fprintf (stdout, "%08x: expected 0x%04x, got 0x%04x\n", offset, counter, v & 0x0fff);
- return false;
- }
-
- if (((v >> 12) & 0xf) != (v & 0xf)){
- fprintf (stdout, "%08x: bad high bits 0x%04x\n", offset, v);
- return false;
- }
-
- return true;
-}
-
-int
-main (int argc, char **argv)
-{
- static const int BUFSIZE = 64 * 1024;
- unsigned short buf[BUFSIZE];
-
- int n;
- int i;
- int counter = 0;
- int offset = 0;
- bool ok = true;
-
- while ((n = fread (buf, sizeof (short), BUFSIZE, stdin)) != 0){
- for (i = 0; i < n; i++){
- ok &= check (buf[i], counter, offset);
- counter = (counter + 1) & 0x0fff;
- offset++;
- }
- }
-
- return ok ? 0 : 1;
-}
diff --git a/usrp/host/apps/dump_12bit_shorts b/usrp/host/apps/dump_12bit_shorts
deleted file mode 100755
index a896f2dd3..000000000
--- a/usrp/host/apps/dump_12bit_shorts
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# -*- Python -*-
-
-import sys, errno
-
-counter = 0
-
-try:
- while 1:
- x = sys.stdin.read (2)
- if not x:
- break
-
- v = (ord(x[1]) << 8) | ord(x[0])
- sys.stdout.write ("0x%08x %6d 0x%04x\n" % (counter, v & 0x0fff, v))
- counter += 1
-except IOError, e:
- if e.errno == errno.EPIPE:
- sys.exit (0)
-
-
-
-
diff --git a/usrp/host/apps/dump_shorts b/usrp/host/apps/dump_shorts
deleted file mode 100755
index 6104ea062..000000000
--- a/usrp/host/apps/dump_shorts
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# -*- Python -*-
-
-import sys, errno
-
-counter = 0
-
-try:
- while 1:
- x = sys.stdin.read (2)
- if not x:
- break
-
- v = (ord(x[1]) << 8) | ord(x[0])
- sys.stdout.write ("0x%08x %6d 0x%04x\n" % (counter, v, v))
- counter += 1
-except IOError, e:
- if e.errno == errno.EPIPE:
- sys.exit (0)
-
-
-
-
diff --git a/usrp/host/apps/run b/usrp/host/apps/run
deleted file mode 100755
index 5b13336c7..000000000
--- a/usrp/host/apps/run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-./test_usrp_standard_rx -D 8 -o rx.bin
-./dump_12bit_shorts <rx.bin | head -100000 >rx.ascii
-./check_order rx.ascii
-#./dump_12bit_shorts <rx.bin | ./check_order
diff --git a/usrp/host/apps/run2 b/usrp/host/apps/run2
deleted file mode 100755
index 5fcf154cb..000000000
--- a/usrp/host/apps/run2
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-./test_usrp_standard_rx -D 8 -o rx.bin
-./check_order_quickly <rx.bin
diff --git a/usrp/host/apps/run_input b/usrp/host/apps/run_input
deleted file mode 100755
index b8afae6f3..000000000
--- a/usrp/host/apps/run_input
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-./test_usrp_standard_rx -D 8 -o rx.bin "$@"
-./dump_shorts <rx.bin | head -50000 >rx.ascii
-
diff --git a/usrp/host/apps/test_usrp_standard_rx.cc b/usrp/host/apps/test_usrp_standard_rx.cc
deleted file mode 100644
index 4098decda..000000000
--- a/usrp/host/apps/test_usrp_standard_rx.cc
+++ /dev/null
@@ -1,273 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2006,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <assert.h>
-#include <math.h>
-#include "time_stuff.h"
-#include <usrp/usrp_standard.h>
-#include <usrp/usrp_bytesex.h>
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-
-#ifdef HAVE_SCHED_H
-#include <sched.h>
-#endif
-
-char *prog_name;
-
-static bool test_input (usrp_standard_rx_sptr urx, int max_bytes, FILE *fp);
-
-static void
-set_progname (char *path)
-{
- char *p = strrchr (path, '/');
- if (p != 0)
- prog_name = p+1;
- else
- prog_name = path;
-}
-
-static void
-usage ()
-{
- fprintf (stderr, "usage: %s [-f] [-v] [-l] [-c] [-D <decim>] [-F freq] [-o output_file]\n", prog_name);
- fprintf (stderr, " [-f] loop forever\n");
- fprintf (stderr, " [-M] how many Megabytes to transfer (default 128)\n");
- fprintf (stderr, " [-v] verbose\n");
- fprintf (stderr, " [-l] digital loopback in FPGA\n");
- fprintf (stderr, " [-c] counting in FPGA\n");
- fprintf (stderr, " [-8] 8-bit samples across USB\n");
- fprintf (stderr, " [-B <fusb_block_size>] set fast usb block_size\n");
- fprintf (stderr, " [-N <fusb_nblocks>] set fast usb nblocks\n");
- fprintf (stderr, " [-R] set real time scheduling: SCHED_FIFO; pri = midpoint\n");
-
- exit (1);
-}
-
-static void
-die (const char *msg)
-{
- fprintf (stderr, "die: %s: %s\n", prog_name, msg);
- exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
- bool verbose_p = false;
- bool loopback_p = false;
- bool counting_p = false;
- bool width_8_p = false;
- int max_bytes = 128 * (1L << 20);
- int ch;
- char *output_filename = 0;
- int which_board = 0;
- int decim = 8; // 32 MB/sec
- double center_freq = 0;
- int fusb_block_size = 0;
- int fusb_nblocks = 0;
- bool realtime_p = false;
-
-
- set_progname (argv[0]);
-
- while ((ch = getopt (argc, argv, "fvlco:D:F:M:8B:N:R")) != EOF){
- switch (ch){
- case 'f':
- max_bytes = 0;
- break;
-
- case 'v':
- verbose_p = true;
- break;
-
- case 'l':
- loopback_p = true;
- break;
-
- case 'c':
- counting_p = true;
- break;
-
- case '8':
- width_8_p = true;
- break;
-
- case 'o':
- output_filename = optarg;
- break;
-
- case 'D':
- decim = strtol (optarg, 0, 0);
- break;
-
- case 'F':
- center_freq = strtod (optarg, 0);
- break;
-
- case 'M':
- max_bytes = strtol (optarg, 0, 0) * (1L << 20);
- if (max_bytes < 0) max_bytes = 0;
- break;
-
- case 'B':
- fusb_block_size = strtol (optarg, 0, 0);
- break;
-
- case 'N':
- fusb_nblocks = strtol (optarg, 0, 0);
- break;
-
- case 'R':
- realtime_p = true;
- break;
-
- default:
- usage ();
- }
- }
-
-#ifdef HAVE_SCHED_SETSCHEDULER
- if (realtime_p){
- int policy = SCHED_FIFO;
- int pri = (sched_get_priority_max (policy) - sched_get_priority_min (policy)) / 2;
- int pid = 0; // this process
-
- struct sched_param param;
- memset(&param, 0, sizeof(param));
- param.sched_priority = pri;
- int result = sched_setscheduler(pid, policy, &param);
- if (result != 0){
- perror ("sched_setscheduler: failed to set real time priority");
- }
- else
- printf("SCHED_FIFO enabled with priority = %d\n", pri);
- }
-#endif
-
- FILE *fp = 0;
-
- if (output_filename){
- fp = fopen (output_filename, "wb");
- if (fp == 0)
- perror (output_filename);
- }
-
- int mode = 0;
- if (loopback_p)
- mode |= usrp_standard_rx::FPGA_MODE_LOOPBACK;
- if (counting_p)
- mode |= usrp_standard_rx::FPGA_MODE_COUNTING;
-
-
- usrp_standard_rx_sptr urx =
- usrp_standard_rx::make (which_board, decim, 1, -1, mode,
- fusb_block_size, fusb_nblocks);
-
- if (urx == 0)
- die ("usrp_standard_rx::make");
-
- if (!urx->set_rx_freq (0, center_freq))
- die ("urx->set_rx_freq");
-
- if (width_8_p){
- int width = 8;
- int shift = 8;
- bool want_q = true;
- if (!urx->set_format(usrp_standard_rx::make_format(width, shift, want_q)))
- die("urx->set_format");
- }
-
- urx->start(); // start data xfers
-
- test_input (urx, max_bytes, fp);
-
- if (fp)
- fclose (fp);
-
- return 0;
-}
-
-
-static bool
-test_input (usrp_standard_rx_sptr urx, int max_bytes, FILE *fp)
-{
- int fd = -1;
- static const int BUFSIZE = urx->block_size();
- static const int N = BUFSIZE/sizeof (short);
- short buf[N];
- int nbytes = 0;
-
- double start_wall_time = get_elapsed_time ();
- double start_cpu_time = get_cpu_usage ();
-
- if (fp)
- fd = fileno (fp);
-
- bool overrun;
- int noverruns = 0;
-
- for (nbytes = 0; max_bytes == 0 || nbytes < max_bytes; nbytes += BUFSIZE){
-
- unsigned int ret = urx->read (buf, sizeof (buf), &overrun);
- if (ret != sizeof (buf)){
- fprintf (stderr, "test_input: error, ret = %d\n", ret);
- }
-
- if (overrun){
- printf ("rx_overrun\n");
- noverruns++;
- }
-
- if (fd != -1){
-
- for (unsigned int i = 0; i < sizeof (buf) / sizeof (short); i++)
- buf[i] = usrp_to_host_short (buf[i]);
-
- if (write (fd, buf, sizeof (buf)) == -1){
- perror ("write");
- fd = -1;
- }
- }
- }
-
- double stop_wall_time = get_elapsed_time ();
- double stop_cpu_time = get_cpu_usage ();
-
- double delta_wall = stop_wall_time - start_wall_time;
- double delta_cpu = stop_cpu_time - start_cpu_time;
-
- printf ("xfered %.3g bytes in %.3g seconds. %.4g bytes/sec. cpu time = %.4g\n",
- (double) max_bytes, delta_wall, max_bytes / delta_wall, delta_cpu);
- printf ("noverruns = %d\n", noverruns);
-
- return true;
-}
diff --git a/usrp/host/apps/test_usrp_standard_tx.cc b/usrp/host/apps/test_usrp_standard_tx.cc
deleted file mode 100644
index cc9f9edfc..000000000
--- a/usrp/host/apps/test_usrp_standard_tx.cc
+++ /dev/null
@@ -1,314 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <assert.h>
-#include <math.h>
-#include "time_stuff.h"
-#include <usrp/usrp_standard.h>
-#include <usrp/usrp_bytesex.h>
-#include <boost/program_options.hpp>
-
-enum {
- GR_SIN_WAVE,
- GR_CONST_WAVE
-};
-
-namespace po = boost::program_options;
-
-char *prog_name;
-
-usrp_subdev_spec
-str_to_subdev(std::string spec_str)
-{
- usrp_subdev_spec spec;
- if(spec_str == "A" || spec_str == "A:0" || spec_str == "0:0") {
- spec.side = 0;
- spec.subdev = 0;
- }
- else if(spec_str == "A:1" || spec_str == "0:1") {
- spec.side = 0;
- spec.subdev = 1;
- }
- else if(spec_str == "B" || spec_str == "B:0" || spec_str == "1:0") {
- spec.side = 1;
- spec.subdev = 0;
- }
- else if(spec_str == "B:1" || spec_str == "1:1") {
- spec.side = 1;
- spec.subdev = 1;
- }
- else {
- throw std::range_error("Incorrect subdevice specifications.\n");
- }
-
- return spec;
-}
-
-
-static void
-set_progname (char *path)
-{
- char *p = strrchr (path, '/');
- if (p != 0)
- prog_name = p+1;
- else
- prog_name = path;
-}
-
-static void
-die (const char *msg)
-{
- fprintf (stderr, "die: %s: %s\n", prog_name, msg);
- exit (1);
-}
-
-
-static bool
-test_output (usrp_standard_tx_sptr utx, long long max_bytes, double ampl, int waveform)
-{
- const int BUFSIZE = utx->block_size();
- const int N = BUFSIZE/sizeof (short);
-
- short buf[N];
- long long nbytes = 0;
-
- // ----------------------------------------------------------------
- // one time initialization of the pattern we're going to transmit
-
- const int PERIOD = 65; // any value is valid
- const int PATLEN = 2 * PERIOD;
- short pattern[PATLEN];
-
- for (int i = 0; i < PERIOD; i++){
- if (waveform == GR_CONST_WAVE){
- pattern[2*i+0] = host_to_usrp_short((short) ampl);
- pattern[2*i+1] = host_to_usrp_short((short) 0);
- }
- else {
- pattern[2*i+0] = host_to_usrp_short((short) (ampl * cos(2*M_PI * i / PERIOD)));
- pattern[2*i+1] = host_to_usrp_short((short) (ampl * sin(2*M_PI * i / PERIOD)));
- }
- }
-
- // ----------------------------------------------------------------
-
- double start_wall_time = get_elapsed_time ();
- double start_cpu_time = get_cpu_usage ();
-
- bool underrun;
- int nunderruns = 0;
- int pi = 0;
-
- for (nbytes = 0; max_bytes == 0 || nbytes < max_bytes; nbytes += BUFSIZE){
-
- for (int i = 0; i < N; i++){
- buf[i] = pattern[pi];
- pi++;
- if (pi >= PATLEN)
- pi = 0;
- }
-
- int ret = utx->write (buf, sizeof (buf), &underrun);
- if ((unsigned) ret != sizeof (buf)){
- fprintf (stderr, "test_output: error, ret = %d\n", ret);
- }
-
- if (underrun){
- nunderruns++;
- printf ("tx_underrun\n");
- //printf ("tx_underrun %9d %6d\n", nbytes, nbytes/BUFSIZE);
- }
- }
-
- utx->wait_for_completion ();
-
- double stop_wall_time = get_elapsed_time ();
- double stop_cpu_time = get_cpu_usage ();
-
- double delta_wall = stop_wall_time - start_wall_time;
- double delta_cpu = stop_cpu_time - start_cpu_time;
-
- printf ("xfered %.3g bytes in %.3g seconds. %.4g bytes/sec. cpu time = %.3g\n",
- (double) max_bytes, delta_wall, max_bytes / delta_wall, delta_cpu);
-
- printf ("%d underruns\n", nunderruns);
-
- return true;
-}
-
-int
-main (int argc, char **argv)
-{
- int which = 0; // specify which USRP board
- usrp_subdev_spec spec(0,0); // specify the d'board side
- int interp = 16; // set the interpolation rate
- double rf_freq = -1; // set the frequency
- float amp = 10000; // set the amplitude of the output
- float gain = -1; // set the d'board PGA gain
- int waveform;
- int fusb_block_size = 0;
- int fusb_nblocks = 0;
- bool realtime_p = false;
- double nsamples = 32e6;
-
- set_progname (argv[0]);
-
- po::options_description cmdconfig("Program options");
- cmdconfig.add_options()
- ("help,h", "produce help message")
- ("which,W", po::value<int>(&which), "select which USRP board")
- ("tx-subdev-spec,T", po::value<std::string>(), "select USRP Tx side A or B")
- ("rf-freq,f", po::value<double>(), "set RF center frequency to FREQ")
- ("interp,i", po::value<int>(&interp), "set fgpa interpolation rate to INTERP")
-
- ("sine", "generate a complex sinusoid [default]")
- ("const", "generate a constant output")
-
- //("waveform-freq,w", po::value<double>(&wfreq), "set waveform frequency to FREQ")
- ("amplitude,a", po::value<float>(&amp), "set amplitude")
- ("gain,g", po::value<float>(&gain), "set output gain to GAIN [default=MAX]")
- //("offset,o", po::value<float>(&offset), "set waveform offset to OFFSET")
- ("nsamples,N", po::value<double>(&nsamples), "number of samples to send [default=32M]")
- ;
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).
- options(cmdconfig).run(), vm);
- po::notify(vm);
-
- if (vm.count("help")) {
- std::cout << cmdconfig << "\n";
- return 1;
- }
-
- if(vm.count("tx-subdev-spec")) {
- std::string s = vm["tx-subdev-spec"].as<std::string>();
- spec = str_to_subdev(s);
- }
-
- if(vm.count("sine")) {
- waveform = GR_SIN_WAVE;
- }
- else if(vm.count("const")) {
- waveform = GR_CONST_WAVE;
- }
- else {
- waveform = GR_SIN_WAVE;
- }
-
- printf("which: %d\n", which);
- printf("interp: %d\n", interp);
- printf("rf_freq: %g\n", rf_freq);
- printf("amp: %f\n", amp);
- printf("nsamples: %g\n", nsamples);
-
-
- if (realtime_p){
- // FIXME
- }
-
- usrp_standard_tx_sptr utx;
-
- utx = usrp_standard_tx::make (which,
- interp,
- 1, // nchan
- -1, // mux
- fusb_block_size,
- fusb_nblocks);
-
- if (utx == 0)
- die ("usrp_standard_tx::make");
-
- // FIXME
-
- db_base_sptr subdev = utx->selected_subdev(spec);
- printf("Subdevice name is %s\n", subdev->name().c_str());
- printf("Subdevice freq range: (%g, %g)\n",
- subdev->freq_min(), subdev->freq_max());
-
- unsigned int mux = utx->determine_tx_mux_value(spec);
- printf("mux: %#08x\n", mux);
- utx->set_mux(mux);
-
- if(gain == -1)
- gain = subdev->gain_max();
- subdev->set_gain(gain);
-
- float input_rate = utx->dac_rate() / utx->interp_rate();
- printf("baseband rate: %g\n", input_rate);
-
- usrp_tune_result r;
-
- if (rf_freq < 0)
- rf_freq = (subdev->freq_min() + subdev->freq_max()) * 0.5;
- double target_freq = rf_freq;
- bool ok = utx->tune(subdev->which(), subdev, target_freq, &r);
-
- if(!ok) {
- throw std::runtime_error("Could not set frequency.");
- }
-
- subdev->set_enable(true);
-
- printf("target_freq: %f\n", target_freq);
- printf("ok: %s\n", ok ? "true" : "false");
- 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);
-
-
- fflush (stdout);
- fflush (stderr);
-
- utx->start(); // start data xfers
-
- test_output (utx, (long long) nsamples, amp, waveform);
-
- return 0;
-}
-
-
-#if 0
- case 'B':
- fusb_block_size = strtol (optarg, 0, 0);
- break;
-
- case 'N':
- fusb_nblocks = strtol (optarg, 0, 0);
- break;
-
- case 'R':
- realtime_p = true;
- break;
-
-#endif
diff --git a/usrp/host/apps/time_stuff.c b/usrp/host/apps/time_stuff.c
deleted file mode 100644
index 89a4a3815..000000000
--- a/usrp/host/apps/time_stuff.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "time_stuff.h"
-
-#include <sys/time.h>
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-#include <unistd.h>
-
-static double
-timeval_to_secs (struct timeval *tv)
-{
- return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6;
-}
-
-double
-get_cpu_usage (void)
-{
-#ifdef HAVE_GETRUSAGE
- struct rusage ru;
-
- if (getrusage (RUSAGE_SELF, &ru) != 0)
- return 0;
-
- return timeval_to_secs (&ru.ru_utime) + timeval_to_secs (&ru.ru_stime);
-#else
- return 0; /* FIXME */
-#endif
-}
-
-/*
- * return elapsed time (wall time) in seconds
- */
-double
-get_elapsed_time (void)
-{
- struct timeval tv;
- if (gettimeofday (&tv, 0) != 0)
- return 0;
-
- return timeval_to_secs (&tv);
-}
-
diff --git a/usrp/host/apps/time_stuff.h b/usrp/host/apps/time_stuff.h
deleted file mode 100644
index 74b79f388..000000000
--- a/usrp/host/apps/time_stuff.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003 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 _TIME_STUFF_H_
-#define _TIME_STUFF_H_
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * return USER + SYS cpu time in seconds
- */
-double get_cpu_usage (void);
-
-/*
- * return elapsed time in seconds
- */
-double get_elapsed_time (void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _TIME_STUFF_H_ */
diff --git a/usrp/host/apps/usrp_cal_dc_offset.cc b/usrp/host/apps/usrp_cal_dc_offset.cc
deleted file mode 100644
index 5f708d672..000000000
--- a/usrp/host/apps/usrp_cal_dc_offset.cc
+++ /dev/null
@@ -1,239 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <assert.h>
-#include <math.h>
-#include <boost/scoped_ptr.hpp>
-#include <usrp/usrp_local_sighandler.h>
-#include <usrp/usrp_standard.h>
-#include <usrp/usrp_bytesex.h>
-
-char *prog_name;
-
-
-
-
-static void
-run_cal(usrp_standard_rx_sptr u, int which_side, int decim, bool verbose_p)
-{
- static const int BUFSIZE = u->block_size();
- static const int N = BUFSIZE/sizeof (short);
- short buf[N];
- bool cal_done = false;
- bool overrun;
- int noverruns = 0;
-
- static const double K = 1e-4;
- long integrator[2];
- int offset[2];
-
- integrator[0] = 0;
- integrator[1] = 0;
- offset[0] = 0;
- offset[1] = 0;
-
- u->start(); // start data xfers
-
- while(!cal_done){
- int ret = u->read (buf, sizeof (buf), &overrun);
- if (ret != (int) sizeof (buf)){
- fprintf (stderr, "usrp_cal_dc_offset: error, ret = %d\n", ret);
- continue;
- }
- if (overrun){
- fprintf (stderr, "O");
- noverruns++;
- }
- else {
- // fputc('.', stderr);
- }
-
- static const int MAX = (1L << 30); // 1G
-
- for (int i = 0; i < N/2; i++){
- for (int n = 0; n < 2; n++){
- integrator[n] = integrator[n] + buf[2*i + n];
- if (integrator[n] > MAX)
- integrator[n] = MAX;
- else if (integrator[n] < -MAX)
- integrator[n] = -MAX;
- }
- }
-
-#if 1
- for (int n = 0; n < 2; n++){
- offset[n] = (int) rint(integrator[n] * K);
- if (offset[n] > 32767)
- offset[n] = 32767;
- else if (offset[n] < -32767)
- offset[n] = -32767;
- u->set_adc_offset(which_side * 2 + n, offset[n]);
- }
-#else
- offset[0] = (int) rint(integrator[0] * K);
- if (offset[0] > 32767)
- offset[0] = 32767;
- else if (offset[0] < -32767)
- offset[0] = -32767;
- u->set_adc_offset(which_side * 2 + 0, offset[0]);
- u->set_adc_offset(which_side * 2 + 1, offset[0]);
-#endif
-
-
- printf ("%9ld : %6d\t\t%9ld : %6d\n",
- integrator[0], offset[0], integrator[1], offset[1]);
- }
-
- u->stop();
-}
-
-
-static void
-set_progname (char *path)
-{
- char *p = strrchr (path, '/');
- if (p != 0)
- prog_name = p+1;
- else
- prog_name = path;
-}
-
-static void
-usage ()
-{
- fprintf(stderr, "usage: %s [-v] [-w which_side] [-D decim] [-c ddc_freq] [-g gain]\n", prog_name);
- fprintf(stderr, " [-S fusb_block_size] [-N fusb_nblocks]\n");
- exit (1);
-}
-
-static void
-die (const char *msg)
-{
- fprintf (stderr, "die: %s: %s\n", prog_name, msg);
- exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
- int ch;
- int decim = 128; // 500 kS/sec
- bool verbose_p = false;
- int which_board = 0;
- int which_side = 0;
- double ddc_freq = 0;
- int fusb_block_size = 1024;
- int fusb_nblocks = 4;
- double pga_gain = 0.0;
-
- set_progname(argv[0]);
-
- while ((ch = getopt (argc, argv, "vw:D:c:S:N:g:")) != EOF){
- switch (ch){
-
- case 'w':
- which_side = strtol (optarg, 0, 0);
- if (which_side < 0 || which_side > 1)
- usage();
- break;
-
- case 'D':
- decim = strtol (optarg, 0, 0);
- if (decim < 1)
- usage();
- break;
-
- case 'c':
- ddc_freq = strtod (optarg, 0);
- break;
-
- case 'v':
- verbose_p = true;
- break;
-
- case 'S':
- fusb_block_size = strtol(optarg, 0, 0);
- break;
-
- case 'N':
- fusb_nblocks = strtol(optarg, 0, 0);
- break;
-
- case 'g':
- pga_gain = strtod (optarg, 0);
- break;
-
- default:
- usage ();
- }
- }
-
- int nchannels = 1;
- int mode = usrp_standard_rx::FPGA_MODE_NORMAL;
- int mux;
-
- if (which_side == 0)
- mux = 0x00000010;
- else
- mux = 0x00000032;
-
-#ifdef SIGINT
- usrp_local_sighandler sigint (SIGINT, usrp_local_sighandler::throw_signal);
-#endif
-#ifdef SIGQUIT
- usrp_local_sighandler sigquit (SIGQUIT, usrp_local_sighandler::throw_signal);
-#endif
-
- usrp_standard_rx_sptr urx =
- usrp_standard_rx::make(which_board, decim,
- nchannels, mux, mode,
- fusb_block_size, fusb_nblocks);
- if (!urx)
- die("usrp_standard_rx::make");
-
- try {
-
- if (!urx->set_rx_freq(0, ddc_freq))
- die("urx->set_rx_freq");
-
- urx->set_pga(2 * which_side + 0, pga_gain);
- urx->set_pga(2 * which_side + 1, pga_gain);
-
- run_cal(urx, which_side, decim, verbose_p);
- }
- catch (usrp_signal &sig){
- fprintf (stderr, "usrp_cal_dc_offset: caught %s\n", sig.name().c_str());
- }
- catch(...){
- fprintf (stderr, "usrp_cal_dc_offset: caught something\n");
- }
-}
-
diff --git a/usrp/host/apps/usrper.cc b/usrp/host/apps/usrper.cc
deleted file mode 100644
index 593cd7921..000000000
--- a/usrp/host/apps/usrper.cc
+++ /dev/null
@@ -1,356 +0,0 @@
-/* -*- c++ -*- */
-/*
- * USRP - Universal Software Radio Peripheral
- *
- * Copyright (C) 2003,2004,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
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "usrp/usrp_prims.h"
-#include "usrp_spi_defs.h"
-
-char *prog_name;
-
-static void
-set_progname (char *path)
-{
- char *p = strrchr (path, '/');
- if (p != 0)
- prog_name = p+1;
- else
- prog_name = path;
-}
-
-static void
-usage ()
-{
- fprintf (stderr, "usage: \n");
- fprintf (stderr, " %s [-v] [-w <which_board>] [-x] ...\n", prog_name);
- fprintf (stderr, " %s load_standard_bits\n", prog_name);
- fprintf (stderr, " %s load_firmware <file.ihx>\n", prog_name);
- fprintf (stderr, " %s load_fpga <file.rbf>\n", prog_name);
- fprintf (stderr, " %s write_fpga_reg <reg8> <value32>\n", prog_name);
- fprintf (stderr, " %s set_fpga_reset {on|off}\n", prog_name);
- fprintf (stderr, " %s set_fpga_tx_enable {on|off}\n", prog_name);
- fprintf (stderr, " %s set_fpga_rx_enable {on|off}\n", prog_name);
- fprintf (stderr, " ----- diagnostic routines -----\n");
- fprintf (stderr, " %s led0 {on|off}\n", prog_name);
- fprintf (stderr, " %s led1 {on|off}\n", prog_name);
- fprintf (stderr, " %s set_hash0 <hex-string>\n", prog_name);
- fprintf (stderr, " %s get_hash0\n", prog_name);
- fprintf (stderr, " %s i2c_read i2c_addr len\n", prog_name);
- fprintf (stderr, " %s i2c_write i2c_addr <hex-string>\n", prog_name);
- fprintf (stderr, " %s 9862a_write regno value\n", prog_name);
- fprintf (stderr, " %s 9862b_write regno value\n", prog_name);
- fprintf (stderr, " %s 9862a_read regno\n", prog_name);
- fprintf (stderr, " %s 9862b_read regno\n", prog_name);
- exit (1);
-}
-
-#if 0
-static void
-die (const char *msg)
-{
- fprintf (stderr, "%s (die): %s\n", prog_name, msg);
- exit (1);
-}
-#endif
-
-static int
-hexval (char ch)
-{
- if ('0' <= ch && ch <= '9')
- return ch - '0';
-
- if ('a' <= ch && ch <= 'f')
- return ch - 'a' + 10;
-
- if ('A' <= ch && ch <= 'F')
- return ch - 'A' + 10;
-
- return -1;
-}
-
-static unsigned char *
-hex_string_to_binary (const char *string, int *lenptr)
-{
- int sl = strlen (string);
- if (sl & 0x01){
- fprintf (stderr, "%s: odd number of chars in <hex-string>\n", prog_name);
- return 0;
- }
-
- int len = sl / 2;
- *lenptr = len;
- unsigned char *buf = new unsigned char [len];
-
- for (int i = 0; i < len; i++){
- int hi = hexval (string[2 * i]);
- int lo = hexval (string[2 * i + 1]);
- if (hi < 0 || lo < 0){
- fprintf (stderr, "%s: invalid char in <hex-string>\n", prog_name);
- delete [] buf;
- return 0;
- }
- buf[i] = (hi << 4) | lo;
- }
- return buf;
-}
-
-static void
-print_hex (FILE *fp, unsigned char *buf, int len)
-{
- for (int i = 0; i < len; i++){
- fprintf (fp, "%02x", buf[i]);
- }
- fprintf (fp, "\n");
-}
-
-static void
-chk_result (bool ok)
-{
- if (!ok){
- fprintf (stderr, "%s: failed\n", prog_name);
- exit (1);
- }
-}
-
-static bool
-get_on_off (const char *s)
-{
- if (strcmp (s, "on") == 0)
- return true;
-
- if (strcmp (s, "off") == 0)
- return false;
-
- usage (); // no return
- return false;
-}
-
-
-int
-main (int argc, char **argv)
-{
- int ch;
- bool verbose = false;
- int which_board = 0;
- bool fx2_ok_p = false;
-
- set_progname (argv[0]);
-
- while ((ch = getopt (argc, argv, "vw:x")) != EOF){
- switch (ch){
-
- case 'v':
- verbose = true;
- break;
-
- case 'w':
- which_board = strtol (optarg, 0, 0);
- break;
-
- case 'x':
- fx2_ok_p = true;
- break;
-
- default:
- usage ();
- }
- }
-
- int nopts = argc - optind;
-
- if (nopts < 1)
- usage ();
-
- const char *cmd = argv[optind++];
- nopts--;
-
- usrp_one_time_init ();
-
-
- libusb_device *udev = usrp_find_device (which_board, fx2_ok_p);
- if (udev == 0){
- fprintf (stderr, "%s: failed to find usrp[%d]\n", prog_name, which_board);
- exit (1);
- }
-
- if (usrp_unconfigured_usrp_p (udev)){
- fprintf (stderr, "%s: found unconfigured usrp; needs firmware.\n", prog_name);
- }
-
- if (usrp_fx2_p (udev)){
- fprintf (stderr, "%s: found unconfigured FX2; needs firmware.\n", prog_name);
- }
-
- libusb_device_handle *udh = usrp_open_cmd_interface (udev);
- if (udh == 0){
- fprintf (stderr, "%s: failed to open_cmd_interface\n", prog_name);
- exit (1);
- }
-
-#define CHKARGS(n) if (nopts != n) usage (); else
-
- if (strcmp (cmd, "led0") == 0){
- CHKARGS (1);
- bool on = get_on_off (argv[optind]);
- chk_result (usrp_set_led (udh, 0, on));
- }
- else if (strcmp (cmd, "led1") == 0){
- CHKARGS (1);
- bool on = get_on_off (argv[optind]);
- chk_result (usrp_set_led (udh, 1, on));
- }
- else if (strcmp (cmd, "led2") == 0){
- CHKARGS (1);
- bool on = get_on_off (argv[optind]);
- chk_result (usrp_set_led (udh, 2, on));
- }
- else if (strcmp (cmd, "set_hash0") == 0){
- CHKARGS (1);
- char *p = argv[optind];
- unsigned char buf[16];
-
- memset (buf, ' ', 16);
- for (int i = 0; i < 16 && *p; i++)
- buf[i] = *p++;
-
- chk_result (usrp_set_hash (udh, 0, buf));
- }
- else if (strcmp (cmd, "get_hash0") == 0){
- CHKARGS (0);
- unsigned char buf[17];
- memset (buf, 0, 17);
- bool r = usrp_get_hash (udh, 0, buf);
- if (r)
- printf ("hash: %s\n", buf);
- chk_result (r);
- }
- else if (strcmp (cmd, "load_fpga") == 0){
- CHKARGS (1);
- char *filename = argv[optind];
- chk_result (usrp_load_fpga (udh, filename, true));
- }
- else if (strcmp (cmd, "load_firmware") == 0){
- CHKARGS (1);
- char *filename = argv[optind];
- chk_result (usrp_load_firmware (udh, filename, true));
- }
- else if (strcmp (cmd, "write_fpga_reg") == 0){
- CHKARGS (2);
- chk_result (usrp_write_fpga_reg (udh, strtoul (argv[optind], 0, 0),
- strtoul(argv[optind+1], 0, 0)));
- }
- else if (strcmp (cmd, "set_fpga_reset") == 0){
- CHKARGS (1);
- chk_result (usrp_set_fpga_reset (udh, get_on_off (argv[optind])));
- }
- else if (strcmp (cmd, "set_fpga_tx_enable") == 0){
- CHKARGS (1);
- chk_result (usrp_set_fpga_tx_enable (udh, get_on_off (argv[optind])));
- }
- else if (strcmp (cmd, "set_fpga_rx_enable") == 0){
- CHKARGS (1);
- chk_result (usrp_set_fpga_rx_enable (udh, get_on_off (argv[optind])));
- }
- else if (strcmp (cmd, "load_standard_bits") == 0){
- CHKARGS (0);
- usrp_close_interface (udh);
- udh = 0;
- chk_result (usrp_load_standard_bits (which_board, true));
- }
- else if (strcmp (cmd, "i2c_read") == 0){
- CHKARGS (2);
- int i2c_addr = strtol (argv[optind], 0, 0);
- int len = strtol (argv[optind + 1], 0, 0);
- if (len < 0)
- chk_result (0);
-
- unsigned char *buf = new unsigned char [len];
- bool result = usrp_i2c_read (udh, i2c_addr, buf, len);
- if (!result){
- chk_result (0);
- }
- print_hex (stdout, buf, len);
- }
- else if (strcmp (cmd, "i2c_write") == 0){
- CHKARGS (2);
- int i2c_addr = strtol (argv[optind], 0, 0);
- int len = 0;
- char *hex_string = argv[optind + 1];
- unsigned char *buf = hex_string_to_binary (hex_string, &len);
- if (buf == 0)
- chk_result (0);
-
- bool result = usrp_i2c_write (udh, i2c_addr, buf, len);
- chk_result (result);
- }
- else if (strcmp (cmd, "9862a_write") == 0){
- CHKARGS (2);
- int regno = strtol (argv[optind], 0, 0);
- int value = strtol (argv[optind+1], 0, 0);
- chk_result (usrp_9862_write (udh, 0, regno, value));
- }
- else if (strcmp (cmd, "9862b_write") == 0){
- CHKARGS (2);
- int regno = strtol (argv[optind], 0, 0);
- int value = strtol (argv[optind+1], 0, 0);
- chk_result (usrp_9862_write (udh, 1, regno, value));
- }
- else if (strcmp (cmd, "9862a_read") == 0){
- CHKARGS (1);
- int regno = strtol (argv[optind], 0, 0);
- unsigned char value;
- bool result = usrp_9862_read (udh, 0, regno, &value);
- if (!result){
- chk_result (0);
- }
- fprintf (stdout, "reg[%d] = 0x%02x\n", regno, value);
- }
- else if (strcmp (cmd, "9862b_read") == 0){
- CHKARGS (1);
- int regno = strtol (argv[optind], 0, 0);
- unsigned char value;
- bool result = usrp_9862_read (udh, 1, regno, &value);
- if (!result){
- chk_result (0);
- }
- fprintf (stdout, "reg[%d] = 0x%02x\n", regno, value);
- }
- else {
- usage ();
- }
-
- if (udh){
- usrp_close_interface (udh);
- udh = 0;
- }
-
- return 0;
-}