[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5842 - in gnuradio/branches/developers/gnychis/inband
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5842 - in gnuradio/branches/developers/gnychis/inband: pmt/src/lib usrp/host/lib/inband |
Date: |
Tue, 26 Jun 2007 09:10:02 -0600 (MDT) |
Author: gnychis
Date: 2007-06-26 09:10:00 -0600 (Tue, 26 Jun 2007)
New Revision: 5842
Modified:
gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
gnuradio/branches/developers/gnychis/inband/pmt/src/lib/qa_pmt_prims.cc
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_server.cc
Log:
Adding in new PMT code to get the length of a list which was missing
All checked in CS code is still a work in progress
Modified: gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
2007-06-26 04:51:25 UTC (rev 5841)
+++ gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
2007-06-26 15:10:00 UTC (rev 5842)
@@ -748,9 +748,27 @@
if (x->is_uniform_vector())
return _uniform_vector(x)->length();
- // FIXME list length
+ if (x->is_pair()) {
+
+ size_t length=0;
+ pmt_t alist = x;
+
+ while (pmt_is_pair(alist)){
+ pmt_t p = pmt_car(alist);
+ if (!pmt_is_pair(p)) // malformed alist
+ throw pmt_wrong_type("pmt_length", x);
+
+ alist = pmt_cdr(alist);
+ length++;
+ }
+
+ return length;
+ }
+
+
// FIXME dictionary length (number of entries)
+
throw pmt_wrong_type("pmt_length", x);
}
Modified:
gnuradio/branches/developers/gnychis/inband/pmt/src/lib/qa_pmt_prims.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/pmt/src/lib/qa_pmt_prims.cc
2007-06-26 04:51:25 UTC (rev 5841)
+++ gnuradio/branches/developers/gnychis/inband/pmt/src/lib/qa_pmt_prims.cc
2007-06-26 15:10:00 UTC (rev 5842)
@@ -138,6 +138,7 @@
pmt_t s2 = pmt_string_to_symbol("s2");
pmt_t s3 = pmt_string_to_symbol("s3");
+
pmt_t c1 = pmt_cons(s1, PMT_NIL);
CPPUNIT_ASSERT(pmt_is_pair(c1));
CPPUNIT_ASSERT(!pmt_is_pair(s1));
@@ -150,7 +151,7 @@
CPPUNIT_ASSERT_EQUAL(c2, pmt_cdr(c1));
pmt_set_car(c1, s3);
CPPUNIT_ASSERT_EQUAL(s3, pmt_car(c1));
-
+
CPPUNIT_ASSERT_THROW(pmt_cdr(PMT_NIL), pmt_wrong_type);
CPPUNIT_ASSERT_THROW(pmt_car(PMT_NIL), pmt_wrong_type);
CPPUNIT_ASSERT_THROW(pmt_set_car(s1, PMT_NIL), pmt_wrong_type);
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-26 04:51:25 UTC (rev 5841)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-06-26 15:10:00 UTC (rev 5842)
@@ -36,32 +36,14 @@
#include <iostream>
#include <pmt.h>
+#include <symbols_usrp_server_cs.h>
+#include <symbols_usrp_tx.h>
+#include <symbols_usrp_rx.h>
+#include <symbols_usrp_channel.h>
+#include <symbols_usrp_low_level_cs.h>
+
typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
-static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel");
-static pmt_t s_cmd_close = pmt_intern("cmd-close");
-static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel");
-static pmt_t s_cmd_open = pmt_intern("cmd-open");
-static pmt_t s_cmd_start_recv_raw_samples =
pmt_intern("cmd-start-recv-raw-samples");
-static pmt_t s_cmd_stop_recv_raw_samples =
pmt_intern("cmd-stop-recv-raw-samples");
-static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel");
-static pmt_t s_cmd_xmit_raw_frame = pmt_intern("cmd-xmit-raw-frame");
-static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity");
-static pmt_t s_cmd_ntx_chan = pmt_intern("cmd-ntx-chan");
-static pmt_t s_cmd_nrx_chan = pmt_intern("cmd-nrx-chan");
-static pmt_t s_cmd_current_capacity_allocation =
pmt_intern("cmd-current-capacity-allocation");
-static pmt_t s_response_allocate_channel =
pmt_intern("response-allocate-channel");
-static pmt_t s_response_close = pmt_intern("response-close");
-static pmt_t s_response_deallocate_channel =
pmt_intern("response-deallocate-channel");
-static pmt_t s_response_from_control_channel =
pmt_intern("response-from-control-channel");
-static pmt_t s_response_open = pmt_intern("response-open");
-static pmt_t s_response_recv_raw_samples =
pmt_intern("response-recv-raw-samples");
-static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame");
-static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity");
-static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan");
-static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
-static pmt_t s_response_current_capacity_allocation =
pmt_intern("response-current-capacity-allocation");
-
static bool verbose = false;
//
----------------------------------------------------------------------------------------------
@@ -1093,6 +1075,161 @@
//
----------------------------------------------------------------------------------------------
+class qa_cs_top : public mb_mblock
+{
+ mb_port_sptr d_tx;
+ mb_port_sptr d_rx;
+ mb_port_sptr d_cs;
+
+ long d_nmsgs_to_recv;
+ long d_nrecvd;
+
+ long d_max_capacity;
+ long d_ntx_chan, d_nrx_chan;
+
+ long d_nstatus;
+ long d_nstatus_to_recv;
+
+ public:
+ qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ ~qa_cs_top();
+ void initial_transition();
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void check_message(mb_message_sptr msg);
+ void run_tests();
+};
+
+qa_cs_top::qa_cs_top(mb_runtime *runtime, const std::string &instance_name,
pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg)
+{
+ d_nrecvd=0;
+ d_nmsgs_to_recv = 6;
+ d_nstatus=0;
+ d_nstatus_to_recv = 50;
+
+ 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
+ pmt_t usrp_server_dict = pmt_make_dict();
+ pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T);
+
+ // 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");
+
+}
+
+qa_cs_top::~qa_cs_top(){}
+
+void
+qa_cs_top::initial_transition()
+{
+ run_tests();
+}
+
+void
+qa_cs_top::run_tests()
+{
+ if(verbose)
+ std::cout << "[qa_cs_top] Starting tests...\n";
+
+ // Retrieve information about the USRP, then run tests
+ d_cs->send(s_cmd_open,
+ pmt_list2(pmt_list2(s_response_open, PMT_T),
+ pmt_from_long(0)));
+
+ // should be able to allocate 1 byte
+ d_tx->send(s_cmd_allocate_channel,
+ pmt_list2(PMT_T, pmt_from_long(1)));
+
+ d_tx->send(s_cmd_to_control_channel,
+ pmt_list2(PMT_NIL, pmt_list1(pmt_list3(s_op_ping_fixed, PMT_NIL,
PMT_NIL))));
+
+}
+
+void
+qa_cs_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()))
+ && pmt_eq(msg->signal(), s_response_allocate_channel))
+ check_message(msg);
+
+ if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
+
+ if(pmt_eq(msg->signal(), s_response_max_capacity)) {
+ d_max_capacity = pmt_to_long(pmt_nth(2, data));
+ if(verbose)
+ std::cout << "[qa_cs_top] USRP has max capacity of "
+ << d_max_capacity << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_ntx_chan)) {
+ d_ntx_chan = pmt_to_long(pmt_nth(2, data));
+ if(verbose)
+ std::cout << "[qa_cs_top] USRP tx channels: "
+ << d_ntx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_nrx_chan)) {
+ d_nrx_chan = pmt_to_long(pmt_nth(2, data));
+ if(verbose)
+ std::cout << "[qa_cs_top] USRP rx channels: "
+ << d_nrx_chan << "\n";
+ }
+ else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) {
+ check_message(msg);
+ }
+
+ d_nstatus++;
+
+ check_message(msg);
+
+ if(d_nstatus==d_nstatus_to_recv)
+ run_tests();
+ }
+}
+
+void
+qa_cs_top::check_message(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);
+
+ d_nrecvd++;
+
+
+ if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) {
+ if(verbose)
+ std::cout << "Got: " << status << " Expected: " << e_status << "\n";
+ shutdown_all(PMT_F);
+ return;
+ } else {
+ if(verbose)
+ std::cout << "[qa_cs_top] Received expected response for message "
+ << d_nrecvd << " (" << event << ")\n";
+ }
+
+ if(d_nrecvd == d_nmsgs_to_recv)
+ shutdown_all(PMT_T);
+}
+
+REGISTER_MBLOCK_CLASS(qa_cs_top);
+
+//
----------------------------------------------------------------------------------------------
+
void
qa_inband_usrp_server::test_open_close()
{
@@ -1162,3 +1299,17 @@
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
}
+
+void
+qa_inband_usrp_server::test_cs()
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_T;
+
+ // std::cout << "\n\n-----------------\n";
+ // std::cout << " RUNNING CS TESTS \n";
+
+ rt->run("top", "qa_cs_top", PMT_F, &result);
+
+ CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
+}
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-26 04:51:25 UTC (rev 5841)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-06-26 15:10:00 UTC (rev 5842)
@@ -33,6 +33,7 @@
CPPUNIT_TEST(test_chan_deallocation);
CPPUNIT_TEST(test_tx);
// CPPUNIT_TEST(test_rx);
+ CPPUNIT_TEST(test_cs);
CPPUNIT_TEST_SUITE_END();
private:
@@ -41,6 +42,7 @@
void test_open_close();
void test_tx();
void test_rx();
+ void test_cs();
};
#endif /* INCLUDED_QA_INBAND_USRP_SERVER_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-26 04:51:25 UTC (rev 5841)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-26 15:10:00 UTC (rev 5842)
@@ -650,8 +650,10 @@
pmt_t invocation_handle = pmt_nth(0, data);
pmt_t subpackets = pmt_nth(1, data);
- long n_subpackets = 1;//pmt_length(subpackets);
+ long n_subpackets = pmt_length(subpackets);
+ std::cout << "SUBPACKETS: " << n_subpackets << std::endl;
+
size_t psize;
long payload_len = 0;
long channel = 0x1f;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5842 - in gnuradio/branches/developers/gnychis/inband: pmt/src/lib usrp/host/lib/inband,
gnychis <=