commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5849 - in gnuradio/branches/developers/gnychis/inband


From: gnychis
Subject: [Commit-gnuradio] r5849 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband
Date: Tue, 26 Jun 2007 15:56:12 -0600 (MDT)

Author: gnychis
Date: 2007-06-26 15:56:12 -0600 (Tue, 26 Jun 2007)
New Revision: 5849

Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_cs.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.cc
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
Log:
Properly creating and sending a ping to the USRP and getting back a response


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc  
2007-06-26 21:51:12 UTC (rev 5848)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc  
2007-06-26 21:56:12 UTC (rev 5849)
@@ -53,12 +53,13 @@
   // Open the file and read the packets, dumping information
   infile.open(argv[1], std::ios::binary|std::ios::in);
   outfile.open("dump.dat",std::ios::out|std::ios::binary);  
+    
+  // read 1 packet in to the memory
+  infile.read(pkt_data, pkt_size);
 
+
   while(!infile.eof()) {
   
-    // read 1 packet in to the memory
-    infile.read(pkt_data, pkt_size);
-
     printf("Packet %u\n", pkt_num);
     printf("\tchannel: \t0x%x\n", pkt->chan());
     //printf("\ttimestamp: \t0x%x\n", pkt->timestamp());
@@ -77,6 +78,9 @@
     printf("\n\n");
 
     pkt_num++;
+  
+    // read 1 packet in to the memory
+    infile.read(pkt_data, pkt_size);
 
   }
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_cs.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_cs.cc
   2007-06-26 21:51:12 UTC (rev 5848)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_cs.cc
   2007-06-26 21:56:12 UTC (rev 5849)
@@ -334,19 +334,34 @@
   if(verbose)
     std::cout << "[TEST_USRP_INBAND_CS] Beginning transmission\n";
 
-  build_and_send_ping();
+  sleep(1);
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
+//  build_and_send_ping();
 
   build_and_send_next_frame(); // fire off 4 to start pipeline
   build_and_send_next_frame();
   build_and_send_next_frame();
   build_and_send_next_frame();
+  
+  build_and_send_ping();
 }
 
 void
 test_usrp_cs::build_and_send_ping()
 {
+  
   d_tx->send(s_cmd_to_control_channel,
              pmt_list2(PMT_NIL, pmt_list1(pmt_list3(s_op_ping_fixed, PMT_NIL, 
PMT_NIL))));
+
+  std::cout << "ping sent" << std::endl;
 }
 
 void
@@ -418,7 +433,7 @@
     enter_closing_channel();
   }
 
-  build_and_send_next_frame();
+  //build_and_send_next_frame();
 }
 
 void

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   2007-06-26 21:51:12 UTC (rev 5848)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_tx.cc
   2007-06-26 21:56:12 UTC (rev 5849)
@@ -105,8 +105,8 @@
   d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL);
   d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
   
-  bool fake_usrp_p = true;
-  //bool fake_usrp_p = false;
+  //bool fake_usrp_p = true;
+  bool fake_usrp_p = false;
 
   // Test the TX side
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-06-26 21:51:12 UTC (rev 5848)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-06-26 21:56:12 UTC (rev 5849)
@@ -104,7 +104,7 @@
     word0 |= 1<<FL_END_OF_BURST_SHIFT;
     d_word0 = host_to_usrp_u32(word0);
   }
-
+  
   void set_header(int flags, int chan, int tag, int payload_len){
     uint32_t word0 =  ((flags & FL_ALL_FLAGS)
                        | ((chan & CHAN_MASK) << CHAN_SHIFT)
@@ -185,6 +185,18 @@
 
       );
 
+    int p_len = payload_len();
+    uint32_t *payload = (uint32_t *) d_payload + p_len;
+    *payload = host_to_usrp_u32(ping);
+
+    // Update payload length
+    int h_flags = flags();
+    int h_chan = chan();
+    int h_tag = tag();
+    int h_payload_len = payload_len() + 4;  // increased by fixed ping size
+
+    set_header(h_flags, h_chan, h_tag, h_payload_len);
+
     return ping;
   }
 

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-26 21:51:12 UTC (rev 5848)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
2007-06-26 21:56:12 UTC (rev 5849)
@@ -132,6 +132,9 @@
         d_cs_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
       else
         d_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+
+      d_cs_ofile.flush();
+      d_ofile.flush();
     }
   }
 }

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 21:51:12 UTC (rev 5848)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-26 21:56:12 UTC (rev 5849)
@@ -676,28 +676,27 @@
     pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0);
     transport_pkt *pkt = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packet, psize);
     payload_len = 0;
+    
+    pkt->set_header(0, channel, 0, payload_len);
+    pkt->set_timestamp(0xffffffff);
 
+
     //--------- PING FIXED --------------//
     if(pmt_eq(subp_cmd, s_op_ping_fixed)) {
 
       long rid = 0;
       long pingval = 0;
 
-//      memcpy(pkt->payload() + payload_len,        // skip curr payload
-//             (void *) pkt->cs_ping(rid, pingval), // create data
-//             4);                                  // size of fixed ping
+      // Adds a ping after the previous command in the pkt
+      pkt->cs_ping(rid, pingval);
 
-      payload_len+=4;   // the next subpacket is created after this in payload
-
     }
-      
-    pkt->set_header(0, channel, 0, payload_len);
-    pkt->set_timestamp(0xffffffff);
 
     d_cs_usrp->send(s_cmd_usrp_write, 
                     pmt_list3(invocation_handle, 
                               pmt_from_long(channel), 
                               v_packet));
+
   }
 
   return;

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.cc 
2007-06-26 21:51:12 UTC (rev 5848)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.cc 
2007-06-26 21:56:12 UTC (rev 5849)
@@ -39,14 +39,25 @@
 static const bool verbose = false;
 
 usrp_tx::usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t 
user_arg)
-  : mb_mblock(rt, instance_name, user_arg)
+  : mb_mblock(rt, instance_name, user_arg),
+    d_disk_write(false)
 {
   d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL);
   
+  d_disk_write=true;
+  
+  if(d_disk_write) {
+    d_ofile.open("tx_data.dat",std::ios::binary|std::ios::out);
+    d_cs_ofile.open("tx_cs.dat",std::ios::binary|std::ios::out);
+  }
 }
 
 usrp_tx::~usrp_tx() 
 {
+  if(d_disk_write) {
+    d_ofile.close();
+    d_cs_ofile.close();
+  }
 }
 
 void 
@@ -103,7 +114,24 @@
     d_cs->send(s_response_usrp_tx_write,
               pmt_list3(invocation_handle, PMT_F, channel));
   }
+    
+  long n_packets = 
+    static_cast<long>(std::ceil(n_bytes / 
(double)transport_pkt::max_pkt_size()));
 
+  for(int i=0; i < n_packets; i++) {
+    
+    if(d_disk_write) {
+      if(pkts[i].chan() == 0x1f)
+        d_cs_ofile.write((const char *)&pkts[i], 
transport_pkt::max_pkt_size());
+      else
+        d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size());
+
+      d_cs_ofile.flush();
+      d_ofile.flush();
+    }
+  }
+
+
   return;
 }
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.h
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.h  
2007-06-26 21:51:12 UTC (rev 5848)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx.h  
2007-06-26 21:56:12 UTC (rev 5849)
@@ -22,6 +22,7 @@
 #define INCLUDED_USRP_TX_H
 
 #include <mb_mblock.h>
+#include <fstream>
 
 class usrp_standard_tx;
 
@@ -33,6 +34,10 @@
   mb_port_sptr         d_cs;
   usrp_standard_tx     *d_utx;
   
+  bool d_disk_write;
+  std::ofstream d_ofile;
+  std::ofstream d_cs_ofile;
+  
  public:
   usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
   ~usrp_tx();

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-26 21:51:12 UTC (rev 5848)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-26 21:56:12 UTC (rev 5849)
@@ -222,7 +222,7 @@
 
   // Open up a standard RX and TX for communication with the USRP
    
-  std::string rbf = "last.rbf";
+  std::string rbf = "last3.rbf";
   //std::string rbf = "";
 
   d_utx = usrp_standard_tx::make(which_usrp,





reply via email to

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