summaryrefslogtreecommitdiff
path: root/gr-vrt/src
diff options
context:
space:
mode:
authorJohnathan Corgan2009-10-21 14:20:15 -0700
committerJohnathan Corgan2009-10-21 14:20:15 -0700
commit8e003a402af2993f978620741fdf195ac9bf7834 (patch)
tree17bc885b8e32b3b29f78d9ae0817c88c581d87f2 /gr-vrt/src
parent3f60c94858810b605c2f8a343375c57c78a660dc (diff)
parent2875cf23fcb5d38866a42327cafa2b43abe2fbf4 (diff)
downloadgnuradio-8e003a402af2993f978620741fdf195ac9bf7834.tar.gz
gnuradio-8e003a402af2993f978620741fdf195ac9bf7834.tar.bz2
gnuradio-8e003a402af2993f978620741fdf195ac9bf7834.zip
Merge branch 'vrt' of http://gnuradio.org/git/jblum
Merge fix: added GRUEL_INCLUDES to vrt Makefile Merge fix: added missing include in gr-vrt * 'vrt' of http://gnuradio.org/git/jblum: query the model number from the host fix so all handlers get called on event simplfied the code while i was looking at it added access methods for gps stuff added access methods and parsing for caldiv if context use existing utility method reading the lo back and storing it use the new htonll and vrt types to send cal and lo freqs checking for if context packets and setting up the payload pointer and size Reading 64 bit freq out of chunk of context packet. copied over vrt context and type headers, updated bits.h as well Dump IF-Context packets in hex. use gruel/inet.h instead of arap/inet.h fix white space made rxdspno a parameter for: start/stop streaming, and quadradio32fc
Diffstat (limited to 'gr-vrt/src')
-rw-r--r--gr-vrt/src/vrt_quadradio_source_32fc.cc20
-rw-r--r--gr-vrt/src/vrt_quadradio_source_32fc.h25
-rw-r--r--gr-vrt/src/vrt_source_32fc.cc94
-rw-r--r--gr-vrt/src/vrt_source_32fc.h18
4 files changed, 122 insertions, 35 deletions
diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.cc b/gr-vrt/src/vrt_quadradio_source_32fc.cc
index 0aac86991..cd779bdf5 100644
--- a/gr-vrt/src/vrt_quadradio_source_32fc.cc
+++ b/gr-vrt/src/vrt_quadradio_source_32fc.cc
@@ -29,25 +29,29 @@
vrt_quadradio_source_32fc_sptr
vrt_make_quadradio_source_32fc(const std::string &ip,
size_t rx_bufsize,
- size_t samples_per_pkt)
+ size_t samples_per_pkt,
+ int rxdspno)
{
return gnuradio::get_initial_sptr(new vrt_quadradio_source_32fc(ip,
rx_bufsize,
- samples_per_pkt));
+ samples_per_pkt,
+ rxdspno));
}
vrt_quadradio_source_32fc::vrt_quadradio_source_32fc(const std::string &ip,
size_t rx_bufsize,
- size_t samples_per_pkt)
+ size_t samples_per_pkt,
+ int rxdspno)
: vrt_source_32fc("quadradio_source_32fc"),
- d_samples_per_pkt(samples_per_pkt == 0 ? 800 : samples_per_pkt),
- d_qr(vrt::quadradio::sptr(new vrt::quadradio(ip, rx_bufsize)))
+ d_samples_per_pkt(samples_per_pkt == 0 ? (rxdspno == 0 ? 800 : 200) : samples_per_pkt),
+ d_qr(vrt::quadradio::sptr(new vrt::quadradio(ip, rx_bufsize))),
+ d_rxdspno(rxdspno)
{
}
vrt_quadradio_source_32fc::~vrt_quadradio_source_32fc()
{
- d_qr->stop_streaming();
+ d_qr->stop_streaming(d_rxdspno);
}
vrt::rx::sptr
@@ -64,13 +68,13 @@ vrt_quadradio_source_32fc::start()
vrt_rx()->rx_packets(&nop, true);
d_checker.resync();
- return d_qr->start_streaming(d_samples_per_pkt);
+ return d_qr->start_streaming(d_rxdspno, d_samples_per_pkt);
}
bool
vrt_quadradio_source_32fc::stop()
{
- return d_qr->stop_streaming();
+ return d_qr->stop_streaming(d_rxdspno);
}
bool
diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.h b/gr-vrt/src/vrt_quadradio_source_32fc.h
index 6193efa10..bb3935c46 100644
--- a/gr-vrt/src/vrt_quadradio_source_32fc.h
+++ b/gr-vrt/src/vrt_quadradio_source_32fc.h
@@ -33,19 +33,21 @@ typedef boost::shared_ptr<vrt_quadradio_source_32fc> vrt_quadradio_source_32fc_s
vrt_quadradio_source_32fc_sptr
vrt_make_quadradio_source_32fc(const std::string &ip,
size_t rx_bufsize = 0,
- size_t samples_per_pkt = 0);
+ size_t samples_per_pkt = 0,
+ int rxdspno = 0);
class vrt_quadradio_source_32fc : public vrt_source_32fc
{
size_t d_samples_per_pkt;
boost::shared_ptr<vrt::quadradio> d_qr;
+ int d_rxdspno;
vrt_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize,
- size_t samples_per_pkt);
+ size_t samples_per_pkt, int rxdspno);
friend vrt_quadradio_source_32fc_sptr
vrt_make_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize,
- size_t samples_per_pkt);
+ size_t samples_per_pkt, int rxdspno);
public:
virtual ~vrt_quadradio_source_32fc();
@@ -110,6 +112,23 @@ public:
bool set_cal_freq(double freq);
bool set_beamforming(std::vector<gr_complex> gains);
bool set_cal_enb(bool enb);
+
+ //caldiv public access methods
+ double get_cal_freq(void){return d_cal_freq;}
+ bool get_cal_locked(void){return d_cal_locked;}
+ bool get_cal_enabled(void){return d_cal_enabled;}
+ double get_lo_freq(void){return d_lo_freq;}
+ bool get_lo_locked(void){return d_lo_locked;}
+ double get_caldiv_temp(void){return d_caldiv_temp;}
+ int get_caldiv_revision(void){return d_caldiv_rev;}
+ int get_caldiv_serial(void){return d_caldiv_ser;}
+ int get_caldiv_model(void){return d_caldiv_mod;}
+
+ //gps public access methods
+ int get_utc_time(void){return d_utc_time;}
+ double get_altitude(void){return d_altitude;}
+ double get_longitude(void){return d_longitude;}
+ double get_latitude(void){return d_latitude;}
};
diff --git a/gr-vrt/src/vrt_source_32fc.cc b/gr-vrt/src/vrt_source_32fc.cc
index beb5ef26d..f9375d31c 100644
--- a/gr-vrt/src/vrt_source_32fc.cc
+++ b/gr-vrt/src/vrt_source_32fc.cc
@@ -27,9 +27,14 @@
#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>
+#include <gruel/inet.h>
+#include <cstdio>
+#include <cstring>
#define VERBOSE 1 // define to 0 or 1
@@ -41,7 +46,8 @@ class rx_32fc_handler : public vrt::rx_packet_handler
int *d_oo; // output index
std::vector< std::complex<float> > &d_remainder;
missing_pkt_checker &d_checker;
-
+ all_context_t d_if_context;
+ size_t d_if_context_n32_bit_words;
public:
@@ -49,13 +55,16 @@ public:
int *oo, std::vector< std::complex<float> > &remainder,
missing_pkt_checker &checker)
: d_noutput_items(noutput_items), d_out(out),
- d_oo(oo), d_remainder(remainder), d_checker(checker) {}
+ d_oo(oo), d_remainder(remainder), d_checker(checker),
+ d_if_context_n32_bit_words(0) {}
~rx_32fc_handler();
bool operator()(const uint32_t *payload,
size_t n32_bit_words,
const vrt::expanded_header *hdr);
+ all_context_t* get_if_context(void){
+ return d_if_context_n32_bit_words? &d_if_context : NULL;};
};
rx_32fc_handler::~rx_32fc_handler()
@@ -67,29 +76,48 @@ rx_32fc_handler::operator()(const uint32_t *payload,
size_t n32_bit_words,
const vrt::expanded_header *hdr)
{
- int nmissing = d_checker.check(hdr);
- if (VERBOSE && nmissing != 0){
- std::cerr << "S" << nmissing;
+ if (hdr->if_data_p()){
+ int nmissing = d_checker.check(hdr);
+ if (VERBOSE && nmissing != 0){
+ std::cerr << "S" << nmissing;
+ }
+
+ // copy as many as will fit into the output buffer.
+
+ size_t n = std::min(n32_bit_words, (size_t)(d_noutput_items - *d_oo));
+ vrt::copy_net_16sc_to_host_32fc(n, payload, &d_out[*d_oo]);
+ *d_oo += n;
+
+ // if there are any left over, copy them into remainder and tell
+ // our caller we're had enough for now.
+
+ size_t r = n32_bit_words - n;
+ if (r > 0){
+ assert(d_remainder.size() == 0);
+ d_remainder.resize(r);
+ vrt::copy_net_16sc_to_host_32fc(r, &payload[n], &d_remainder[0]);
+ return false; // Stop calling us.
+ }
+
+ return true; // Keep calling us, we've got more room
}
-
- // copy as many as will fit into the output buffer.
-
- size_t n = std::min(n32_bit_words, (size_t)(d_noutput_items - *d_oo));
- vrt::copy_net_16sc_to_host_32fc(n, payload, &d_out[*d_oo]);
- *d_oo += n;
-
- // if there are any left over, copy them into remainder and tell
- // our caller we're had enough for now.
-
- size_t r = n32_bit_words - n;
- if (r > 0){
- assert(d_remainder.size() == 0);
- d_remainder.resize(r);
- vrt::copy_net_16sc_to_host_32fc(r, &payload[n], &d_remainder[0]);
- return false; // Stop calling us.
+ else if (hdr->if_context_p()){
+ // 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]));
+ memcpy(&d_if_context, payload, sizeof(uint32_t)*n32_bit_words);
+ d_if_context_n32_bit_words = n32_bit_words;
+ return true;
+ }
+ else {
+ // It's most likely an Extension Data or Extension Context packet
+ // (that we don't know how to interpret...)
+ fprintf(stderr, "\nIF-Extension:\n");
+ for (size_t i = 0; i < n32_bit_words; i++)
+ fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i]));
+ return true;
}
-
- return true; // Keep calling us, we've got more room
}
@@ -140,5 +168,25 @@ vrt_source_32fc::work(int noutput_items,
return -1; // say we're done
}
+ //we have a context packet, grab its useful information...
+ //remember that things are in network byte order!
+ if (h.get_if_context()){
+ //extract caldiv stuff
+ d_lo_freq = vrt_freq_to_double(ntohx(h.get_if_context()->caldiv.lo_freq));
+ d_cal_freq = vrt_freq_to_double(ntohx(h.get_if_context()->caldiv.cal_freq));
+ d_lo_locked = bool(ntohx(h.get_if_context()->caldiv.lo_locked));
+ d_cal_locked = bool(ntohx(h.get_if_context()->caldiv.cal_locked));
+ d_cal_enabled = bool(ntohx(h.get_if_context()->caldiv.cal_enabled));
+ d_caldiv_temp = vrt_temp_to_double(ntohx(h.get_if_context()->caldiv.temp));
+ d_caldiv_rev = ntohx(h.get_if_context()->caldiv.rev);
+ d_caldiv_ser = ntohx(h.get_if_context()->caldiv.ser);
+ d_caldiv_mod = ntohx(h.get_if_context()->caldiv.mod);
+ //extract gps stuff
+ d_utc_time = ntohx(h.get_if_context()->gps.formatted_gps.integer_secs);
+ d_altitude = vrt_altitude_to_double(ntohx(h.get_if_context()->gps.formatted_gps.altitude));
+ d_longitude = vrt_geo_angle_to_double(ntohx(h.get_if_context()->gps.formatted_gps.longitude));
+ d_latitude = vrt_geo_angle_to_double(ntohx(h.get_if_context()->gps.formatted_gps.latitude));
+ }
+
return oo;
}
diff --git a/gr-vrt/src/vrt_source_32fc.h b/gr-vrt/src/vrt_source_32fc.h
index 7ca3e5fe2..c43170e83 100644
--- a/gr-vrt/src/vrt_source_32fc.h
+++ b/gr-vrt/src/vrt_source_32fc.h
@@ -34,6 +34,23 @@ protected:
std::vector< std::complex<float> > d_remainder;
missing_pkt_checker d_checker;
+ //caldiv settings parsed from if context
+ double d_cal_freq;
+ bool d_cal_locked;
+ bool d_cal_enabled;
+ double d_lo_freq;
+ bool d_lo_locked;
+ double d_caldiv_temp;
+ int d_caldiv_rev;
+ int d_caldiv_ser;
+ int d_caldiv_mod;
+
+ //gps settings parsed from if context
+ int d_utc_time;
+ double d_altitude;
+ double d_longitude;
+ double d_latitude;
+
public:
~vrt_source_32fc();
@@ -42,7 +59,6 @@ public:
gr_vector_void_star &output_items);
void reset() { d_remainder.clear(); }
-
};
#endif /* INCLUDED_VRT_SOURCE_32FC_H */