summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorjcorgan2007-02-06 00:10:32 +0000
committerjcorgan2007-02-06 00:10:32 +0000
commitc4e072e8a58800f2dfd6c1e5e95009dd783061be (patch)
tree575da3b788adacda6aeff19c730394ce1ddbdbc3 /gnuradio-core/src/lib
parentb431e9f594607e61866aef2bab73240c21c4cc6f (diff)
downloadgnuradio-c4e072e8a58800f2dfd6c1e5e95009dd783061be.tar.gz
gnuradio-c4e072e8a58800f2dfd6c1e5e95009dd783061be.tar.bz2
gnuradio-c4e072e8a58800f2dfd6c1e5e95009dd783061be.zip
Merged r4354:4390 from developer branch jcorgan/digital into trunk.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4391 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/gr_framer_sink_1.cc17
-rw-r--r--gnuradio-core/src/lib/general/gr_framer_sink_1.h11
2 files changed, 16 insertions, 12 deletions
diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc b/gnuradio-core/src/lib/general/gr_framer_sink_1.cc
index d6f87df1e..1d939adbd 100644
--- a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc
+++ b/gnuradio-core/src/lib/general/gr_framer_sink_1.cc
@@ -52,13 +52,14 @@ gr_framer_sink_1::enter_have_sync()
}
inline void
-gr_framer_sink_1::enter_have_header(int payload_len)
+gr_framer_sink_1::enter_have_header(int payload_len, int whitener_offset)
{
if (VERBOSE)
- fprintf(stderr, "@ enter_have_header (payload_len = %d)\n", payload_len);
+ fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", payload_len, whitener_offset);
d_state = STATE_HAVE_HEADER;
d_packetlen = payload_len;
+ d_packet_whitener_offset = whitener_offset;
d_packetlen_cnt = 0;
d_packet_byte = 0;
d_packet_byte_index = 0;
@@ -125,11 +126,10 @@ gr_framer_sink_1::work (int noutput_items,
// we have a full header, check to see if it has been received properly
if (header_ok()){
- int payload_len = header_payload_len();
- if (payload_len <= MAX_PKT_LEN) // reasonable?
- enter_have_header(payload_len); // yes.
- else
- enter_search(); // no.
+ int payload_len;
+ int payload_offset;
+ header_payload(&payload_len, &payload_offset);
+ enter_have_header(payload_len, payload_offset);
}
else
enter_search(); // no.
@@ -151,7 +151,8 @@ gr_framer_sink_1::work (int noutput_items,
if (d_packetlen_cnt == d_packetlen){ // packet is filled
// build a message
- gr_message_sptr msg = gr_make_message(0, 0, 0, d_packetlen_cnt);
+ // NOTE: passing header field as arg1 is not scalable
+ gr_message_sptr msg = gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt);
memcpy(msg->msg(), d_packet, d_packetlen_cnt);
d_target_queue->insert_tail(msg); // send it
diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.h b/gnuradio-core/src/lib/general/gr_framer_sink_1.h
index dab346755..ba50184b8 100644
--- a/gnuradio-core/src/lib/general/gr_framer_sink_1.h
+++ b/gnuradio-core/src/lib/general/gr_framer_sink_1.h
@@ -70,6 +70,7 @@ class gr_framer_sink_1 : public gr_sync_block
unsigned char d_packet_byte; // byte being assembled
int d_packet_byte_index; // which bit of d_packet_byte we're working on
int d_packetlen; // length of packet
+ int d_packet_whitener_offset; // offset into whitener string to use
int d_packetlen_cnt; // how many so far
protected:
@@ -77,7 +78,7 @@ class gr_framer_sink_1 : public gr_sync_block
void enter_search();
void enter_have_sync();
- void enter_have_header(int payload_len);
+ void enter_have_header(int payload_len, int whitener_offset);
bool header_ok()
{
@@ -85,11 +86,13 @@ class gr_framer_sink_1 : public gr_sync_block
return ((d_header >> 16) ^ (d_header & 0xffff)) == 0;
}
- int header_payload_len()
+ void header_payload(int *len, int *offset)
{
// header consists of two 16-bit shorts in network byte order
- int t = (d_header >> 16) & 0xffff;
- return t;
+ // payload length is lower 12 bits
+ // whitener offset is upper 4 bits
+ *len = (d_header >> 16) & 0x0fff;
+ *offset = (d_header >> 28) & 0x000f;
}
public: