commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5629 - in gnuradio/branches/developers/eb/ibu/usrp/ho


From: eb
Subject: [Commit-gnuradio] r5629 - in gnuradio/branches/developers/eb/ibu/usrp/host: apps lib/inband
Date: Sat, 2 Jun 2007 22:32:22 -0600 (MDT)

Author: eb
Date: 2007-06-02 22:32:21 -0600 (Sat, 02 Jun 2007)
New Revision: 5629

Modified:
   gnuradio/branches/developers/eb/ibu/usrp/host/apps/test_usrp_inband_tx.cc
   gnuradio/branches/developers/eb/ibu/usrp/host/lib/inband/usrp_server.mbh
Log:
starting to work

Modified: 
gnuradio/branches/developers/eb/ibu/usrp/host/apps/test_usrp_inband_tx.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/usrp/host/apps/test_usrp_inband_tx.cc   
2007-06-03 03:54:53 UTC (rev 5628)
+++ gnuradio/branches/developers/eb/ibu/usrp/host/apps/test_usrp_inband_tx.cc   
2007-06-03 04:32:21 UTC (rev 5629)
@@ -66,7 +66,6 @@
 {
   mb_port_sptr         d_tx;
   mb_port_sptr         d_cs;
-
   pmt_t                d_tx_chan;      // returned tx channel handle
 
   enum state_t {
@@ -75,10 +74,12 @@
     ALLOCATING_CHANNEL,
     TRANSMITTING,
     CLOSING_CHANNEL,
-    CLOSE_USRP,
+    CLOSING_USRP,
   };
 
   state_t      d_state;
+  long         d_nsamples_to_send;
+  long         d_nsamples_transmitted;
 
   // for generating sine wave output
   ui_nco<float,float>  d_nco;
@@ -94,12 +95,14 @@
   void close_usrp();
   void allocate_channel();
   void send_packets();
+  void enter_transmitting();
 };
 
 test_usrp_tx::test_usrp_tx(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_state(INIT), d_nsamples_to_send((long) 40e6), d_nsamples_transmitted(0)
 { 
-  std::cout << "[TEST_USRP_TX] Initializing...\n";
+  // std::cout << "[TEST_USRP_TX] Initializing...\n";
   
   d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
   d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
@@ -134,6 +137,59 @@
 void
 test_usrp_tx::handle_message(mb_message_sptr msg)
 {
+  pmt_t        event = msg->signal();
+  pmt_t data = msg->data();
+  pmt_t status = PMT_F;
+  
+  std::cout << msg << std::endl;
+
+  switch(d_state){
+  case OPENING_USRP:
+    if (pmt_eq(event, s_response_open)){
+      status = pmt_nth(1, data);
+      if (pmt_eq(status, PMT_T)){
+       allocate_channel();
+       return;
+      }
+      else {
+       std::cerr << "failed to open usrp:" << data
+                 << "status = " << status << std::endl;
+       shutdown_all(PMT_F);
+       return;
+      }
+    }
+    goto unhandled;
+    
+  case ALLOCATING_CHANNEL:
+    if (pmt_eq(event, s_response_allocate_channel)){
+      status = pmt_nth(1, data);
+      d_tx_chan = pmt_nth(2, data);
+
+      if (pmt_eq(status, PMT_T)){
+       enter_transmitting();
+       return;
+      }
+      else {
+       std::cerr << "failed to allocate channel:" 
+                 << "status = " << status << std::endl;
+       shutdown_all(PMT_F);
+       return;
+      }
+    }
+    goto unhandled;
+
+  case TRANSMITTING:
+  case CLOSING_CHANNEL:
+  case CLOSING_USRP:
+  default:
+    std::cerr << "test_usrp_tx: unhandled state\n";
+    return;
+  }
+  return;
+
+ unhandled:
+  std::cout << "test_usrp_inband_tx: unhandled msg: " << msg
+           << "in state "<< d_state << std::endl;
 }
 
 
@@ -143,14 +199,31 @@
   pmt_t which_usrp = pmt_from_long(0);
 
   d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp));
+  d_state = OPENING_USRP;
 }
 
 void
 test_usrp_tx::close_usrp()
 {
   d_cs->send(s_cmd_close, pmt_list1(PMT_NIL));
+  d_state = CLOSING_USRP;
 }
 
+void
+test_usrp_tx::allocate_channel()
+{
+  long capacity = (long) 16e6;
+  d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, 
pmt_from_long(capacity)));
+  d_state = ALLOCATING_CHANNEL;
+}
+
+void
+test_usrp_tx::enter_transmitting()
+{
+  // FIXME
+}
+
+
 REGISTER_MBLOCK_CLASS(test_usrp_tx);
 
 

Modified: 
gnuradio/branches/developers/eb/ibu/usrp/host/lib/inband/usrp_server.mbh
===================================================================
--- gnuradio/branches/developers/eb/ibu/usrp/host/lib/inband/usrp_server.mbh    
2007-06-03 03:54:53 UTC (rev 5628)
+++ gnuradio/branches/developers/eb/ibu/usrp/host/lib/inband/usrp_server.mbh    
2007-06-03 04:32:21 UTC (rev 5629)
@@ -40,9 +40,8 @@
 ;; mechanism to match asynchronous responses with the commands that
 ;; generated them.
 ;;
-;; status is either #t, indicating success, or a pair containing
-;; (status-code . message), where status-code is a symbol and message
-;; is a string.
+;; status is either #t, indicating success, or a symbol indicating an error.
+;; All symbol's names shall begin with %error-
 
 
 ;; ----------------------------------------------------------------





reply via email to

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