pothosware / SoapyRTLSDR

SoapySDR RTL-SDR Support Module
https://github.com/pothosware/SoapyRTLSDR/wiki
MIT License
124 stars 29 forks source link

Invalid sample values Returned #67

Closed Mas313 closed 1 year ago

Mas313 commented 1 year ago

Hi When running the following code taken from the soapysdr c API example the samples returned for FM station(audible in sdrsharp) are invalid, I think. Do I need to do any post-processing before demodulation.

  //create a re-usable buffer for rx samples
    complex float buf[32768];
while(1)
{
        void *buffs[] = {buf}; //array of buffers
        int flags=0; //flags set by receive operation
        long long timeNs=0; //timestamp for receive buffer
         ret= SoapySDRDevice_readStream(sdr, rxStream, buffs, 4096, &flags, &timeNs, 1000000); //100000 

         for(int m=0;  m<ret*1;m++)//  /8
        {               
            i= creal(buf[m]) ;  
            q =cimag(buf[m]) ;  
            printf("i=%f q=%f\n",i,q);
}

The samples obtained are as follows

i=0.000000 q=0.000000 
i=0.000000 q=0.000000
i=0.000000 q=-1.#QNAN0
i=-374479884198376570000000000000.000000 q=0.000000
i=-95881357464619777000000000000000.000000 q=-6285423662376635500000000000000000000.000000
i=-95893446722815924000000000000000.000000 q=-23410895720502123000000000000.000000
i=-5716703634517820400000000.000000 q=-93679000630630013000000000000.000000
zuckschwerdt commented 1 year ago

You are not showing declaration of i and q. Can't reproduce.

Take the pristine example code and below this (line 86)

        printf("ret=%d, flags=%d, timeNs=%lld\n", ret, flags, timeNs);

insert

        for(int m = 0;  m < ret; m++)
        {
            printf("i=%f q=%f\n", creal(buff[m]), cimag(buff[m]));
        }

This works without problems.