[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6393 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r6393 - gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband |
Date: |
Mon, 10 Sep 2007 19:41:04 -0600 (MDT) |
Author: gnychis
Date: 2007-09-10 19:41:04 -0600 (Mon, 10 Sep 2007)
New Revision: 6393
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/
Log:
Adding in bare bones test program for the gmac
Property changes on:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband
___________________________________________________________________
Name: svn:ignore
- 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
test_usrp_inband_underrun
test_usrp_inband_overrun
gmac_mbh.cc
+ Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
*.dat
.*.swp
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
test_usrp_inband_underrun
test_usrp_inband_overrun
gmac_mbh.cc
test_gmac_tx
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
(rev 0)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
2007-09-11 01:41:04 UTC (rev 6393)
@@ -0,0 +1,42 @@
+/* -*- 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_GMAC_SYMBOLS_H
+#define INCLUDED_GMAC_SYMBOLS_H
+
+#include <pmt.h>
+
+// TX
+static pmt_t s_cmd_tx_pkt = pmt_intern("cmd-tx-pkt");
+static pmt_t s_response_tx_pkt = pmt_intern("response-tx-pkt");
+
+// RX
+static pmt_t s_response_rx_pkt = pmt_intern("response-rx-pkt");
+
+// CS
+static pmt_t s_enable_carrier_sense = pmt_intern("cmd-enable-carrier-sense");
+static pmt_t s_disable_carrier_sense = pmt_intern("cmd-disable-carrier-sense");
+static pmt_t s_set_tx_retries = pmt_intern("cmd-set-tx-retries");
+static pmt_t s_response_enable_carrier_sense =
pmt_intern("response-enable-carrier-sense");
+static pmt_t s_response_disable_carrier_sense =
pmt_intern("response-disable-carrier-sense");
+static pmt_t s_response_set_tx_retries = pmt_intern("response-set-tx-retries");
+
+#endif // INCLUDED_GMAC_SYMBOLS_H
Added:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
(rev 0)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
2007-09-11 01:41:04 UTC (rev 6393)
@@ -0,0 +1,233 @@
+/* -*- 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 <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_runtime_nop.h> // QA only
+#include <mb_protocol_class.h>
+#include <mb_exception.h>
+#include <mb_msg_queue.h>
+#include <mb_message.h>
+#include <mb_mblock_impl.h>
+#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
+#include <pmt.h>
+#include <ui_nco.h>
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+
+#include <gmac.h>
+#include <gmac_symbols.h>
+
+static bool verbose = true;
+
+class test_gmac_tx : public mb_mblock
+{
+ mb_port_sptr d_tx;
+ mb_port_sptr d_cs;
+ pmt_t d_tx_chan; // returned tx channel handle
+
+ enum state_t {
+ INIT,
+ OPENING_USRP,
+ ALLOCATING_CHANNEL,
+ TRANSMITTING,
+ CLOSING_CHANNEL,
+ CLOSING_USRP,
+ };
+
+ state_t d_state;
+ long d_nsamples_to_send;
+ long d_nsamples_xmitted;
+ long d_nframes_xmitted;
+ long d_samples_per_frame;
+ bool d_done_sending;
+
+ // for generating sine wave output
+ ui_nco<float,float> d_nco;
+ double d_amplitude;
+
+ public:
+ test_gmac_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ ~test_gmac_tx();
+ void initial_transition();
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void open_usrp();
+ void close_usrp();
+ void allocate_channel();
+ void send_packets();
+ void enter_transmitting();
+ void build_and_send_next_frame();
+ void handle_xmit_response(pmt_t invocation_handle);
+ void enter_closing_channel();
+};
+
+test_gmac_tx::test_gmac_tx(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg),
+ d_state(INIT), d_nsamples_to_send((long) 40e6),
+ d_nsamples_xmitted(0),
+ d_nframes_xmitted(0),
+ //d_samples_per_frame((long)(126)),
+ //d_samples_per_frame((long)(126 * 3.5)), // non-full packet
+ d_samples_per_frame((long)(126 * 4)), // full packet
+ d_done_sending(false),
+ d_amplitude(16384)
+{
+
+ define_component("GMAC", "gmac", PMT_NIL);
+ d_tx = define_port("tx0", "gmac-tx", false, mb_port::INTERNAL);
+ d_cs = define_port("cs", "gmac-cs", false, mb_port::INTERNAL);
+
+ connect("self", "tx0", "GMAC", "tx0");
+ connect("self", "cs", "GMAC", "cs");
+
+ // initialize NCO
+ double freq = 100e3;
+ int interp = 32; // 32 -> 4MS/s
+ double sample_rate = 128e6 / interp;
+ d_nco.set_freq(2*M_PI * freq/sample_rate);
+
+}
+
+test_gmac_tx::~test_gmac_tx()
+{
+}
+
+void
+test_gmac_tx::initial_transition()
+{
+}
+
+void
+test_gmac_tx::handle_message(mb_message_sptr msg)
+{
+}
+
+void
+test_gmac_tx::enter_transmitting()
+{
+ d_state = TRANSMITTING;
+ d_nsamples_xmitted = 0;
+
+ build_and_send_next_frame(); // fire off 4 to start pipeline
+ build_and_send_next_frame();
+ build_and_send_next_frame();
+ build_and_send_next_frame();
+}
+
+void
+test_gmac_tx::build_and_send_next_frame()
+{
+ // allocate the uniform vector for the samples
+ // FIXME perhaps hold on to this between calls
+
+#if 1
+ long nsamples_this_frame =
+ std::min(d_nsamples_to_send - d_nsamples_xmitted,
+ d_samples_per_frame);
+#else
+ long nsamples_this_frame = d_samples_per_frame;
+#endif
+
+ if (nsamples_this_frame == 0){
+ d_done_sending = true;
+ return;
+ }
+
+
+ size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q
+ pmt_t uvec = pmt_make_s16vector(nshorts, 0);
+ size_t ignore;
+ int16_t *samples = pmt_s16vector_writeable_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();
+ }
+ }
+
+ pmt_t tx_properties = pmt_make_dict();
+ pmt_dict_set(tx_properties,
+ pmt_intern("carrier-sense"),
+ PMT_T);
+
+ pmt_t timestamp = pmt_from_long(0xffffffff); // NOW
+ d_tx->send(s_cmd_tx_pkt,
+ pmt_list4(PMT_NIL, // invocation-handle
+ PMT_NIL, // destination
+ uvec, // the samples
+ PMT_NIL)); // no properties yet!
+
+ d_nsamples_xmitted += nsamples_this_frame;
+ d_nframes_xmitted++;
+
+ if(verbose)
+ std::cout << "[TEST_GMAC_TX] Transmitted frame\n";
+}
+
+
+void
+test_gmac_tx::handle_xmit_response(pmt_t handle)
+{
+ if (d_done_sending &&
+ pmt_to_long(handle) == (d_nframes_xmitted - 1)){
+ // We're done sending and have received all responses
+ }
+
+ build_and_send_next_frame();
+}
+
+REGISTER_MBLOCK_CLASS(test_gmac_tx);
+
+
+// ----------------------------------------------------------------
+
+int
+main (int argc, char **argv)
+{
+ // handle any command line args here
+
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_NIL;
+
+ rt->run("test_gmac_tx", "test_gmac_tx", PMT_F, &result);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6393 - gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband,
gnychis <=