commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r4988 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Fri, 13 Apr 2007 12:42:06 -0600 (MDT)

Author: gnychis
Date: 2007-04-13 12:42:06 -0600 (Fri, 13 Apr 2007)
New Revision: 4988

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
removing use of USB_PKT_SIZE, and using sizeof(transport_pkt) to be technology 
independent and switch to gigabit

removing the decrease in the total number of bytes since we keep track of it 
through the for loop definition, no need to decrease

After tracing, I was initially pulling sample data for insertion into the 
payload incorrectly.
You do not skip n*sizeof(transport_pkt) bytes ahead to read the next set of 
samples, its the max size of the payload.
If you skip the size of the transport packet, some samples will be ignored and 
worse yet, you'll eventually get a memory read outside of the scope of the 
samples.



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-04-13 17:30:49 UTC (rev 4987)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-04-13 18:42:06 UTC (rev 4988)
@@ -325,8 +325,10 @@
   const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes);
   long timestamp = pmt_to_long(pmt_nth(3, data));
 
-  long n_packets = std::ceil(n_bytes / max_payload_len);   // always at least 
1 packet
-  pmt_t v_packets = pmt_make_u8vector(USB_PKT_SIZE * n_packets, 0);
+  // Determine the number of packets to allocate contiguous memory for 
bursting over the
+  // USB and get a pointer to the memory to be used in building the packets
+  long n_packets = std::ceil(n_bytes / max_payload_len);
+  pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0);
   transport_pkt *pkts = (transport_pkt *) 
pmt_u8vector_writeable_elements(v_packets, psize);
 
   for(int n=0; n < n_packets; n++) {
@@ -341,8 +343,7 @@
       pkts[n].set_timestamp(0xffffffff);
     }
 
-    memcpy(pkts[n].payload(), (uint8_t *)samples+(USB_PKT_SIZE * n), 
payload_len);
-    n_bytes -= payload_len;   // decrease the number of bytes left
+    memcpy(pkts[n].payload(), (uint8_t *)samples+(max_payload_len * n), 
payload_len);
   }
 
   pkts[n_packets-1].set_end_of_burst();   // set the last packet's end of burst





reply via email to

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