Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AutoFEC gnuradio patch
diff -ur a/gr-fec/grc/fec_decode_ccsds_27_fb.xml b/gr-fec/grc/fec_decode_ccsds_27_fb.xml
--- a/gr-fec/grc/fec_decode_ccsds_27_fb.xml 2016-09-02 06:16:13.000000000 +0200
+++ b/gr-fec/grc/fec_decode_ccsds_27_fb.xml 2016-10-10 15:42:31.446904672 +0200
@@ -17,4 +17,9 @@
<name>out</name>
<type>byte</type>
</source>
+ <source>
+ <name>metric</name>
+ <type>float</type>
+ <optional>1</optional>
+ </source>
</block>
diff -ur a/gr-fec/include/gnuradio/fec/viterbi.h b/gr-fec/include/gnuradio/fec/viterbi.h
--- a/gr-fec/include/gnuradio/fec/viterbi.h 2016-09-02 06:16:13.000000000 +0200
+++ b/gr-fec/include/gnuradio/fec/viterbi.h 2016-10-10 15:42:31.446904672 +0200
@@ -49,5 +49,5 @@
viterbi_butterfly2(unsigned char *symbols, int mettab[2][256],
struct viterbi_state *state0, struct viterbi_state *state1);
-FEC_API unsigned char
+FEC_API long
viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf);
diff -ur a/gr-fec/lib/decode_ccsds_27_fb_impl.cc b/gr-fec/lib/decode_ccsds_27_fb_impl.cc
--- a/gr-fec/lib/decode_ccsds_27_fb_impl.cc 2016-09-02 06:16:13.000000000 +0200
+++ b/gr-fec/lib/decode_ccsds_27_fb_impl.cc 2016-10-10 15:43:16.754904452 +0200
@@ -26,6 +26,7 @@
#include "decode_ccsds_27_fb_impl.h"
#include <gnuradio/io_signature.h>
+#include <memory.h>
namespace gr {
namespace fec {
@@ -35,10 +36,12 @@
return gnuradio::get_initial_sptr(new decode_ccsds_27_fb_impl());
}
+ static int ios[] = {sizeof(char), sizeof(float)};
+ static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
decode_ccsds_27_fb_impl::decode_ccsds_27_fb_impl()
: sync_decimator("decode_ccsds_27_fb",
io_signature::make (1, 1, sizeof(float)),
- io_signature::make (1, 1, sizeof(char)),
+ io_signature::makev (1, 2, iosig),
2*8), d_count(0) // Rate 1/2 code, unpacked to packed conversion
{
float RATE = 0.5;
@@ -48,6 +51,7 @@
gen_met(d_mettab, 100, esn0, 0.0, 256);
viterbi_chunks_init(d_state0);
viterbi_chunks_init(d_state1);
+ memset(d_viterbi_in, 0x00, sizeof(d_viterbi_in));
}
int
@@ -57,6 +61,7 @@
{
const float *in = (const float*)input_items[0];
unsigned char *out = (unsigned char*)output_items[0];
+ float* metric_out = (float*)((output_items.size() == 2) ? output_items[1] : NULL);
for (int i = 0; i < noutput_items*16; i++) {
// Translate and clip [-1.0..1.0] to [28..228]
@@ -74,9 +79,9 @@
// Every sixteenth symbol, read out a byte
if (d_count % 16 == 11) {
- // long metric =
- viterbi_get_output(d_state0, out++);
+ long metric = viterbi_get_output(d_state0, out++);
// printf("%li\n", *(out-1), metric);
+ if (metric_out) *metric_out++ = metric;
}
}
diff -ur a/gr-fec/lib/viterbi/viterbi.c b/gr-fec/lib/viterbi/viterbi.c
--- a/gr-fec/lib/viterbi/viterbi.c 2016-09-02 06:16:13.000000000 +0200
+++ b/gr-fec/lib/viterbi/viterbi.c 2016-10-10 15:42:31.447904672 +0200
@@ -326,7 +326,7 @@
BUTTERFLY(28,1);BUTTERFLY(29,0);BUTTERFLY(30,2);BUTTERFLY(31,3);
}
-unsigned char
+long
viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf) {
// Produce output every 8 bits once path memory is full
// if((bitcnt % 8) == 5 && bitcnt > 32) {
@@ -343,6 +343,7 @@
beststate = i;
}
*outbuf = state[beststate].path >> 24;
+ for(i=0;i<64;i++) state[i].metric -= bestmetric;
return bestmetric;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment