# Reading data streams of the 2 RX channels simultaneusly?

**URL:** <https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242>\
**Category:** LimeSDR\
**Created:** [24 February 2019 20:14 UTC](https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242 "2019-02-24T20:14:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauro](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@mauro](https://discourse.myriadrf.org/u/mauro)\
**Post date:** [24 February 2019 20:14 UTC](https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242/1 "2019-02-24T20:14:49Z")

</div>

Hello!  
I am working with a Lime SDR USB, and the LMS API.  
I need to measure the phase difference of two signals connected to the 2 RX channels.

In the documentation of the API there are functions to read the data streams of each channel (one by one). But I haven’t seen any function that allows to read both data streams simultaneously.

Is there any function that allow to read the information of both RX channels simultaneously?  
Any other API or any other library has a function that read both RX streams at the same time?

Thanks in advance  
Mauro

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [24 February 2019 21:25 UTC](https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242/2 "2019-02-24T21:25:59Z")

</div>

When using 2 channels, both of them are received simultaneously and samples are put into each channel’s FIFO buffers. So reading data streams one by one you will get samples that are at the same time frame.

---

<div class="post-metadata">

**Author:** ![mauro](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@mauro](https://discourse.myriadrf.org/u/mauro)\
**Post date:** [25 February 2019 23:58 UTC](https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242/3 "2019-02-25T23:58:25Z")

</div>

Thanks for the answer @ricardas!

I was looking into one of the examples (dualRXTX.cpp). In this example they start the RX stream one by one:

> Blockquote  
> //Start streaming  
> for (int i = 0; i \< chCount; ++i)  
> {  
> LMS\_StartStream(&rx\_streams[i]);  
> LMS\_StartStream(&tx\_streams[i]);  
> }

I am starting the RX stream in the same way. (I guess that LMS\_StartStream() just initiates the transfer of data from the Lime board to the FIFO buffers in the PC, is it correct?). If the RX streams are started in this way, are they aligned?

I am reading a small amount (1k up to 64k samples) of each stream each time. I suppose that in this way the sample alignment between both channels is kept. Is it correct?

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [26 February 2019 09:14 UTC](https://discourse.myriadrf.org/t/reading-data-streams-of-the-2-rx-channels-simultaneusly/4242/4 "2019-02-26T09:14:17Z")

</div>

Yes, you are correct. LMS\_SetupStream determines which channels are going to be used, and actually the first call to LMS\_StartStream starts them all, subsequent calls to other LMS\_StartStream is just for reference count tracking.  
Rx streams started this way are timestamp aligned, not sure about phase alignment [2RX Phase measuremen issue -180 degree phase jump](https://discourse.myriadrf.org/t/2rx-phase-measuremen-issue-180-degree-phase-jump/4087), I haven’t tried it myself.  
As long as you read equal amount of samples from both channels they will stay aligned (as long as you’re processing samples faster than they are produced).
