Reading 64 bit freq out of chunk of context packet.
authorJosh Blum <josh@joshknows.com>
Fri, 25 Sep 2009 22:57:20 +0000 (15:57 -0700)
committerJosh Blum <josh@joshknows.com>
Fri, 25 Sep 2009 22:57:20 +0000 (15:57 -0700)
Where is the rest of my context packet?
Added htonll and ntohll in gruel inet.h
Fixed vrt/types.h freq cast

gr-vrt/src/vrt_source_32fc.cc
gruel/src/include/gruel/inet.h.in
vrt/include/vrt/types.h

index 6c3035b8f17643e1d2bd784e4a636fc5b52fc08c..483b6c246362098a9a2cc998a83c5252e49f90fc 100644 (file)
@@ -27,6 +27,8 @@
 #include <vrt_source_32fc.h>
 #include <vrt/expanded_header.h>
 #include <vrt/copiers.h>
+#include <vrt/types.h>
+#include <vrt/if_context.h>
 #include <gr_io_signature.h>
 #include <missing_pkt_checker.h>
 #include <iostream>
@@ -96,10 +98,17 @@ rx_32fc_handler::operator()(const uint32_t *payload,
     return true;                       // Keep calling us, we've got more room
   }
   else if (hdr->if_context_p()){
-    // FIXME print the IF-Context packet
+    // print the IF-Context packet
     fprintf(stderr, "\nIF-Context:\n");
     for (size_t i = 0; i < n32_bit_words; i++)
       fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i]));
+    // copy the context into struct so we cant reference bad memory
+    // print the components of the struct, prove that it works!
+    all_context_t if_context;
+    memcpy(((uint32_t*)&if_context) + 5, payload, sizeof(uint32_t)*n32_bit_words);//FIXME
+    fprintf(stderr, "\nIF-Context-Components:\n");
+    if_context.beamformer.rf_ref_freq = ntohll(if_context.beamformer.rf_ref_freq);
+    fprintf(stderr, "Ref Freq %f Hz\n", vrt_freq_to_double(if_context.beamformer.rf_ref_freq));
     return true;
   }
   else {
index a98d83e9c57962b02aa78a3dab10eecea725ebaa..3202707270df3e22bc765fda1b743cd6f168b3da 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008, 2009 Free Software Foundation, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #ifndef INCLUDED_INET_H
 #define INCLUDED_INET_H
 
+#if 1 /* missing htonll or ntohll */
+#if @GR_ARCH_BIGENDIAN@  /* GR_ARCH_BIGENDIAN */
+// Nothing to do...
+static inline uint64_t htonll(uint64_t x){ return x;}
+static inline uint64_t ntohll(uint64_t x){ return x;}
+#else
+#if @GR_HAVE_BYTESWAP@  /* GR_HAVE_BYTESWAP */
+#include <byteswap.h>
+#else
+
+static inline uint64_t
+bswap_64(uint64_t x)
+{
+  return ((x & 0x00000000000000ffull) << 56) | ((x & 0x000000000000ff00ull) << 40) |
+         ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x00000000ff000000ull) <<  8) |
+         ((x & 0x000000ff00000000ull) >>  8) | ((x & 0x0000ff0000000000ull) >> 24) |
+         ((x & 0x00ff000000000000ull) >> 40) | ((x & 0xff00000000000000ull) >> 56);
+}
+
+#endif /* GR_HAVE_BYTESWAP */
+
+static inline uint64_t htonll(uint64_t x){ return bswap_64(x);}
+static inline uint64_t ntohll(uint64_t x){ return bswap_64(x);}
+
+#endif /* GR_ARCH_BIGENDIAN */
+#endif /* missing htonll or ntohll */ 
+
 #if @GR_HAVE_ARPA_INET@  /* GR_HAVE_ARPA_INET */
 #include <arpa/inet.h>
 #elif @GR_HAVE_NETINET_IN@  /* GR_HAVE_NETINET_IN */
@@ -61,8 +88,10 @@ static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); }
 static inline uint8_t  ntohx(uint8_t  x){ return x;        }
 static inline uint16_t ntohx(uint16_t x){ return ntohs(x); }
 static inline uint32_t ntohx(uint32_t x){ return ntohl(x); }
+static inline uint64_t ntohx(uint64_t x){ return ntohll(x);}
 static inline uint8_t  htonx(uint8_t  x){ return x;        }
 static inline uint16_t htonx(uint16_t x){ return htons(x); }
 static inline uint32_t htonx(uint32_t x){ return htonl(x); }
+static inline uint64_t htonx(uint64_t x){ return htonll(x);}
 
 #endif /* INCLUDED_INET_H */
index 2081702c5cf52ff5263c5906c4cfd516879427f0..edfa4ec37b0c71f1458bf1cd23c8bb93e57357b9 100644 (file)
@@ -74,7 +74,7 @@ vrt_geo_angle_to_double(vrt_geo_angle_t fx){
  **********************************************************************/
 typedef int64_t vrt_freq_t;
 #define VRT_FREQ_RP 20
-#define VRT_FREQ_C(_x) _FXPT_C(vrt_altitude_t, _x, VRT_FREQ_RP)
+#define VRT_FREQ_C(_x) _FXPT_C(vrt_freq_t, _x, VRT_FREQ_RP)
 
 static inline vrt_freq_t
 double_to_vrt_freq(double num){