discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Appending SYNC block to data


From: Johannes Demel
Subject: Re: [Discuss-gnuradio] Appending SYNC block to data
Date: Tue, 28 Jun 2016 19:10:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

Hi Olivier,

is there a reason, besides you print the values afterwards, that you copy your input data to your tab array?

Write a test which puts in your frame and checks if the output is prepended by your sync word. [syncword, payload]. Just write your preamble to the output buffer and then continue with the input.

Besides, I'd recommend using constants instead of a define for TAB_SIZE.

Cheers
Johannes

On 28.06.2016 18:27, Olivier Goyette wrote:
Hi everyone,

I'm actually coding a SYNC block for my application. I need to append a
36 bits sync word to some data coming from a Reed Solomon encoder. What
I did is to initialize an array with my 36 bits sequence and then,
plugging the data in the rest of the array. The total length of my SYNC
+ PAYLOAD + FEC PARITY is 420. So with basic calculation, 420 - 36 =
384, is the length that is left to fill the array. Actually, I can't get
the data I'm sending into the array. I'm a bit newbie with programming
GNU radio blocks so I'd like some help to understand. I'm giving my code
for you to see :

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include <stdio.h>
#include "ADD_SYNC_impl.h"

#define TAB_SIZE 420

namespace gr {
   namespace UAT {

     ADD_SYNC::sptr
     ADD_SYNC::make()
     {
       return gnuradio::get_initial_sptr
         (new ADD_SYNC_impl());
     }

     /*
      * The private constructor
      */
     ADD_SYNC_impl::ADD_SYNC_impl()
       : gr::block("ADD_SYNC",
               gr::io_signature::make(1, 1, sizeof(unsigned char)),
               gr::io_signature::make(1, 1, sizeof(unsigned char)))
     {}

     /*
      * Our virtual destructor.
      */
     ADD_SYNC_impl::~ADD_SYNC_impl()
     {
     }

     void
     ADD_SYNC_impl::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
     {
       /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */
     }

     int
     ADD_SYNC_impl::general_work (int noutput_items,
                        gr_vector_int &ninput_items,
                        gr_vector_const_void_star &input_items,
                        gr_vector_void_star &output_items)
     {
       const unsigned char *in = (const unsigned char *) input_items[0];
       char *out = (char *) output_items[0];
       //unsigned long preamble = 0b111010101100110111011010010011100010;
       unsigned char tab[TAB_SIZE] =
{1,1,1,0,1,0,1,0,1,1,0,0,1,1,0,1,1,1,0,1,1,0,1,0,0,1,0,0,1,1,1,0,0,0,1,0};

       for(int i = 36; i < TAB_SIZE; i++)
       {
           tab[i] = in[i];// Data should be inserted here???
       }

       for(int x = 0; x < TAB_SIZE; x++)
       {
           printf("%u", tab[x]);// Printing what's in the tab
           printf(" ");
       }
       printf("\n\n");


       consume_each (noutput_items);

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

   } /* namespace UAT */
} /* namespace gr */




_______________________________________________
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]