[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5752 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5752 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Fri, 8 Jun 2007 20:55:26 -0600 (MDT) |
Author: gnychis
Date: 2007-06-08 20:55:25 -0600 (Fri, 08 Jun 2007)
New Revision: 5752
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
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
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
Log:
Fixing bug in TX allocate that broke QA code, as expected.
Adding working RX QA code.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-06-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-06-09 02:55:25 UTC (rev 5752)
@@ -853,7 +853,9 @@
if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
if(verbose)
- std::cout << "Got: " << status << " Expected: " << e_status << "\n";
+ std::cout << "[qa_xmit_top] Got: " << status
+ << " Expected: " << e_status
+ << "For signal: " << event << "\n";
shutdown_all(PMT_F);
return;
} else {
@@ -904,16 +906,16 @@
class qa_rx_top : public mb_mblock
{
- mb_port_sptr d_tx;
mb_port_sptr d_rx;
mb_port_sptr d_cs;
long d_max_capacity;
long d_ntx_chan, d_nrx_chan;
- long d_tx_chan;
long d_rx_chan;
+ long d_got_response_recv;
+
long d_nmsg_to_recv;
long d_nmsg_recvd;
@@ -932,14 +934,14 @@
};
qa_rx_top::qa_rx_top(mb_runtime *runtime, const std::string &instance_name,
pmt_t user_arg)
- : mb_mblock(runtime, instance_name, user_arg)
+ : mb_mblock(runtime, instance_name, user_arg),
+ d_got_response_recv(false)
{
d_nmsg_to_recv=12;
d_nmsg_recvd=0;
d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
- d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
// Use the stub with the usrp_server
@@ -948,7 +950,6 @@
// Test the TX side
define_component("server", "usrp_server", usrp_server_dict);
- connect("self", "tx0", "server", "tx0");
connect("self", "rx0", "server", "rx0");
connect("self", "cs", "server", "cs");
}
@@ -969,7 +970,6 @@
d_cs->send(s_cmd_open, pmt_list2(pmt_list2(s_response_open,PMT_T),
pmt_from_long(0)));
- // Try to transmit on a channel that we have no allocation for
d_rx->send(s_cmd_allocate_channel,
pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T),
pmt_from_long(1)));
@@ -978,9 +978,16 @@
pmt_list2(PMT_NIL,
pmt_from_long(0)));
+ // A small sleep is used to ensure, if working properly, a recv
+ // response comes through successfully before the close gets
+ // through
+ usleep(1000);
- // A final close which should be successful
-// d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
+ d_rx->send(s_cmd_stop_recv_raw_samples,
+ pmt_list2(PMT_NIL,
+ pmt_from_long(0)));
+
+ d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
}
@@ -989,124 +996,96 @@
qa_rx_top::handle_message(mb_message_sptr msg)
{
pmt_t data = msg->data();
-
- if (pmt_eq(msg->port_id(), d_tx->port_symbol())
- || pmt_eq(msg->port_id(), d_rx->port_symbol())) {
-
- if(pmt_eq(msg->signal(), s_response_allocate_channel))
- check_allocation(msg);
-
- if(pmt_eq(msg->signal(), s_response_xmit_raw_frame))
- check_xmit(msg);
- }
+ pmt_t event = msg->signal();
- if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
- check_cs(msg);
- }
-
- d_nmsg_recvd++;
-
- if(d_nmsg_to_recv == d_nmsg_recvd){
- shutdown_all(PMT_T);
+ if(pmt_eq(event, pmt_intern("%shutdown")))
return;
- }
-}
-
-void
-qa_rx_top::check_deallocation(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
+
pmt_t expected = pmt_nth(0, data);
pmt_t status = pmt_nth(1, data);
+
+ // For testing RX, an invocation handle is not generated by the stub,
+ // therefore the same approach for testing is not used. We simply
+ // expect all responses to be true.
+ if(pmt_eq(event, s_response_recv_raw_samples)) {
+ if(!pmt_eqv(status, PMT_T)) {
+ if(verbose)
+ std::cout << "Got: " << status << " Expected: " << PMT_T << "\n";
+ shutdown_all(PMT_F);
+ return;
+ }
+ else {
+ if(verbose)
+ std::cout << "[qa_rx_top] Received expected response for message "
+ << d_nmsg_recvd
+ << " (" << event << ")\n";
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
-
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- // std::cout << "[qa_rx_top] FAILED check_deallocation... Got: " << result
<< " Expected: " << expected_result << "\n";
- shutdown_all(PMT_F);
+ // All we want is 1 response receive! Can't guarantee exact numbers
+ d_got_response_recv = true;
+ }
return;
- } else {
- // std::cout << "[qa_rx_top] Received expected deallocation response for
message\n";
}
-}
-void
-qa_rx_top::check_allocation(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
-
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
- pmt_t channel = pmt_nth(2, data);
-
pmt_t e_event = pmt_nth(0, expected);
pmt_t e_status = pmt_nth(1, expected);
-
+
if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- // std::cout << "[qa_rx_top] FAILED check_allocation... Got: " << result
<< " Expected: " << expected_result << " for event " << msg->signal() << ")\n";
+ if(verbose)
+ std::cout << "Got: " << status << " Expected: " << e_status << "\n";
shutdown_all(PMT_F);
return;
} else {
- // std::cout << "[qa_rx_top] Received expected allocation response for
message\n";
+ if(verbose)
+ std::cout << "[qa_rx_top] Received expected response for message "
+ << d_nmsg_recvd
+ << " (" << event << ")\n";
}
-
- if(pmt_eqv(status, PMT_T)) {
- // store all of the allocate channel numbers
- if(pmt_eq(msg->port_id(), d_tx->port_symbol()))
- d_tx_chan = pmt_to_long(channel);
- if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
- d_rx_chan = pmt_to_long(channel);
- }
-}
-void
-qa_rx_top::check_xmit(mb_message_sptr msg)
-{
- pmt_t data = msg->data();
- pmt_t event = msg->signal();
+ if (pmt_eq(msg->port_id(), d_rx->port_symbol())) {
+
+ if(pmt_eq(msg->signal(), s_response_allocate_channel))
+ check_allocation(msg);
- pmt_t expected = pmt_nth(0, data);
- pmt_t status = pmt_nth(1, data);
+ }
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
+ // We stop when we get a close, we are successful if we
+ // got a response from recv, fail if we never got a recv response
+ if(pmt_eq(msg->signal(), s_response_close)) {
+
+ if(d_got_response_recv) {
+ shutdown_all(PMT_T);
+ return;
+ }
+ else {
+ shutdown_all(PMT_F);
+ if(verbose)
+ std::cout << "[qa_rx_top] No response message before close\n";
+ return;
+ }
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- //std::cout << "[qa_rx_top] FAILED check_xmit... Got: " << result
- // << " Expected: " << expected_result
- // << " for event " << msg->signal() << ")\n";
- shutdown_all(PMT_F);
- return;
- } else {
- // std::cout << "[qa_rx_top] Received expected xmit response for
message\n";
}
+
+
+ d_nmsg_recvd++;
+
}
+
void
-qa_rx_top::check_cs(mb_message_sptr msg)
+qa_rx_top::check_allocation(mb_message_sptr msg)
{
pmt_t data = msg->data();
pmt_t event = msg->signal();
-
+
pmt_t expected = pmt_nth(0, data);
pmt_t status = pmt_nth(1, data);
-
- pmt_t e_event = pmt_nth(0, expected);
- pmt_t e_status = pmt_nth(1, expected);
+ pmt_t channel = pmt_nth(2, data);
- if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
- // std::cout << "[qa_rx_top] FAILED check_cs... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << "\n";
- shutdown_all(PMT_F);
- return;
- } else {
- // std::cout << "[qa_rx_top] Received expected CS response for message ("
- // << msg->signal() << ")\n";
+ if(pmt_eqv(status, PMT_T)) {
+ // store all of the allocate channel numbers
+ if(pmt_eq(msg->port_id(), d_rx->port_symbol()))
+ d_rx_chan = pmt_to_long(channel);
}
-
}
REGISTER_MBLOCK_CLASS(qa_rx_top);
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-06-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-06-09 02:55:25 UTC (rev 5752)
@@ -32,7 +32,7 @@
CPPUNIT_TEST(test_chan_allocation);
CPPUNIT_TEST(test_chan_deallocation);
CPPUNIT_TEST(test_tx);
-// CPPUNIT_TEST(test_rx);
+ CPPUNIT_TEST(test_rx);
CPPUNIT_TEST_SUITE_END();
private:
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
2007-06-09 02:07:29 UTC (rev 5751)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
2007-06-09 02:55:25 UTC (rev 5752)
@@ -83,8 +83,12 @@
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)));
+ // Need the handle to the RX port to send responses, this is passed
+ // by the USRP interface m-block
+ d_urx =
+ boost::any_cast<usrp_standard_rx *>(pmt_any_ref(pmt_nth(1, data)));
+
pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0);
transport_pkt *pkt =
(transport_pkt *) pmt_u8vector_writeable_elements(v_pkt, ignore);
@@ -98,11 +102,13 @@
if(n_read != pkt_size) {
std::cerr << "[usrp_rx] Error reading packet, shutting down\n";
- d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
+ d_cs->send(s_response_usrp_rx_read,
+ pmt_list3(PMT_NIL, PMT_F, PMT_NIL));
return;
}
- d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
+ d_cs->send(s_response_usrp_rx_read,
+ pmt_list3(PMT_NIL, PMT_T, v_pkt));
if(verbose)
std::cout << "[usrp_rx] Read 1 packet\n";
}
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-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
2007-06-09 02:55:25 UTC (rev 5752)
@@ -23,11 +23,12 @@
#include <config.h>
#endif
+#include <usrp_rx_stub.h>
+
#include <iostream>
#include <vector>
#include <usb.h>
#include <mb_class_registry.h>
-#include <usrp_rx_stub.h>
#include <usrp_inband_usb_packet.h>
#include <fpga_regs_common.h>
#include "usrp_standard.h"
@@ -62,6 +63,8 @@
if(d_disk_write)
d_ofile.open("raw_rx.dat",std::ios::binary|std::ios::out);
+
+ usrp_rx_stop = false;
}
usrp_rx_stub::~usrp_rx_stub()
@@ -86,6 +89,9 @@
// Theoretically only have 1 message to ever expect, but
// want to make sure its at least what we want
if(pmt_eq(port_id, d_cs->port_symbol())) {
+
+ if(verbose)
+ std::cout << "Got start\n";
if(pmt_eqv(event, s_cmd_usrp_rx_start_reading))
read_and_respond(data);
@@ -96,8 +102,6 @@
usrp_rx_stub::read_and_respond(pmt_t data)
{
- usrp_rx_stop = false;
-
while(!usrp_rx_stop) {
long nsamples_this_frame = d_samples_per_frame;
@@ -143,7 +147,12 @@
d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt));
}
+
+ usrp_rx_stop = false;
+ if(verbose)
+ std::cout << "[USRP_TX_STUB] Got fake RX stop\n";
+
}
REGISTER_MBLOCK_CLASS(usrp_rx_stub);
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-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
2007-06-09 02:55:25 UTC (rev 5752)
@@ -27,6 +27,8 @@
#include "ui_nco.h"
#include <fstream>
+extern bool usrp_rx_stop; // used to communicate a 'stop' to the RX stub
+
/*!
* \brief Implements the low level usb interface to the USRP
*/
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-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-09 02:55:25 UTC (rev 5752)
@@ -129,8 +129,14 @@
// Initialize capacity on each channel to 0 and to no owner
// Also initialize the USRP standard tx/rx pointers to NULL
- reset_channels();
-
+ for(int chan=0; chan < d_ntx_chan; chan++)
+ d_chaninfo_tx.push_back(channel_info());
+
+ for(int chan=0; chan < d_nrx_chan; chan++)
+ d_chaninfo_rx.push_back(channel_info());
+
+ d_rx_chan_mask = 0;
+
//d_fake_rx=true;
}
@@ -138,11 +144,15 @@
usrp_server::reset_channels()
{
- for(int chan=0; chan < d_ntx_chan; chan++)
- d_chaninfo_tx.push_back(channel_info());
+ for(int chan=0; chan < d_ntx_chan; chan++) {
+ d_chaninfo_tx[chan].assigned_capacity = 0;
+ d_chaninfo_tx[chan].owner = PMT_NIL;
+ }
- for(int chan=0; chan < d_nrx_chan; chan++)
- d_chaninfo_rx.push_back(channel_info());
+ for(int chan=0; chan < d_nrx_chan; chan++) {
+ d_chaninfo_rx[chan].assigned_capacity = 0;
+ d_chaninfo_rx[chan].owner = PMT_NIL;
+ }
d_rx_chan_mask = 0;
}
@@ -460,7 +470,6 @@
return;
// FIX ME : no response for stopping? even if error? (permissions)
-
handle_cmd_stop_recv_raw_samples(d_rx[port], d_chaninfo_rx, data);
return;
@@ -688,7 +697,7 @@
if(d_rx_chan_mask == 0) {
if(verbose)
- std::cout << "[USRP_SERVER] Sending read request down\n";
+ std::cout << "[USRP_SERVER] Sending read request down to start recv\n";
d_cs_usrp->send(s_cmd_usrp_start_reading, pmt_list1(invocation_handle));
}
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-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-06-09 02:55:25 UTC (rev 5752)
@@ -22,14 +22,17 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
+#include <usrp_usb_interface.h>
+
#include <iostream>
#include <vector>
#include <usb.h>
#include <mb_class_registry.h>
-#include <usrp_usb_interface.h>
#include <usrp_inband_usb_packet.h>
#include <fpga_regs_common.h>
#include "usrp_rx.h"
+#include <usrp_rx_stub.h>
#include "usrp_tx.h"
#include "usrp_standard.h"
#include <stdio.h>
@@ -353,13 +356,16 @@
{
pmt_t invocation_handle = pmt_nth(0, data);
- if(verbose)
- std::cout << "[usrp_usb_interface] Stopping RX...\n";
-
- if(!d_fake_usrp)
+ if(!d_fake_usrp) {
+ if(verbose)
+ std::cout << "[usrp_usb_interface] Stopping RX...\n";
d_urx->stop();
- else
+ }
+ else {
+ if(verbose)
+ std::cout << "[usrp_usb_interface] Stopping fake RX...\n";
usrp_rx_stop = true; // extern to communicate with stub to wait
+ }
return;
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-06-09 02:07:29 UTC (rev 5751)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-06-09 02:55:25 UTC (rev 5752)
@@ -25,8 +25,6 @@
#include <vector>
#include "usrp_standard.h"
-extern bool usrp_rx_stop; // used to communicate a 'stop' to the RX stub
-
/*!
* \brief Implements the low level usb interface to the USRP
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5752 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=