commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r5829 - in gnuradio/branches/developers/gnychis/inband/usrp/host: apps lib/inband
Date: Mon, 25 Jun 2007 12:58:44 -0600 (MDT)

Author: gnychis
Date: 2007-06-25 12:58:43 -0600 (Mon, 25 Jun 2007)
New Revision: 5829

Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/apps/Makefile.am
   gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.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_rx.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
Log:
Intermediate checkin which includes changes to the read_packets application to 
specify which data file to read

usrp_rx now dumps data and CS packets to different files if the disk write flag 
is set

all other changes belong to the beginning of the CS handling code


Modified: gnuradio/branches/developers/gnychis/inband/usrp/host/apps/Makefile.am
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/apps/Makefile.am      
2007-06-25 18:36:26 UTC (rev 5828)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/apps/Makefile.am      
2007-06-25 18:58:43 UTC (rev 5829)
@@ -32,8 +32,8 @@
 
 noinst_PROGRAMS =                      \
        check_order_quickly             \
+       test_usrp_inband_rx             \
        test_usrp_inband_tx             \
-       test_usrp_inband_rx             \
        test_usrp_standard_rx           \
        test_usrp_standard_tx           \
        read_packets

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-25 18:36:26 UTC (rev 5828)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/apps/read_packets.cc  
2007-06-25 18:58:43 UTC (rev 5829)
@@ -32,10 +32,16 @@
 
 typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
 
-int main() {
+int main(int argc, char *argv[]) {
 
+  if(argc !=2) {
+    std::cout << "Usage: ./read_packets <data_file>\n";
+    return -1;
+  }
+
   std::ifstream infile;
-  
+  std::ofstream outfile;  
+
   unsigned int pkt_size = transport_pkt::max_pkt_size();
   unsigned int pkt_num=0;
 
@@ -43,10 +49,10 @@
   char pkt_data[pkt_size];          // allocate the number of bytes for a 
single packet
 
   pkt = (transport_pkt *)pkt_data;  // makes operations cleaner to read
-  
 
   // Open the file and read the packets, dumping information
-  infile.open("rx_raw.dat",std::ios::binary|std::ios::in);
+  infile.open(argv[1], std::ios::binary|std::ios::in);
+  outfile.open("dump.dat",std::ios::out|std::ios::binary);  
 
   while(!infile.eof()) {
   
@@ -55,19 +61,26 @@
 
     printf("Packet %u\n", pkt_num);
     printf("\tchannel: \t0x%x\n", pkt->chan());
-    printf("\ttimestamp: \t0x%x\n", pkt->timestamp());
+    //printf("\ttimestamp: \t0x%x\n", pkt->timestamp());
+    printf("\ttimestamp: \t%u\n", pkt->timestamp());
     printf("\tlength: \t%u\n", pkt->payload_len());
 
     printf("\tpayload: \n");
     for(int i=0; i < pkt->payload_len(); i++)
     //for(int i=0; i < pkt->max_payload(); i++)
+    {
       printf("\t%d\t0x%x\n", i, *(pkt->payload()+i));
+      outfile.write((const char*)(pkt->payload()+i),1);
       //printf("\t\t0x%x\n", pkt->payload()+i);
 
+    }
     printf("\n\n");
 
     pkt_num++;
 
   }
 
+  infile.close();
+  outfile.close();
+
 }

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
   2007-06-25 18:36:26 UTC (rev 5828)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/apps/test_usrp_inband_rx.cc
   2007-06-25 18:58:43 UTC (rev 5829)
@@ -112,10 +112,10 @@
   d_rx = define_port("rx0", "usrp-rx", 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;
   
-  //d_disk_write = true;
+  d_disk_write = true;
 
   // 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-25 18:36:26 UTC (rev 5828)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-06-25 18:58:43 UTC (rev 5829)
@@ -38,6 +38,22 @@
 
 public:
 
+  enum opcodes {
+    OP_PING_FIXED         = 0x00,
+    OP_PING_FIXED_REPLY   = 0x01,
+    OP_WRITE_REG          = 0x02,
+    OP_WRITE_REG_MASKED   = 0x03,
+    OP_READ_REG           = 0x04,
+    OP_READ_REG_REPLY     = 0x05,
+    OP_I2C_WRITE          = 0x06,
+    OP_I2C_READ           = 0x07,
+    OP_I2C_READ_REPLY     = 0x08,
+    OP_SPI_WRITE          = 0x09,
+    OP_SPI_READ           = 0x0a,
+    OP_SPI_READ_REPLY     = 0x0b,
+    OP_DELAY              = 0x0c
+  };
+
   enum flags {
     FL_OVERRUN        = 0x80000000,
     FL_UNDERRUN       = 0x40000000,

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-25 18:36:26 UTC (rev 5828)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.cc 
2007-06-25 18:58:43 UTC (rev 5829)
@@ -47,17 +47,21 @@
 {
   d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL);
   
-  //d_disk_write=true;
+  d_disk_write=true;
   
-  if(d_disk_write)
-    d_ofile.open("rx_raw.dat",std::ios::binary|std::ios::out);
+  if(d_disk_write) {
+    d_ofile.open("rx_data.dat",std::ios::binary|std::ios::out);
+    d_cs_ofile.open("rx_cs.dat",std::ios::binary|std::ios::out);
+  }
 
 }
 
 usrp_rx::~usrp_rx() 
 {
-  if(d_disk_write)
+  if(d_disk_write) {
     d_ofile.close();
+    d_cs_ofile.close();
+  }
 }
 
 void 
@@ -124,8 +128,12 @@
     if(verbose)
       std::cout << "[usrp_rx] Read 1 packet\n";
     
-    if(d_disk_write)
-      d_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+    if(d_disk_write) {
+      if(pkt->chan() == 0x1f)
+        d_cs_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+      else
+        d_ofile.write((const char *)pkt, transport_pkt::max_pkt_size());
+    }
   }
 }
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h
===================================================================
--- gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h  
2007-06-25 18:36:26 UTC (rev 5828)
+++ gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx.h  
2007-06-25 18:58:43 UTC (rev 5829)
@@ -36,6 +36,7 @@
   
   bool d_disk_write;
   std::ofstream d_ofile;
+  std::ofstream d_cs_ofile;
   
  public:
   usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);

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-25 18:36:26 UTC (rev 5828)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-06-25 18:58:43 UTC (rev 5829)
@@ -270,7 +270,7 @@
     d_defer_queue.push(msg);
     return;
   }
-
+  
   //--------- CONTROL / STATUS ------------//
   if (pmt_eq(port_id, d_cs->port_symbol())){
     
@@ -413,7 +413,21 @@
       handle_cmd_xmit_raw_frame(d_tx[port], d_chaninfo_tx, data);
       return;
     }
+    
+    //-------------- CONTROL PACKET -----------------/
+    if (pmt_eq(event, s_cmd_to_control_channel)) {
+      
+      if(!d_opened) { 
+        d_tx[port]->send(s_response_xmit_raw_frame, 
+                         pmt_list2(invocation_handle, PMT_F));
+        return;
+      }
+      
+      handle_cmd_to_control_channel(d_tx[port], d_chaninfo_tx, data);
+      return;
 
+    }
+
     goto unhandled;
   }
 
@@ -665,6 +679,12 @@
   return;
 }
 
+void usrp_server::handle_cmd_to_control_channel(mb_port_sptr port, 
std::vector<struct channel_info> &chan_info, pmt_t data) 
+{
+
+  return;
+}
+
 void
 usrp_server::handle_cmd_start_recv_raw_samples(mb_port_sptr port, 
std::vector<struct channel_info> &chan_info, pmt_t data)
 {
@@ -779,6 +799,12 @@
   long payload_len = pkt->payload_len();
   long port;
 
+  // If the packet is a C/S packet, parse it separately
+  if(channel == 0x1f) {
+    parse_control_pkt(pkt);
+    return;
+  }
+
   // Ignore packets which seem to have incorrect size or size 0
   if(payload_len > pkt->max_payload() || payload_len == 0)
     return;
@@ -801,6 +827,15 @@
 }
 
 void
+usrp_server::parse_control_pkt(transport_pkt *pkt)
+{
+
+  long payload_len = pkt->payload_len();
+  long port;
+
+}
+
+void
 usrp_server::recall_defer_queue()
 {
 

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-06-25 18:36:26 UTC (rev 5828)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h  
    2007-06-25 18:58:43 UTC (rev 5829)
@@ -25,7 +25,10 @@
 #include <vector>
 #include <queue>
 #include <fstream>
+#include <usrp_inband_usb_packet.h>
 
+typedef usrp_inband_usb_packet transport_pkt;   // makes conversion to gigabit 
easy
+
 /*!
  * \brief Implements the lowest-level mblock usb_interface to the USRP
  */
@@ -92,6 +95,7 @@
   void handle_cmd_allocate_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
+  void handle_cmd_to_control_channel(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct 
channel_info> &chan_info, pmt_t data);
   int rx_port_index(pmt_t port_id);
@@ -101,6 +105,7 @@
   void reset_channels();
   void handle_response_usrp_read(pmt_t data);
   bool check_valid(mb_port_sptr port, long channel, std::vector<struct 
channel_info> &chan_info, pmt_t signal_info);
+  void parse_control_pkt(transport_pkt *pkt);
 };
 
 #endif /* INCLUDED_USRP_SERVER_H */

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-25 18:36:26 UTC (rev 5828)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
      2007-06-25 18:58:43 UTC (rev 5829)
@@ -238,7 +238,7 @@
 
   // Open up a standard RX and TX for communication with the USRP
    
-  std::string rbf = "sad.rbf";
+  std::string rbf = "cmd6.rbf";
   //std::string rbf = "";
 
   d_utx = usrp_standard_tx::make(which_usrp,





reply via email to

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