[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5701 - in gnuradio/branches/developers/gnychis/inband
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5701 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband |
Date: |
Tue, 5 Jun 2007 21:37:55 -0600 (MDT) |
Author: gnychis
Date: 2007-06-05 21:37:54 -0600 (Tue, 05 Jun 2007)
New Revision: 5701
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
Log:
Work in progress on testing RX side
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
2007-06-06 03:37:54 UTC (rev 5701)
@@ -115,8 +115,8 @@
d_state(INIT), d_nsamples_to_send((long) 40e6),
d_nsamples_recvd(0),
d_nframes_recvd(0),
- //d_samples_per_frame((long)(126 * 3.5)), // non-full packet
- d_samples_per_frame((long)(126 * 4)), // full packet
+ 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)
{
@@ -124,8 +124,8 @@
d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
- //bool fake_usrp_p = true;
- bool fake_usrp_p = false;
+ bool fake_usrp_p = true;
+ //bool fake_usrp_p = false;
// Test the TX side
@@ -134,8 +134,8 @@
if(fake_usrp_p)
pmt_dict_set(usrp_server_dict,
- pmt_intern("usrp-interface"),
- pmt_intern("usrp_usb_interface_stub"));
+ pmt_intern("fake-usrp"),
+ PMT_T);
define_component("server", "usrp_server", usrp_server_dict);
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
2007-06-06 03:37:54 UTC (rev 5701)
@@ -332,14 +332,14 @@
if (1){
gr_complex s;
d_nco.sincos(&s, 1, d_amplitude);
- // write 16-bit I & Q
+ // 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
+ // write 16-bit i & q
samples[2*i] = (int16_t) s.real();
samples[2*i+1] = (int16_t) s.imag();
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
2007-06-06 03:37:54 UTC (rev 5701)
@@ -22,7 +22,7 @@
INCLUDES = \
$(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \
- $(USRP_INCLUDES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES)
+ $(USRP_INCLUDES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES) -I../../apps
TESTS = test_inband
@@ -60,6 +60,7 @@
usrp_tx.cc
\
usrp_tx_stub.cc \
usrp_rx.cc
\
+ ../../apps/ui_sincos.c \
usrp_rx_stub.cc
libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
2007-06-06 03:37:54 UTC (rev 5701)
@@ -32,6 +32,8 @@
#include <fpga_regs_common.h>
#include "usrp_standard.h"
#include <stdio.h>
+#include "ui_nco.h"
+#include <fstream>
typedef usrp_inband_usb_packet transport_pkt;
@@ -41,14 +43,29 @@
static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read");
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)
+ : mb_mblock(rt, instance_name, user_arg),
+ d_samples_per_frame((long)(126)),
+ d_amplitude(16384),
+ d_disk_write(false)
{
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 = 128e6 / 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_stub::~usrp_rx_stub()
{
+ if(d_disk_write)
+ d_ofile.close();
}
void
@@ -76,34 +93,51 @@
void
usrp_rx_stub::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);
- d_urx = boost::any_cast<usrp_standard_rx *>(pmt_any_ref(pmt_nth(1, data)));
+ while(1) {
- pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
- transport_pkt *pkt =
- (transport_pkt *) pmt_u8vector_writeable_elements(v_pkt, ignore);
+ long nsamples_this_frame = d_samples_per_frame;
- if(verbose)
- std::cout << "[usrp_rx_stub] Waiting for packets..\n";
-
- // Read by 512 which is packet size and send them back up
- while(1) {
- n_read = d_urx->read(pkt, pkt_size, &underrun);
+ 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_writeable_elements(uvec, ignore);
- if(n_read != pkt_size) {
- std::cerr << "[usrp_rx_stub] Error reading packet, shutting down\n";
- d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
- return;
+ // 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_writeable_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));
- if(verbose)
- std::cout << "[usrp_rx_stub] Read 1 packet\n";
+
}
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
2007-06-06 03:37:54 UTC (rev 5701)
@@ -24,6 +24,8 @@
#include <mb_mblock.h>
#include <vector>
#include "usrp_standard.h"
+#include "ui_nco.h"
+#include <fstream>
/*!
* \brief Implements the low level usb interface to the USRP
@@ -35,6 +37,16 @@
mb_port_sptr d_cs;
usrp_standard_rx* d_urx;
+ long d_samples_per_frame;
+
+ // 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();
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-06 03:37:54 UTC (rev 5701)
@@ -130,7 +130,7 @@
// Also initialize the USRP standard tx/rx pointers to NULL
reset_channels();
- d_fake_rx=true;
+ //d_fake_rx=true;
}
void
@@ -796,7 +796,13 @@
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(verbose)
std::cout << "[USRP_SERVER] Received raw samples\n";
@@ -815,6 +821,29 @@
return;
}
+ // Extract the packet and return appropriately
+ transport_pkt *pkt = (transport_pkt *)
pmt_u8vector_writeable_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;
+
+ 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_writeable_elements(v_samples, ignore);
+
+ memcpy(samples, pkt->payload(), payload_len);
+
+ d_cs->send(s_response_recv_raw_samples,
+ pmt_list5(invocation_handle,
+ status,
+ v_samples,
+ pmt_from_long(pkt->timestamp()),
+ PMT_NIL));
+ return;
}
void
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-06-06 01:09:14 UTC (rev 5700)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-06-06 03:37:54 UTC (rev 5701)
@@ -174,14 +174,7 @@
// Relay reads back up
if(pmt_eq(event, s_response_usrp_rx_read)) {
-
- pmt_t invocation_handle = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t samples = pmt_nth(2, data);
- d_cs->send(s_response_usrp_read,
- pmt_list3(invocation_handle,
- status,
- samples));
+ d_cs->send(s_response_usrp_read, data);
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5701 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband,
gnychis <=