commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r4996 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Fri, 13 Apr 2007 14:02:47 -0600 (MDT)

Author: gnychis
Date: 2007-04-13 14:02:46 -0600 (Fri, 13 Apr 2007)
New Revision: 4996

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_server.cc
Log:
fixing the number of packets computation by casting to a double

Create a max_payload() method for our USB packet class and created another 
static variable which is MAX_PAYLOAD used for initializing payload[] and to 
return in the static method.

I could not have max_payload() be static and return the size of a non-static 
method, therefore I could have it return sizeof(d_payload).  This was my 
solution.



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-04-13 19:57:44 UTC (rev 4995)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-04-13 20:02:46 UTC (rev 4996)
@@ -26,6 +26,7 @@
 #include <mb_mblock.h>
 
 static const int USB_PKT_SIZE = 512;   // bytes
+static const int MAX_PAYLOAD = USB_PKT_SIZE-2*sizeof(uint32_t);
 
 class usrp_inband_usb_packet {
   //
@@ -33,7 +34,7 @@
   //
   uint32_t           d_word0;
   uint32_t           d_timestamp;
-  unsigned char          d_payload[USB_PKT_SIZE-2*sizeof(uint32_t)];
+  unsigned char          d_payload[MAX_PAYLOAD];
 
 public:
 
@@ -139,6 +140,10 @@
     return d_payload; 
   }
 
+  static int max_payload() {
+    return MAX_PAYLOAD;
+  }
+
 };
 
 #endif

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 19:57:44 UTC (rev 4995)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-04-13 20:02:46 UTC (rev 4996)
@@ -318,8 +318,8 @@
 void usrp_server::handle_cmd_xmit_raw_frame(pmt_t data) {
 
   size_t n_bytes, psize;
-  long max_payload_len = USB_PKT_SIZE-2*sizeof(uint32_t);   // we can't do 
sizeof(pkts->payload()) because it would
-                                                            // be 
sizeof(unsigned char *), other ideas?
+  long max_payload_len = transport_pkt::max_payload();
+
   pmt_t invocation_handle = pmt_nth(0, data);
   long channel = pmt_to_long(pmt_nth(1, data));
   const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes);
@@ -327,7 +327,7 @@
 
   // 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);
+  long n_packets = std::ceil(n_bytes / (double)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);
 





reply via email to

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