discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Appending SYNC block to data


From: Olivier Goyette
Subject: [Discuss-gnuradio] Appending SYNC block to data
Date: Tue, 28 Jun 2016 12:27:44 -0400

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 */
 
 

reply via email to

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