[Discuss-gnuradio] How to get a specific output of a block if a condition is true?
Hello GNU Radio community, I'm trying to program a demodulation block for a variable pulse position modulation with c++ and have a problem where nobody know how to solve it. At the moment it is a offline simulation and don't use USRP yet but this is my final goal. I already created a block (type interpolator) that gets a byte and creates a 4-vppm symbol (containing 2 bits which mean there are 4 slots) that contains out of 4000 samples. Depending of the byte value only 10 samples are 1 at the beginning of the respective slot (i.e. (1100 if byte is 0x00 or 1100 if byte is 0x02). For adding the preamble sequence before the vppm symbol I use the "Stream Mux" block. Now the part of my problem: On the receiver side I created a preamble detection block (type general) which runs a cross-correlation and adds a tag to the stream if the preamble was found. First I used the block "Tagged Stream Align" but I found out that the block only aligns the stream one time. So if i want to start a second transmission the stream is not aligned again and I don't get the expected output. So my idea was to create a block (type general?) that search in the incoming stream for the tag "preamble_match". If a tag is found than copy 4000 samples beginning of the tag offset. It's possible that ninput_items[0] is < 4000 so I have to get the remaining items with the next call of the work-function. If I have 4000 items I want to start the demodulation and the block should only output one value. All the other time there should be no output of the block. I conected the block with a file sink and observed that the block is putting out data all the time. So how can I make sure that the block only put out a specific amout of data if a condition is true and if the condition is false no data is put out? Please find below a stripped down version of the c++ code (and attached as txt file) of my general work function: new_mode_vppm_demodulator_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 float *in = (const float *) input_items[0]; unsigned char *out = (unsigned char *) output_items[0]; // get the lowest count of items of the input and output buffer int ninput_noutput_min = std::min(noutput_items, ninput_items[0]); // create a vector of type tag_t which can hold the tag information of found tags std::vector tags; // store the distance between the first sample in the input buffer and the tag int nitems_read_tag_delta = 0; int tag_offset = 0; int ninput_items_tag_offset_delta = 0; if (d_tag_found) { std::cout << "Tag found before - get the remaining data" << std::endl; // there was one tag already in the previous call of the work-function // copy the remaining data into the array int tmp = d_read_counter; for (int i = 0; i < ninput_items[0]; i++) { /* check if the iteration variable "i" is equal to the max count of samples per symbol * or if the counter variable "d_read_counter" is equal the max count of samples per symbol */ if ((i == d_samples_per_symbol) || (d_read_counter == d_samples_per_symbol)) { // reset the d_read_counter d_read_counter = 0; d_ready_for_correlation = true; std::cout << "* !!!READY FOR CORRELATION!!! *" << std::endl; // leave the for-loop because the necessary amount of data is available for correlation break; } else{ // store the samples in the vector for correlation d_vppm_symbol_samples[i + tmp] = in[i]; d_read_counter++; } } // end for-loop std::cout << "d_tag_found=true d_read_counter: " << d_read_counter << std::endl; } else // no tag found yet { // get all tags that are stored in the sample stream get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0], d_lengthtag); // check if tags were found in the bunch of samples in input buffer if (tags.size() > 0) { d_tag_found = true; // There was a tag in the sample stream! std::cout << "Tag found - move on!!" << std::endl; std::cout << "count of tags: " << tags.size() << std::endl; // this line prints the count of tags that were found // store the offset between the first sample of the input stream and the tag tag_offset = tags[0].offset;
Re: [Discuss-gnuradio] Issue Receiving Messages Using Gr-IEEE-802-15-4
Thanks Bastian I was able to get it to work by adjusting the tuning frequency and the gain. I do have an additional question for you. Can the platform be used to communicate with XBee modules? For example, if I create a message using the message strobe in the flow graph would I be able to see this message using an XBee module? Tellrell On Thu, Aug 15, 2019 at 5:16 AM Bastian Bloessl wrote: > Hi, > > there are quite a lot of "XBee" boards. Some of them support multiple > PHYs etc. So please make sure that the device is actually sending > standard compliant IEEE 802.15.4 frames on the channel that you are > tuned to. Use gr-fosphor to make sure that the device is actually > sending on the frequency that you are expecting. > > The transceiver, by default, shows a loopback configuration. Make sure > it worked, i.e., it showed something in the PCAP file (you have to > enable the Wireshark block). > When switching to HW, disable the blocks that loop the samples back to > the PHY. > > If you still have problems, try different gains, make sure the antenna > is connected to the correct port, make sure there are no overflows. If > you use an SDR with an uncompensated DC offset, you can also try offset > tuning. > > If that also doesn't work, please provide more information. > > Best, > Bastian > > > On 8/15/19 9:48 AM, Tellrell White wrote: > > Hello > > I'm using the GR-IEEE 802.15.4 OQPSK Transceiver and I'm trying to > > receive a packet from a XBee ZigBee module and then import that packet > > to wireshark. However, the file sink is always empty after running the > > flowgraph. I have the rime stack, socket pdu, message strobe, and packet > > pad all disabled since I'm simply trying to receive a packet. Is there > > something I need to configure within the MAC block to do this? > > > > Tellrell > > > > ___ > > Discuss-gnuradio mailing list > > Discuss-gnuradio@gnu.org > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio > > > > -- > Dr. Bastian Bloessl > Secure Mobile Networking Lab (SEEMOO) > TU Darmstadt, Germany > > www.bastibl.net > GitHub/Twitter: @bastibl > > ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio