Commit 62fb14e3 authored by Manolis Surligas's avatar Manolis Surligas

Extract the coded LRPT CADU

parent a344bc49
This diff is collapsed.
......@@ -56,7 +56,10 @@ lrpt_sync_impl::lrpt_sync_impl (size_t threshold) :
* sync word
*/
d_window((72 + 8)/2),
/* Each CADU has the 4 byte ASM and a VCDU of 1020 bytes*/
d_coded_cadu_len((4 + 1020) * 2),
d_frame_sync(false),
d_received(0),
d_rotate(1, 0),
d_qpsk(digital::constellation_qpsk::make()),
d_shift_reg0(0x0),
......@@ -64,7 +67,6 @@ lrpt_sync_impl::lrpt_sync_impl (size_t threshold) :
d_shift_reg2(0x0),
d_shift_reg3(0x0)
{
set_output_multiple(d_window);
const int alignment_multiple = volk_get_alignment () / sizeof(gr_complex);
set_alignment (std::max (1, alignment_multiple));
......@@ -85,6 +87,18 @@ lrpt_sync_impl::lrpt_sync_impl (size_t threshold) :
volk_free(d_rotate_2pi2);
throw std::runtime_error("lrpt_sync: Could not allocate memory");
}
d_corrected = (gr_complex *)volk_malloc(d_window, volk_get_alignment ());
if(!d_corrected) {
volk_free(d_rotate_pi2);
volk_free(d_rotate_2pi2);
volk_free(d_rotate_3pi2);
throw std::runtime_error("lrpt_sync: Could not allocate memory");
}
d_coded_cadu = new uint8_t[(4 + 1020) * 2];
/* Copy the coded ASM in front */
memcpy(d_coded_cadu, &d_asm_coded, sizeof(uint64_t));
}
/*
......@@ -95,6 +109,8 @@ lrpt_sync_impl::~lrpt_sync_impl ()
volk_free (d_rotate_pi2);
volk_free (d_rotate_2pi2);
volk_free (d_rotate_3pi2);
volk_free (d_corrected);
delete [] d_coded_cadu;
}
bool
......@@ -127,6 +143,7 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg0)) {
d_rotate = gr_complex(1.0, 0);
d_frame_sync = true;
d_received = sizeof(uint64_t);
return i * d_window + j;
}
......@@ -135,6 +152,7 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg1)) {
d_rotate = gr_complex(0.0, 1.0);
d_frame_sync = true;
d_received = sizeof(uint64_t);
return i * d_window + j;
}
......@@ -143,6 +161,7 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg2)) {
d_rotate = gr_complex(-1.0, 0);
d_frame_sync = true;
d_received = sizeof(uint64_t);
return i * d_window + j;
}
......@@ -151,6 +170,7 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg3)) {
d_rotate = gr_complex(0.0, -1.0);
d_frame_sync = true;
d_received = sizeof(uint64_t);
return i * d_window + j;
}
}
......@@ -161,6 +181,31 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
int
lrpt_sync_impl::work_sync(const gr_complex *in, int noutput_items)
{
uint8_t b;
int multiple = noutput_items / d_window;
for(int i = 0; i < multiple; i++) {
volk_32fc_s32fc_multiply_32fc(d_corrected, in + i * d_window,
d_rotate, d_window);
/*
* Skip UW, for now
* NOTE: UW is unencoded
*/
for(int j = 0; j < d_window - 4; j += 4) {
b = 0;
b = d_qpsk->decision_maker(d_corrected + j) << 6;
b |= d_qpsk->decision_maker(d_corrected + j + 1) << 4;
b |= d_qpsk->decision_maker(d_corrected + j + 2) << 2;
b |= d_qpsk->decision_maker(d_corrected + j + 3);
d_coded_cadu[d_received++] = b;
if(d_received == d_coded_cadu_len) {
LOG_ERROR("frame");
d_received = 0;
d_frame_sync = false;
return i * d_window + j + 4;
}
}
}
return noutput_items;
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment