commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: gnychis
Subject: [Commit-gnuradio] r4918 - in gnuradio/branches/developers/gnychis/inband/usrp/host/lib: inband legacy
Date: Sat, 7 Apr 2007 14:31:30 -0600 (MDT)

Author: gnychis
Date: 2007-04-07 14:31:30 -0600 (Sat, 07 Apr 2007)
New Revision: 4918

Added:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/legacy/usrp_bytesex.h
Log:
Adding in functionality for parsing the usb packet

also had to add functionality for byte swapping 32 bit integers, only had 
support for shorts

need to write function for setting payload

it compiles without error



Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-04-07 18:50:47 UTC (rev 4917)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-04-07 20:31:30 UTC (rev 4918)
@@ -31,6 +31,7 @@
 
 BUILT_SOURCES =                                \
        usrp_server_mbh.cc              
+       usrp_inband_usb_packet.cc
 
 usrp_server_mbh.cc : usrp_server.mbh
        $(COMPILE_MBH) usrp_server.mbh usrp_server_mbh.cc
@@ -38,7 +39,8 @@
 
 libinband_la_SOURCES =                 \
        $(BUILT_SOURCES)                \
-       usrp_server.cc                  
+       usrp_server.cc                  \
+       usrp_inband_usb_packet.cc
 
 libinband_la_LIBADD =                  \
        $(MBLOCK_LA)                    
@@ -46,6 +48,7 @@
 
 include_HEADERS =                      \
        usrp_server.h                   
+       usrp_inband_usb_packet.h
 
 MOSTLYCLEANFILES = \
        $(BUILT_SOURCES) *~ *.pyc

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
                          (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
  2007-04-07 20:31:30 UTC (rev 4918)
@@ -0,0 +1,134 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <usrp_bytesex.h>
+#include <mb_mblock.h>
+
+static const int USB_PKT_SIZE = 512;   // bytes
+
+class usrp_inband_usb_packet {
+  //
+  // keep raw packet in USRP-endian order
+  //
+  uint32_t           d_word0;
+  uint32_t           d_timestamp;
+  unsigned char          d_payload[USB_PKT_SIZE-2*sizeof(uint32_t)];
+
+public:
+
+  enum flags {
+    FL_OVERRUN        = 0x80000000,
+    FL_UNDERRUN       = 0x40000000,
+    FL_DROPPED        = 0x20000000,
+    FL_END_OF_BURST   = 0x10000000,
+    FL_START_OF_BURST = 0x08000000,
+
+    FL_ALL_FLAGS      = 0xf8000000
+  };
+
+  static const int FL_OVERRUN_SHIFT = 31;
+  static const int FL_UNDERRUN_SHIFT = 30;
+  static const int FL_DROPPED_SHIFT = 29;
+  static const int FL_END_OF_BURST_SHIFT = 28;
+  static const int FL_START_OF_BURST_SHIFT = 27;
+  
+  static const int RSSI_MASK = 0x3f;
+  static const int RSSI_SHIFT = 21;
+
+  static const int CHAN_MASK = 0x1f;
+  static const int CHAN_SHIFT = 16;
+
+  static const int TAG_MASK = 0xf;
+  static const int TAG_SHIFT = 9;
+
+  static const int PAYLOAD_LEN_MASK = 0x1ff;
+  static const int PAYLOAD_LEN_SHIFT = 0;
+
+public:
+  
+  void set_timestamp(uint32_t timestamp){
+    d_timestamp = host_to_usrp_u32(timestamp);
+  }
+
+  void set_header(int flags, int chan, int tag, int payload_len){
+    uint32_t word0 =  ((flags & FL_ALL_FLAGS)
+                       | ((chan & CHAN_MASK) << CHAN_SHIFT)
+                       | ((tag & TAG_MASK) << TAG_SHIFT)
+                       | ((payload_len & PAYLOAD_LEN_MASK) << 
PAYLOAD_LEN_SHIFT));
+    d_word0 = host_to_usrp_u32(word0);
+  }
+  
+  uint32_t timestamp() const {
+    return usrp_to_host_u32(d_timestamp);
+  }
+
+  int rssi() const {
+    uint32_t word0 = usrp_to_host_u32(d_word0);
+    return (word0 >> RSSI_SHIFT) & RSSI_MASK;
+  }
+
+  int chan() const {
+    uint32_t word0 = usrp_to_host_u32(d_word0);
+    return (word0 >> CHAN_SHIFT) & CHAN_MASK;
+  }
+
+  int tag() const {
+    uint32_t word0 = usrp_to_host_u32(d_word0);
+    return (word0 >> TAG_SHIFT) & TAG_MASK;
+  }
+
+  int payload_len() const {
+    uint32_t word0 = usrp_to_host_u32(d_word0);
+    return (word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK;
+  }
+  
+  int flags() const {
+    return usrp_to_host_u32(d_word0) & FL_ALL_FLAGS;
+  }
+
+  int overrun() const {
+    return (usrp_to_host_u32(d_word0) & FL_OVERRUN) >> FL_OVERRUN_SHIFT;
+  }
+  
+
+  int underrun() const {
+    return (usrp_to_host_u32(d_word0) & FL_UNDERRUN) >> FL_UNDERRUN_SHIFT;
+  }
+
+
+  int start_of_burst() const {
+    return (usrp_to_host_u32(d_word0) & FL_START_OF_BURST) >> 
FL_START_OF_BURST_SHIFT;
+  }
+
+  int end_of_burst() const {
+    return (usrp_to_host_u32(d_word0) & FL_END_OF_BURST) >> 
FL_END_OF_BURST_SHIFT;
+  }
+
+  int dropped() const {
+    return (usrp_to_host_u32(d_word0) & FL_DROPPED) >> FL_DROPPED_SHIFT;
+  }
+
+  unsigned char *payload() { 
+    return d_payload; 
+  }
+
+  // need to set payload
+
+};

Added: 
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
                           (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-04-07 20:31:30 UTC (rev 4918)
@@ -0,0 +1,21 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/legacy/usrp_bytesex.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/legacy/usrp_bytesex.h 
    2007-04-07 18:50:47 UTC (rev 4917)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/legacy/usrp_bytesex.h 
    2007-04-07 20:31:30 UTC (rev 4918)
@@ -38,11 +38,30 @@
 {
   return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
 }
+
+static inline unsigned int
+bswap32 (unsigned int x)
+{
+  return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) \
+        | (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24));
+}
 #endif
 
 
 #ifdef WORDS_BIGENDIAN
 
+static inline unsigned int
+host_to_usrp_u32 (unsigned int x)
+{
+  return bswap_32(x);
+}
+
+static inline unsigned int
+usrp_to_host_u32 (unsigned int x)
+{
+  return bswap_32(x);
+}
+
 static inline short int
 host_to_usrp_short (short int x)
 {
@@ -57,6 +76,18 @@
 
 #else
 
+static inline unsigned int
+host_to_usrp_u32 (unsigned int x)
+{
+  return x;
+}
+
+static inline unsigned int
+usrp_to_host_u32 (unsigned int x)
+{
+  return x;
+}
+
 static inline short int
 host_to_usrp_short (short int x)
 {





reply via email to

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