[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5584 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5584 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Fri, 1 Jun 2007 09:02:25 -0600 (MDT) |
Author: gnychis
Date: 2007-06-01 09:02:25 -0600 (Fri, 01 Jun 2007)
New Revision: 5584
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.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:
Pulling the fake USRP code out of usrp_server and in to the low level code.
Putting it in the low level code ensures proper signals to and from the low
level interface. If the fake USRP code is in usrp_server, no testing is done
on a 'make check' with message relaying between the low level code to
usrp_server.
The number of packets should not be passed to the fake USRP, it should be the
number of bytes which is what the actual USRP USB bus interprets.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
2007-06-01 14:37:41 UTC (rev 5583)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.cc
2007-06-01 15:02:25 UTC (rev 5584)
@@ -38,25 +38,30 @@
fake_usrp::~fake_usrp() {}
long
-fake_usrp::write_bus(transport_pkt *pkts, long n_pkts)
+fake_usrp::write_bus(transport_pkt *pkts, long n_bytes)
{
- std::cout << "[fake_usrp] Packets over bus: " << n_pkts << "\n";
+ std::cout << "[fake_usrp] Bytes over bus: " << n_bytes << "\n";
// I'm assuming that a control packet cannot exist in a burst of data
packets,
// therefore i read only the first packet's channel in the current burst
if(pkts[0].chan() == 0x1f) {
- return control_block(pkts, n_pkts);
+ return control_block(pkts, n_bytes);
} else {
- return data_block(pkts, n_pkts);
+ return data_block(pkts, n_bytes);
}
}
long
-fake_usrp::data_block(transport_pkt *pkts, long n_pkts)
+fake_usrp::data_block(transport_pkt *pkts, long n_bytes)
{
std::cout << "[fake_usrp] Entering data block\n";
+ // Infer the number of packets from the byte count to do logical tests
+ long n_pkts = static_cast<long>(std::ceil(n_bytes /
(double)transport_pkt::max_pkt_size()));
+
+ std::cout << "[fake_usrp] Number of packets: " << n_pkts << "\n";
+
// The first packet should have the start of burst, and the last packet
should have end of burst
if(pkts[0].start_of_burst() && pkts[n_pkts-1].end_of_burst()) {
std::cout << "[fake_usrp] Correct burst flags set\n";
@@ -122,7 +127,7 @@
}
long
-fake_usrp::control_block(transport_pkt *pkts, long n_pkts)
+fake_usrp::control_block(transport_pkt *pkts, long n_bytes)
{
std::cout << "[fake_usrp] Entering control block\n";
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
2007-06-01 14:37:41 UTC (rev 5583)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/fake_usrp.h
2007-06-01 15:02:25 UTC (rev 5584)
@@ -32,11 +32,11 @@
public:
fake_usrp();
~fake_usrp();
- long write_bus(transport_pkt *pkts, long n_pkts);
+ long write_bus(transport_pkt *pkts, long n_bytes);
protected:
- long data_block(transport_pkt *pkts, long n_pkts);
- long control_block(transport_pkt *pkts, long n_pkts);
+ long data_block(transport_pkt *pkts, long n_bytes);
+ long control_block(transport_pkt *pkts, long n_bytes);
};
#endif /* INCLUDED_FAKE_USRP_H */
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-01 14:37:41 UTC (rev 5583)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-01 15:02:25 UTC (rev 5584)
@@ -27,13 +27,10 @@
#include <usrp_inband_usb_packet.h>
#include <mb_class_registry.h>
#include <vector>
-#include <fake_usrp.h>
#include <usrp_usb_interface.h>
typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
-#define FAKE_USRP_TESTS
-
// FIXME We should machine generate these by a simple preprocessor run over
this file
//
// These are all the messages that we expect to receive.
@@ -233,32 +230,15 @@
if (pmt_eq(event, s_cmd_open)){
-#ifdef FAKE_USRP_TESTS
-
- // When we are testing a fake USRP we don't need to open the interface
and just
- // send a correct response
- reply_data = pmt_list2(invocation_handle, PMT_T);
- d_cs->send(s_response_open, reply_data);
-
- #else
-
// 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);
-
- #endif
return;
}
else if (pmt_eq(event, s_cmd_close)){
invocation_handle = pmt_nth(0, data);
-#ifdef FAKE_USRP_TESTS
- // Just respond successfully if using fake USRP
- reply_data = pmt_list2(invocation_handle, PMT_T);
- d_cs->send(s_response_close, reply_data);
-#else
d_cs_usrp->send(s_cmd_usrp_close, pmt_list1(PMT_NIL));
-#endif
return;
}
@@ -549,23 +529,10 @@
pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of
burst
std::cout << "[USRP_SERVER] Received raw frame for invocation " <<
pmt_to_long(invocation_handle) << " --> " << n_packets << " packets\n";
-
-#ifdef FAKE_USRP_TESTS
- fake_usrp usrp;
- if(!usrp.write_bus(pkts, n_packets))
- reply_data = pmt_list2(invocation_handle, PMT_F);
- else
- reply_data = pmt_list2(invocation_handle, PMT_T);
-
- d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
-#else
-
// The actual response to the write will be generated by a
s_response_usrp_write
d_cs_usrp->send(s_cmd_usrp_write, pmt_list4(PMT_NIL,
pmt_from_long(channel), v_packets,
pmt_from_long(n_packets*transport_pkt::max_pkt_size())));
-#endif
-
}
}
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-01 14:37:41 UTC (rev 5583)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-06-01 15:02:25 UTC (rev 5584)
@@ -29,7 +29,10 @@
#include <usrp_usb_interface.h>
#include <usrp_inband_usb_packet.h>
#include "usrp_standard.h"
+#include <fake_usrp.h>
+#define FAKE_USRP_TESTS
+
typedef usrp_inband_usb_packet transport_pkt;
static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open");
@@ -118,6 +121,9 @@
std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " <<
which_usrp << "\n";
+// do not execute any of this code when a fake USRP is being used, just send a
true response
+#ifndef FAKE_USRP_TESTS
+
// Open up a standard RX and TX for communication with the USRP
d_utx = usrp_standard_tx::make (which_usrp,
@@ -141,6 +147,8 @@
return;
}
+ d_utx->start();
+
std::cout << "[USRP_USB_INTERFACE] Setup TX channel\n";
d_urx = usrp_standard_rx::make (which_usrp,
@@ -164,6 +172,8 @@
d_cs->send(s_response_usrp_open, reply_data);
return;
}
+
+ // d_urx->start() // FIXME: currently causing a hang
std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n";
if(rx_mode & usrp_standard_rx::FPGA_MODE_LOOPBACK)
@@ -171,6 +181,8 @@
if(rx_mode & usrp_standard_rx::FPGA_MODE_COUNTING)
std::cout << "[USRP_USB_INTERFACE] - counting enabled\n";
+#endif
+
d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
}
@@ -187,7 +199,7 @@
transport_pkt *pkts = (transport_pkt *)
pmt_u8vector_writeable_elements(v_packets, psize);
- d_utx->start();
+#ifndef FAKE_USRP_TESTS
int ret = d_utx->write (pkts, n_bytes, &underrun);
@@ -204,8 +216,21 @@
d_cs->send(s_response_usrp_write, pmt_list3(invocation_handle,
pmt_from_long(channel), PMT_F));
}
- d_utx->stop();
-
+#else
+
+ // setup a fake USRP and write to the fake USB bus
+ fake_usrp usrp;
+ pmt_t reply_data;
+
+ if(!usrp.write_bus(pkts, n_bytes))
+ reply_data = pmt_list3(invocation_handle, pmt_from_long(channel), PMT_F);
+ else
+ reply_data = pmt_list3(invocation_handle, pmt_from_long(channel), PMT_T);
+
+ d_cs->send(s_response_usrp_write, reply_data);
+
+#endif
+
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5584 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=