commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r6394 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r6394 - gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband
Date: Mon, 10 Sep 2007 20:11:50 -0600 (MDT)

Author: gnychis
Date: 2007-09-10 20:11:50 -0600 (Mon, 10 Sep 2007)
New Revision: 6394

Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.cc
   gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.mbh
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
Log:
GMAC now sends a response to the application once it is initialized, rather than
the application have to send a command to say "initialize" ... if it's being
connected to it just automatically initializes and responds when ready.

The test application now handles messages, GMAC needs to handle incoming and
outgoing samples still.


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.cc   
2007-09-11 01:41:04 UTC (rev 6393)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.cc   
2007-09-11 02:11:50 UTC (rev 6394)
@@ -47,6 +47,8 @@
 #include <symbols_usrp_tx.h>
 #include <symbols_usrp_rx.h>
 
+#include <gmac_symbols.h>
+
 static bool verbose = true;
 
 gmac::gmac(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg)
@@ -267,7 +269,7 @@
 
  // Received an unhandled message for a specific state
  unhandled:
-  if(verbose && !pmt_eq(event, pmt_intern("%shutdown")))
+  if(0 && verbose && !pmt_eq(event, pmt_intern("%shutdown")))
     std::cout << "test_usrp_inband_us_tx: unhandled msg: " << msg
               << "in state "<< d_state << std::endl;
 }
@@ -346,6 +348,9 @@
   // Set carrier sense to enabled by default with the specified threshold
   set_carrier_sense(true, 21, PMT_NIL);
 
+  // Can now notify the application that we are initialized
+  d_cs->send(s_response_gmac_initialized,
+             pmt_list2(PMT_NIL, PMT_T));
 }
 
 // Method for setting the carrier sense and an associated threshold which is

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.mbh
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.mbh  
2007-09-11 01:41:04 UTC (rev 6393)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac.mbh  
2007-09-11 02:11:50 UTC (rev 6394)
@@ -132,6 +132,8 @@
 
   (:incoming
 
+    (response-gmac-initialized invocation-handle status)
+
     (response-enable-carrier-sense invocation-handle status)
     (response-disable-carrier-sense invocation-handle status)
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
    2007-09-11 01:41:04 UTC (rev 6393)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/gmac_symbols.h
    2007-09-11 02:11:50 UTC (rev 6394)
@@ -35,6 +35,7 @@
 static pmt_t s_enable_carrier_sense = pmt_intern("cmd-enable-carrier-sense");
 static pmt_t s_disable_carrier_sense = pmt_intern("cmd-disable-carrier-sense");
 static pmt_t s_set_tx_retries = pmt_intern("cmd-set-tx-retries");
+static pmt_t s_response_gmac_initialized = 
pmt_intern("response-gmac-initialized");
 static pmt_t s_response_enable_carrier_sense = 
pmt_intern("response-enable-carrier-sense");
 static pmt_t s_response_disable_carrier_sense = 
pmt_intern("response-disable-carrier-sense");
 static pmt_t s_response_set_tx_retries = pmt_intern("response-set-tx-retries");

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
   2007-09-11 01:41:04 UTC (rev 6393)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps-inband/test_gmac_tx.cc
   2007-09-11 02:11:50 UTC (rev 6394)
@@ -52,11 +52,7 @@
 
   enum state_t {
     INIT,
-    OPENING_USRP,
-    ALLOCATING_CHANNEL,
     TRANSMITTING,
-    CLOSING_CHANNEL,
-    CLOSING_USRP,
   };
 
   state_t      d_state;
@@ -73,7 +69,6 @@
  public:
   test_gmac_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t 
user_arg);
   ~test_gmac_tx();
-  void initial_transition();
   void handle_message(mb_message_sptr msg);
 
  protected:
@@ -92,8 +87,6 @@
     d_state(INIT), d_nsamples_to_send((long) 40e6),
     d_nsamples_xmitted(0),
     d_nframes_xmitted(0),
-    //d_samples_per_frame((long)(126)),
-    //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)
@@ -119,13 +112,75 @@
 }
 
 void
-test_gmac_tx::initial_transition()
+test_gmac_tx::handle_message(mb_message_sptr msg)
 {
-}
+  pmt_t event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t port_id = msg->port_id();
 
-void
-test_gmac_tx::handle_message(mb_message_sptr msg)
-{
+  pmt_t handle = PMT_F;
+  pmt_t status = PMT_F;
+  pmt_t dict = PMT_NIL;
+  std::string error_msg;
+
+  // Dispatch based on state
+  switch(d_state) {
+    
+    //------------------------------ INIT ---------------------------------//
+    // When GMAC is done initializing, it will send a response
+    case INIT:
+      
+      if(pmt_eq(event, s_response_gmac_initialized)) {
+        handle = pmt_nth(0, data);
+        status = pmt_nth(1, data);
+
+        if(pmt_eq(status, PMT_T)) {
+          enter_transmitting();
+          return;
+        }
+        else {
+          error_msg = "error initializing gmac:";
+          goto bail;
+        }
+      }
+      goto unhandled;
+
+    //-------------------------- TRANSMITTING ----------------------------//
+    // In the transmit state we count the number of underruns received and
+    // ballpark the number with an expected count (something >1 for starters)
+    case TRANSMITTING:
+      
+      // Check that the transmits are OK
+      if (pmt_eq(event, s_response_tx_pkt)){
+        handle = pmt_nth(0, data);
+        status = pmt_nth(1, data);
+
+        if (pmt_eq(status, PMT_T)){
+          handle_xmit_response(handle);
+          return;
+        }
+        else {
+          error_msg = "bad response-xmit-raw-frame:";
+          goto bail;
+        }
+      }
+
+      goto unhandled;
+
+  }
+
+ // An error occured, print it, and shutdown all m-blocks
+ bail:
+  std::cerr << error_msg << data
+           << "status = " << status << std::endl;
+  shutdown_all(PMT_F);
+  return;
+
+ // Received an unhandled message for a specific state
+ unhandled:
+  if(verbose && !pmt_eq(event, pmt_intern("%shutdown")))
+    std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+              << "in state "<< d_state << std::endl;
 }
 
 void





reply via email to

[Prev in Thread] Current Thread [Next in Thread]