discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Liquid DSP Flexframe and GNU Radio


From: Johannes Demel
Subject: Re: [Discuss-gnuradio] Liquid DSP Flexframe and GNU Radio
Date: Tue, 26 Jul 2016 09:13:49 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

Hey!

As fas as I can tell, you don't check if the output buffer can actually take that many samples. Thus "you end up in the middle of invalid memory". At least that's what I guess from the code I can see. You need to ensure that 'noutput_items' always holds a value greater than your final 'total_items'.

Cheers
Johannes

On 26.07.2016 03:13, Vanhoy, Garrett M - (gvanhoy) wrote:
Hello,


I have sent this to the list once before, but I did not see it show up
on the index so I am assuming it did not work after waiting some time.


I am attempting to embed the liquid DSP
<https://github.com/jgaeddert/liquid-dsp> flexframe protocol in a custom
GNU Radio block. I am doing this by extending the out-of-tree module
that Tom Rondeau recently worked on
<https://github.com/trondeau/gr-liquiddsp>. I am writing a block that
embeds the flexframegen and another that embeds a flexframesync. Since
these blocks tend to produce a varying amount of symbols depending on
the coding scheme or modulation, I wrote it as a general block. You can
see the current version of the code at my own fork
<https://github.com/gvanhoy/gr-liquiddsp>.


I am currently having trouble with the generator and occasionally the
sync block as well. However, for the generator, I am getting a return
code -11 (I assume a seg fault) when I attempt to copy a generated frame
to the out buffer and run this in GNURadioCompanion. This often happens
after attempting to copy ~16000 gr_complex items to the outbuffer. Is
there a problems with that amount? Here is my work function code:


     {
         unsigned int buf_len = 1000;
         unsigned int payload_len = 4096;
         unsigned char header[14]; // Liquid hardcodes this as the
length for the header
         unsigned char payload[4096];

         unsigned char *in = (unsigned char *) input_items[0];
         unsigned char *inbuf = in;
         gr_complex *out = (gr_complex *) output_items[0];
         gr_complex *outbuf = (gr_complex *)
malloc(buf_len*sizeof(gr_complex));
         gr_complex *front = out;
         int byte_count = 0;

         unsigned char frame_count;
         unsigned int total_items = 0;
         int frame_complete = 0;

         // Make header
         for(int i = 1; i < 14; i++) header[i] = i;
         while(byte_count < ((int) ninput_items[0]) - payload_len) {
             header[0] = frame_count;
             frame_count > 255 ? frame_count = 0 : frame_count++;
             memcpy(payload, inbuf, payload_len);
             inbuf += payload_len;
             byte_count += payload_len;
             // Assemble the frame
             while (!flexframegen_is_assembled(d_fg)) {
                 flexframegen_assemble(d_fg, header, payload, payload_len);
             }

             // Make the frame in blocks
             frame_complete = 0;
             while (!frame_complete){
                 frame_complete = flexframegen_write_samples(d_fg,
outbuf, buf_len);
                 memcpy(front, outbuf, buf_len*sizeof(gr_complex));
                 front += buf_len;
                 total_items += buf_len;
             }

             // Get frame length
         }

         free(outbuf);
         consume_each (total_items);

       // Tell runtime system how many output items we produced.
       return total_items;
     }


Any ideas? Thanks for any help.




_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio




reply via email to

[Prev in Thread] Current Thread [Next in Thread]