Receive function for LimeSDR

Hello everyone,
if you correlate the command :
samples = dev.receive(5000,0);
with the function definition:
function [samples, timestamp_out, actual_count, overrun]
= receive(obj, num_samples, chan,timeout_ms, timestamp_in),

what exactly should be the input ‘obj’ be?
especially for when you use the device in channel 1(input chan ==1 at that time)
thanks a lot

obj in the non-OO example would be dev in the OO example.

Hello, can you please explain what is “non-00” and “00 example”?..(1)

So basically this is the receive function:

Samples_Received = dev.receive(dev, Number_Of_Samples_To_Be_Received,1);…(2)

and transmit function:

dev.transmit(dev, SS_Value,1); ???..(3)

Is that ALL right? All 3 questions?

The example

Samples_Received = dev.receive(dev, Number_Of_Samples_To_Be_Received,1);…(2)
is coded using an Object Oriented paradigm, or OO for short.
The example
function [samples, timestamp_out, actual_count, overrun]
= receive(obj, num_samples, chan,timeout_ms, timestamp_in),
is coded using a non object oriented paradigm, or what is often called a procedural paradigm.

Now, I am a bit concerned, in that it sounds like you aren’t really familiar with object oriented programming, which is how the Lime drivers are written. Can I ask what your programming background and experience level is, so that I can judge what level to pitch my answers at?

I do not know object oriented programming at all. Its only ‘C’ that i know. Now how can you still help?

I will try. I don’t recall if the Lime and Soapy interfaces have a plain C binding, but if they do, they likely will have the same form as you were showing, where the first parameter is a pointer to a structure that is the device. In an OO binding like C++, that structure becomes and object, and the functions become member functions of the object. Now, if that is clear as mud, don’t worry - basically, there will be a C function that will return a pointer to a device, and all the functions will take that as the first argument. Anytime you see a C++ example like this:
dev.DoFoo(larry,moe,curly);
you should have a C binding like this:
DoFoo(obj,larry,moe,curly);
where “obj” is the pointer you got from the library that represents the device.

Now, I am trying to understand what you are asking in the most recent post, but I don’t get what question you are trying to get answered.

You see, the basic receive function goes like this:

function [samples, timestamp_out, actual_count, overrun] = receive(obj, num_samples, chan,timeout_ms, timestamp_in)

if nargin < 3
chan = 0;
end

        if nargin < 4
            timeout_ms = 1000;
        end
        
        if nargin < 5
            timestamp_in = 0;
        end
        
        if ~obj.running
            error('please start device');
        end
        
        f32=single(zeros(2*num_samples, 1));
        
        metad = libstruct('lms_stream_meta_t');
        
        if timestamp_in == 0
            metad.waitForTimestamp=false;
        else
            metad.waitForTimestamp=true;
        end
        metad.timestamp=timestamp_in;
        if chan==0
            rx_stream=obj.rx0_stream;
            if isempty(rx_stream)
                error('rx0 stream not enabled');
            end
        else
            rx_stream=obj.rx1_stream;
            
            if isempty(rx_stream)
                error('rx1 stream not enabled');
            end
        end
        
        [actual_count, ~, f32, ~]=calllib('libLimeSuite', 'LMS_RecvStream', rx_stream,f32,num_samples,metad,timeout_ms);
        samples=(double(f32(1:2:end)) + double(f32(2:2:end))*1j);
        timestamp_out = metad.timestamp;
    end

Now, in the example that has been provided by jocover, for channel number 1, the OO call resembels:
Samples_Received = dev.receive(Number_Of_Samples_To_Be_Received,0).

However, for channel number 2, chan =1 and not chan = 0.
therefore as from above, nargin>3 but still <4. Therefore i assume the OO call would now be:
Samples_Received = dev.receive(dev, Number_Of_Samples_To_Be_Received,1)

Is that right?

If so, where do i get the value of the variable ‘dev’ from?

Would you like to see the entire limesdr.m program???

OK, that helps, if for no other reason than I have an idea what language you are using (Matlab, right?)

OK, I would suggest you start with some examples in C:
https://myriadrf.org/news/limesdr-made-simple-part-8-c-examples-soapysdr-api/
You might do better than trying to follow C++ if you don’t have any background in OO.

So you are telling me basically, after i read from your link that you gave, i will know how to formulate my receive function for the case where channel = 1 ???

Right??

And i will know what exactly to substitute for parameter “obj”

Right??

Can you just let me know how the receive function for channel 1 should look like…the final equation???

I will try reading what you have sent anyway!!!