[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8452 - in usrp2/branches/developers/jcorgan/u2/host:
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8452 - in usrp2/branches/developers/jcorgan/u2/host: gr-usrp2 lib |
Date: |
Mon, 19 May 2008 16:26:19 -0600 (MDT) |
Author: jcorgan
Date: 2008-05-19 16:26:18 -0600 (Mon, 19 May 2008)
New Revision: 8452
Added:
usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.cc
usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.h
usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.cc
usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.h
Modified:
usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am
usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
Log:
wip
Modified:
usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
2008-05-19 21:39:39 UTC (rev 8451)
+++ usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
2008-05-19 22:26:18 UTC (rev 8452)
@@ -29,7 +29,7 @@
#include <gr_io_signature.h>
#include <iostream>
-#define USRP2_SOURCE_BASE_DEBUG 0
+#define USRP2_SOURCE_BASE_DEBUG 1
#define SAMPLES_PER_PACKET 250
@@ -130,16 +130,12 @@
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- int nsamples = std::min(noutput_items, SAMPLES_PER_PACKET);
- u2_eth_samples_t eth_samples;
- int n = d_u2->read_samples(ð_samples, nsamples);
- if (n < 0)
- return -1; // we're done
-
- copy_from_usrp2_buffer(ð_samples.samples[0], output_items[0], n);
+ // copy_from_usrp2_buffer(buffer, output_items[0], n);
+ int n = noutput_items; //dummy
+
if (USRP2_SOURCE_BASE_DEBUG)
- printf("noutput_items=%d nsamples=%d n=%d\n", noutput_items, nsamples, n);
+ ::write(1, ".", 1);
return n;
}
Modified: usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am 2008-05-19
21:39:39 UTC (rev 8451)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am 2008-05-19
22:26:18 UTC (rev 8452)
@@ -31,8 +31,10 @@
gri_ethernet_pfring.cc \
gri_if_stats.cc \
gri_pktfilter.cc \
+ ringbuffer.cc \
strtod_si.c \
- usrp2_basic.cc
+ usrp2_basic.cc \
+ usrp2_basic_thread.cc
libpfring_la_SOURCES = \
pfring.c
@@ -46,7 +48,9 @@
gri_ethernet_pfring.h \
gri_if_stats.h \
gri_pktfilter.h \
+ ringbuffer.h \
strtod_si.h \
usrp2_tune_result.h \
- usrp2_basic.h
+ usrp2_basic.h \
+ usrp2_basic_thread.h
Added: usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.cc
(rev 0)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.cc 2008-05-19
22:26:18 UTC (rev 8452)
@@ -0,0 +1,34 @@
+/* -*- 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 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 <ringbuffer.h>
+
+#define RINGBUFFER_DEBUG 1
+
+ringbuffer::ringbuffer(size_t nsamples)
+{
+}
+
Added: usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.h
(rev 0)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/ringbuffer.h 2008-05-19
22:26:18 UTC (rev 8452)
@@ -0,0 +1,37 @@
+/* -*- 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 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_RINGBUFFER_H
+#define INCLUDED_RINGBUFFER_H
+
+#include <boost/shared_ptr.hpp>
+
+class ringbuffer
+{
+public:
+
+ ringbuffer(size_t nsamples);
+};
+
+#endif /* INCLUDED_RINGBUFFER_H */
+
+typedef boost::shared_ptr<ringbuffer> ringbuffer_sptr;
Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
2008-05-19 21:39:39 UTC (rev 8451)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
2008-05-19 22:26:18 UTC (rev 8452)
@@ -20,6 +20,7 @@
#include "config.h"
#endif
#include "usrp2_basic.h"
+#include "usrp2_basic_thread.h"
#include "gri_ethernet.h"
#include "gri_ethernet_pfring.h" // FIXME
#include "gri_pktfilter.h"
@@ -37,7 +38,7 @@
#include <unistd.h>
#endif
-#define USRP2_BASIC_DEBUG 0
+#define USRP2_BASIC_DEBUG 1
/*
* Note, this should be considered a first cut at getting
@@ -65,7 +66,8 @@
}
usrp2_basic::usrp2_basic(const std::string &ifc, const u2_mac_addr_t &addr)
- : d_ethernet(new GRI_ETHERNET()), d_pf(0), d_seqno(0), d_next_rid(0)
+ : d_ethernet(new GRI_ETHERNET()), d_pf(0), d_seqno(0), d_next_rid(0),
+ d_thread(0)
{
if (USRP2_BASIC_DEBUG)
std::cout << "usrp2_basic: constructor" << std::endl;
@@ -400,6 +402,8 @@
if (d_ethernet->write_packet(c, len) != len)
return false;
+ d_thread = new usrp2_basic_thread(this);
+ d_thread->start();
return true;
}
@@ -423,6 +427,9 @@
if (d_ethernet->write_packet(c, len) != len)
return false;
+ d_thread->stop();
+ d_thread = 0; // pthread derived objects delete themselves
+
return true;
}
@@ -823,3 +830,9 @@
return memcmp(&a, &b, sizeof(u2_mac_addr_t)) == 0;
}
+void usrp2_basic::loop()
+{
+ ::write(1, "B", 1);
+ struct timespec ts = { (__time_t)0.01, 0 };
+ nanosleep(&ts, NULL);
+}
Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-19
21:39:39 UTC (rev 8451)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-19
22:26:18 UTC (rev 8452)
@@ -34,12 +34,15 @@
class usrp2_basic;
typedef boost::shared_ptr<usrp2_basic> usrp2_basic_sptr;
+class usrp2_basic_thread;
+
usrp2_basic_sptr usrp2_make_basic(const std::string &ifc, const u2_mac_addr_t
&addr);
class usrp2_basic : public boost::noncopyable
{
private:
friend usrp2_basic_sptr usrp2_make_basic(const std::string &ifc, const
u2_mac_addr_t &addr);
+ friend class usrp2_basic_thread;
usrp2_basic(const std::string &ifc, const u2_mac_addr_t &addr);
GRI_ETHERNET *d_ethernet;
@@ -48,6 +51,7 @@
int d_next_rid;
u2_mac_addr_t d_addr;
int d_rx_decim;
+ usrp2_basic_thread *d_thread;
void init_et_hdrs(u2_eth_packet_t *p, const u2_mac_addr_t &dst);
@@ -55,6 +59,8 @@
const u2_mac_addr_t &dst,
int word0_flags, int chan, uint32_t timestamp);
+ void loop();
+
public:
// ---- Static methods ----
Added: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.cc
(rev 0)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.cc
2008-05-19 22:26:18 UTC (rev 8452)
@@ -0,0 +1,79 @@
+/* -*- 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 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 <usrp2_basic_thread.h>
+
+#define USRP2_BASIC_THREAD_DEBUG 1
+
+usrp2_basic_thread::usrp2_basic_thread(usrp2_basic *u2) :
+ omni_thread(NULL, PRIORITY_NORMAL),
+ d_u2(u2), d_keep_running(false)
+{
+ if (USRP2_BASIC_THREAD_DEBUG)
+ std::cout << "usrp2_basic_thread: constructor" << std::endl;
+}
+
+usrp2_basic_thread::~usrp2_basic_thread()
+{
+ if (USRP2_BASIC_THREAD_DEBUG)
+ std::cout << "usrp2_basic_thread: destructor" << std::endl;
+
+ if (d_keep_running)
+ stop();
+
+ // we don't own this, so don't delete
+ d_u2 = 0;
+}
+
+void usrp2_basic_thread::start()
+{
+ if (USRP2_BASIC_THREAD_DEBUG)
+ std::cout << "usrp2_basic_thread::start() "
+ << this << std::endl;
+ d_keep_running = true;
+ start_undetached();
+}
+
+void *
+usrp2_basic_thread::run_undetached(void *arg)
+{
+ // This is the first code to run in the new thread context.
+ while(d_keep_running)
+ d_u2->loop();
+
+ return 0;
+}
+
+void
+usrp2_basic_thread::stop()
+{
+ if (0 && USRP2_BASIC_THREAD_DEBUG) // FIXME not safe to call from
signal handler
+ std::cout << "usrp2_basic_thread::stop() "
+ << this << std::endl;
+ d_keep_running = false;
+ void *dummy_status;
+ join(&dummy_status);
+}
Added: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.h
(rev 0)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic_thread.h
2008-05-19 22:26:18 UTC (rev 8452)
@@ -0,0 +1,46 @@
+/* -*- 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 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_USRP2_BASIC_THREAD_H
+#define INCLUDED_USRP2_BASIC_THREAD_H
+
+#include <omnithread.h>
+#include <usrp2_basic.h>
+#include <iostream>
+
+class usrp2_basic_thread : public omni_thread
+{
+private:
+ usrp2_basic *d_u2;
+ bool d_keep_running;
+
+public:
+ usrp2_basic_thread(usrp2_basic *u2);
+ ~usrp2_basic_thread();
+
+ void start();
+ void stop();
+
+ virtual void *run_undetached(void *arg);
+};
+
+#endif /* INCLUDED_USRP2_BASIC_THREAD_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8452 - in usrp2/branches/developers/jcorgan/u2/host: gr-usrp2 lib,
jcorgan <=