commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7539 - in usrp2/trunk: firmware/apps firmware/include


From: eb
Subject: [Commit-gnuradio] r7539 - in usrp2/trunk: firmware/apps firmware/include host/apps
Date: Fri, 1 Feb 2008 12:45:28 -0700 (MST)

Author: eb
Date: 2008-02-01 12:45:27 -0700 (Fri, 01 Feb 2008)
New Revision: 7539

Modified:
   usrp2/trunk/firmware/apps/app_common.c
   usrp2/trunk/firmware/apps/rx_only.c
   usrp2/trunk/firmware/include/usrp2_eth_packet.h
   usrp2/trunk/host/apps/rx_samples.cc
Log:
Firmware modified to generate seqno's in Rx direction data.
host code, rx_samples, now checks them.


Modified: usrp2/trunk/firmware/apps/app_common.c
===================================================================
--- usrp2/trunk/firmware/apps/app_common.c      2008-02-01 17:53:20 UTC (rev 
7538)
+++ usrp2/trunk/firmware/apps/app_common.c      2008-02-01 19:45:27 UTC (rev 
7539)
@@ -55,7 +55,6 @@
   unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)] _AL4;
   unsigned char *s = &reply[sizeof(u2_eth_packet_t)];
   size_t reply_len = 0;
-  int   i;
 
   // point to beginning of payload (subpackets)
   unsigned char *p = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
@@ -78,9 +77,6 @@
       r->rid_mbz = 0;          // FIXME
       r->addr = *ethernet_mac_addr();
       r->hw_rev = 0x0000;      // FIXME
-      for (i = 0; i < sizeof(r->serial_no); i++)
-       r->serial_no[i] = '0';  // FIXME
-
       // r->fpga_md5sum = ;    // FIXME
       // r->sw_md5sum = ;      // FIXME
     }

Modified: usrp2/trunk/firmware/apps/rx_only.c
===================================================================
--- usrp2/trunk/firmware/apps/rx_only.c 2008-02-01 17:53:20 UTC (rev 7538)
+++ usrp2/trunk/firmware/apps/rx_only.c 2008-02-01 19:45:27 UTC (rev 7539)
@@ -37,6 +37,14 @@
 #include <string.h>
 
 
+#define FW_SETS_SEQNO  1       // define to 0 or 1
+
+#if (FW_SETS_SEQNO)
+static int fw_seqno;   // used when f/w is filling in sequence numbers
+#endif
+
+
+
 static int timer_delta = MASTER_CLK_RATE/1000; // tick at 1kHz
 
 /*
@@ -130,6 +138,9 @@
   memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
 
 
+  if (FW_SETS_SEQNO)
+    fw_seqno = 0;
+
   // setup RX DSP regs
   dsp_rx_regs->clear_state = 1;                        // reset
 
@@ -177,6 +188,31 @@
   }
 }
 
+#if (FW_SETS_SEQNO)
+/*
+ * Debugging ONLY.  This will be handled by the tx_protocol_engine.
+ *
+ * This is called when the DSP Rx chain has filled in a packet.
+ * We set and increment the seqno, then return false, indicating
+ * that we didn't handle the packet.  A bit of a kludge
+ * but it should work.
+ */
+bool 
+fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
+{
+  uint32_t *p = buffer_ram(buf_this);
+  uint32_t seqno = fw_seqno++;
+
+  // KLUDGE all kinds of nasty magic numbers and embedded knowledge
+  uint32_t t = p[4];
+  t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
+  p[4] = t;
+
+  return false;                // we didn't handle the packet
+}
+#endif
+
+
 int
 main(void)
 {
@@ -202,9 +238,16 @@
   ethernet_init();
 
   // initialize double buffering state machine for DSP RX -> Ethernet
-  dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
-           &dsp_rx_recv_args, &dsp_rx_send_args,
-           dbsm_nop_inspector);
+  if (FW_SETS_SEQNO){
+    dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
+             &dsp_rx_recv_args, &dsp_rx_send_args,
+             fw_sets_seqno_inspector);
+  }
+  else {
+    dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
+             &dsp_rx_recv_args, &dsp_rx_send_args,
+             dbsm_nop_inspector);
+  }
 
 
   // setup receive from ETH

Modified: usrp2/trunk/firmware/include/usrp2_eth_packet.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-02-01 17:53:20 UTC 
(rev 7538)
+++ usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-02-01 19:45:27 UTC 
(rev 7539)
@@ -182,7 +182,6 @@
   uint16_t     rid_mbz;
   u2_mac_addr_t        addr;
   uint16_t     hw_rev;
-  uint8_t      serial_no[8];
   uint8_t      fpga_md5sum[16];
   uint8_t      sw_md5sum[16];
 } op_id_reply_t;

Modified: usrp2/trunk/host/apps/rx_samples.cc
===================================================================
--- usrp2/trunk/host/apps/rx_samples.cc 2008-02-01 17:53:20 UTC (rev 7538)
+++ usrp2/trunk/host/apps/rx_samples.cc 2008-02-01 19:45:27 UTC (rev 7539)
@@ -100,11 +100,14 @@
 }
 
 struct pkt_info {
-  int  d_nsamples;
-  int  d_timestamp;
+  int          d_nsamples;
+  int          d_timestamp;
+  unsigned int d_seqno;
 
-  pkt_info(int nsamples, int timestamp)
-    : d_nsamples(nsamples), d_timestamp(timestamp) {}
+  pkt_info(int nsamples, int timestamp, int seqno)
+    : d_nsamples(nsamples),
+      d_timestamp(timestamp),
+      d_seqno(seqno) {}
 };
 
 int
@@ -257,7 +260,7 @@
     
     total_samples_recvd += n;
 
-    history.push_back(pkt_info(n, u2p_timestamp(&pkt.hdrs.fixed)));
+    history.push_back(pkt_info(n, u2p_timestamp(&pkt.hdrs.fixed), 
pkt.hdrs.thdr.seqno));
 
     // convert_samples_to_complex(n, pkt.samples, c_samples);
     // size_t r = fwrite(c_samples, sizeof(fcomplex), n, of);
@@ -287,15 +290,31 @@
   long total_pkts_recvd = 0;
   total_samples_recvd = 0;
 
+  int nbad_seqno = 0;
+
   for (unsigned i = 0; i < history.size(); i++){
     total_pkts_recvd++;
     total_samples_recvd += history[i].d_nsamples;
-    printf("%3d  %8d  %8ld  %8ld\n",
+
+    bool bad_seqno = history[i].d_seqno != (i & 0xff);
+    if (bad_seqno)
+      nbad_seqno++;
+    
+    printf("%3d  %8d  %8ld  %8ld  %3d %s\n",
           history[i].d_nsamples,
           history[i].d_timestamp,
-          total_pkts_recvd, total_samples_recvd);
+          total_pkts_recvd, total_samples_recvd,
+          history[i].d_seqno,
+          bad_seqno ? "BAD SEQNO" : ""
+          );
   }
 
+  if (nbad_seqno == 0)
+    printf("\nAll sequence numbers are correct\n");
+  else
+    printf("\n%d sequence numbers were INCORRECT\n", nbad_seqno);
+    
+
   printf("\nUser space statistics:\n");
   printf("  rx_samples:  %8ld",     total_samples_recvd);
   printf("   expected  %8d  %s\n",





reply via email to

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